LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Thu, 2 Jul 2020 16:43:25 +0000 (12:43 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 2 Jul 2020 16:43:25 +0000 (12:43 -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/copy-attrs.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts

index bede5f5..08af143 100644 (file)
@@ -74,7 +74,8 @@
 
     <!-- TODO: status is batch editable under certain conditions -->
     <div class="mb-1" *ngIf="displayAttr('status')">
-      <eg-batch-item-attr label="Status" i18n-label [readOnly]="true"
+      <eg-batch-item-attr label="Status" i18n-label 
+        [readOnly]="!statusEditable()"
         [labelCounts]="itemAttrCounts('status')">
       </eg-batch-item-attr>
     </div>
index 2097f00..cf4e98a 100644 (file)
@@ -546,6 +546,17 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
         const def = this.idl.classes.acp.field_map[field];
         return def ? def.label : '';
     }
+
+    // Returns false if any items are in magic statuses
+    statusEditable(): boolean {
+        const copies = this.context.copyList();
+        for (let idx = 0; idx < copies.length; idx++) {
+            if (this.volcopy.copyStatIsMagic(copies[idx].status())) {
+                return false;
+            }
+        }
+        return true;
+    }
 }
 
 
index 97895ae..b62f280 100644 (file)
               title="{{copyStatLabel(copyNode.target)}}"
               id="barcode-input-{{copyNode.target.id()}}"
               spellcheck="false" [required]="true"
+              [disabled]="volcopy.copyStatIsMagic(copyNode.target.status())"
               [ngClass]="{'text-danger': copyNode.target._dupe_barcode}"
               (change)="barcodeChanged(copyNode.target, $event.target.value)"  
               (ngModelChange)="copyNode.target.barcode($event)"
index ba20dc9..8711740 100644 (file)
@@ -45,6 +45,7 @@ export class VolCopyService {
     templates: any = {};
 
     commonData: {[key: string]: IdlObject[]} = {};
+    magicCopyStats: number[] = [];
 
     constructor(
         private evt: EventService,
@@ -81,11 +82,12 @@ export class VolCopyService {
             'eg.cat.record.summary.collapse'
         ]))
 
+        .then(_ => this.holdings.getMagicCopyStatuses())
+        .then(stats => this.magicCopyStats = stats)
         .then(_ => this.fetchDefaults())
         .then(_ => this.fetchTemplates());
     }
 
-
     ingestCommonData() {
 
         this.commonData.acp_location.forEach(
@@ -410,5 +412,9 @@ export class VolCopyService {
         );
     }
 
+
+    copyStatIsMagic(id: number): boolean {
+        return this.magicCopyStats.includes(id);
+    }
 }
 
index 9c2b4a5..e86c44c 100644 (file)
@@ -64,5 +64,17 @@ export class HoldingsService {
             });
         });
     }
+
+    /* TODO: make these more configurable per lp1616170 */
+    getMagicCopyStatuses(): Promise<number[]> {
+        return Promise.resolve([
+            1,  // Checked out
+            3,  // Lost
+            6,  // In transit
+            8,  // On holds shelf
+            16, // Long overdue
+            18  // Canceled Transit
+        ]);
+    }
 }