LPXXX volcopy protect statuses
authorBill Erickson <berickxx@gmail.com>
Thu, 2 Jul 2020 20:23:31 +0000 (16:23 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 2 Jul 2020 20:23:31 +0000 (16:23 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts

index 08af143..d91d41e 100644 (file)
   <div class="flex-1 p-1">
     <div class="p-1"><h4 class="font-weight-bold" i18n>Identification</h4></div>
 
-    <!-- TODO: status is batch editable under certain conditions -->
+
     <div class="mb-1" *ngIf="displayAttr('status')">
-      <eg-batch-item-attr label="Status" i18n-label 
-        [readOnly]="!statusEditable()"
-        [labelCounts]="itemAttrCounts('status')">
-      </eg-batch-item-attr>
+
+      <ng-container *ngIf="statusEditable(); else noEditStat">
+        <ng-template #statusTemplate>
+          <eg-combobox domId="status-input"
+            (ngModelChange)="values['status'] = $event ? $event.id : null"
+            [ngModel]="values['status']">
+            <eg-combobox-entry 
+              *ngFor="let stat of volcopy.commonData.acp_status"
+              [entryId]="stat.id()" [entryLabel]="stat.name()">
+            </eg-combobox-entry>
+          </eg-combobox>
+        </ng-template>
+        <ng-container *ngTemplateOutlet="batchAttr;
+          context:{field:'status',template:statusTemplate}">
+        </ng-container>
+      </ng-container>
+
+      <ng-template #noEditStat>
+        <eg-batch-item-attr label="Status" i18n-label [readOnly]="true"
+          [labelCounts]="itemAttrCounts('status')">
+        </eg-batch-item-attr>
+      </ng-template>
     </div>
 
     <div class="mb-1" *ngIf="displayAttr('barcode')">
       <eg-string #olLabel text="Owning Library" i18n-text></eg-string>
       <ng-template #owningLibTemplate>
         <eg-org-select 
-          domId="owning-lib-input"
+          domId="owning_lib-input"
           (onChange)="values['owning_lib'] = $event ? $event.id() : null"
           [limitPerms]="['UPDATE_COPY']">
         </eg-org-select>
index b62f280..620ee81 100644 (file)
           <div class="d-flex">
             <ng-container *ngIf="context.sessionType != 'copy'">
               <button class="clear-button" (click)="deleteCopy(copyNode)"
+                [disabled]="volcopy.restrictCopyDelete(copyNode.target.status())"
                 title="Delete Item {{copyNode.target.barcode()}}" i18n-title>
                 <span class="material-icons">clear</span>
               </button>
index 84afaf5..fec38e0 100644 (file)
@@ -296,8 +296,7 @@ export class VolEditComponent implements OnInit {
     }
 
     barcodeCanChange(copy: IdlObject): boolean {
-        // TODO
-        return true;
+        return !this.volcopy.copyStatIsMagic(copy.status());
     }
 
     generateBarcodes() {
index 8711740..c2a0aa5 100644 (file)
@@ -413,8 +413,12 @@ export class VolCopyService {
     }
 
 
-    copyStatIsMagic(id: number): boolean {
-        return this.magicCopyStats.includes(id);
+    copyStatIsMagic(statId: number): boolean {
+        return this.magicCopyStats.includes(statId);
+    }
+
+    restrictCopyDelete(statId: number): boolean {
+        return this.copyStatuses[statId].restrict_copy_delete() === 't';
     }
 }