LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Mon, 15 Jun 2020 15:17:37 +0000 (11:17 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 15 Jun 2020 15:17:37 +0000 (11:17 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
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.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts

index 3f30820..e4ddab1 100644 (file)
         <div class="p-1" [ngStyle]="{flex: flexAt(2)}">
           <ng-container *ngIf="copyIdx == 0 && volIdx == 0">
             <input type="number" class="form-control form-control-sm"
+              [disabled]="context.sessionType == 'copy' || context.sessionType == 'vol'"
               [required]="true" [min]="existingVolCount(orgNode)"
               [ngModel]="orgNode.children.length"
               (ngModelChange)="volCountChanged(orgNode, $event)"/>
         <div class="p-1" [ngStyle]="{flex: flexAt(7)}">
           <ng-container *ngIf="copyIdx == 0">
             <input type="number" class="form-control form-control-sm"
+              [disabled]="context.sessionType == 'copy'"
               [required]="true" [min]="existingCopyCount(volNode)"
               [ngModel]="volNode.children.length"
               (ngModelChange)="copyCountChanged(volNode, $event)"/>
index 16a5862..87d6faf 100644 (file)
@@ -206,6 +206,7 @@ export class VolEditComponent implements OnInit {
         copy.opac_visible('t');
         copy.ref('f');
         copy.mint_condition('t');
+        copy.parts([]);
 
         // TODO: status / fast-add / defaults?
 
index 97256b1..0de85f8 100644 (file)
@@ -8,7 +8,7 @@
 
 <ng-container *ngIf="!loading">
 
-  <eg-bib-summary *ngIf="recordId" [recordId]="recordId"></eg-bib-summary>
+  <eg-bib-summary *ngIf="context.recordId" [recordId]="context.recordId"></eg-bib-summary>
   
   <div class="mt-3">
     <eg-vol-edit [context]="context"></eg-vol-edit>
index 50a1df1..ec145c6 100644 (file)
@@ -25,16 +25,6 @@ export class VolCopyComponent implements OnInit {
 
     context: VolCopyContext;
 
-    // Note in multi-record mode this value will be unset.
-    recordId: number;
-
-    // Load specific call number by ID.
-    volId: number;
-
-    // Load specific copy by ID.
-    copyId: number;
-
-    session: string;
     loading = true;
     @ViewChild('loadingProgress', {static: false})
     loadingProgress: ProgressInlineComponent;
@@ -61,10 +51,10 @@ export class VolCopyComponent implements OnInit {
     }
 
     negotiateRoute(params: ParamMap) {
-        this.recordId = +params.get('record_id') || null;
-        this.volId    = +params.get('vol_id')    || null;
-        this.copyId   = +params.get('copy_id')   || null;
-        this.session  =  params.get('session')   || null;
+        this.context.recordId = +params.get('record_id') || null;
+        this.context.volId    = +params.get('vol_id')    || null;
+        this.context.copyId   = +params.get('copy_id')   || null;
+        this.context.session  =  params.get('session')   || null;
         this.load();
     }
 
@@ -87,21 +77,26 @@ export class VolCopyComponent implements OnInit {
     }
 
     setRecordId() {
-        if (!this.recordId) {
+        if (!this.context.recordId) {
             const ids = this.context.getRecordIds();
             if (ids.length === 1) {
-                this.recordId = ids[0];
+                this.context.recordId = ids[0];
             }
         }
     }
 
     fetchHoldings(): Promise<any> {
-        if (this.copyId) {
-            return this.fetchCopies(this.copyId);
-        } else if (this.volId) {
-            return this.fetchVols(this.volId);
-        } else if (this.recordId) {
-            return this.fetchRecords(this.recordId);
+        if (this.context.copyId) {
+            this.context.sessionType = 'copy';
+            return this.fetchCopies(this.context.copyId);
+        } else if (this.context.volId) {
+            this.context.sessionType = 'vol';
+            return this.fetchVols(this.context.volId);
+        } else if (this.context.recordId) {
+            this.context.sessionType = 'record';
+            return this.fetchRecords(this.context.recordId);
+        } else if (this.context.session) {
+            this.context.sessionType = 'mixed';
         }
     }
 
index 8918244..75d88cd 100644 (file)
@@ -24,6 +24,20 @@ export class VolCopyContext {
     holdings: HoldingsTree = new HoldingsTree();
     org: OrgService; // injected
 
+    sessionType: 'copy' | 'vol' | 'record' | 'mixed';
+
+    // Edit content comes from a cached session
+    session: string;
+
+    // Note in multi-record mode this value will be unset.
+    recordId: number;
+
+    // Load specific call number by ID.
+    volId: number;
+
+    // Load specific copy by ID.
+    copyId: number;
+
     volsToDelete: IdlObject[] = [];
     copiesToDelete: IdlObject[] = [];