LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Jun 2020 22:18:41 +0000 (18:18 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 16 Jun 2020 22:18:41 +0000 (18:18 -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/volcopy.module.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts

index 253b3bc..c834bf8 100644 (file)
@@ -1,9 +1,11 @@
 
 
+<!-- Copy Templates -->
 <div class="row">
-  <!-- templates row -->
 </div>
 
+<!-- List of Edit Templates -->
+
 <div class="row d-flex">
   <div class="flex-1 p-1"><h3 class="font-weight-bold" i18n>Identification</h3></div>
   <div class="flex-1 p-1"><h3 class="font-weight-bold" i18n>Location</h3></div>
 </div>
 
 
-<!-- List of Edit Templates -->
-<ng-template #locationEditTemplate>
-  <eg-combobox #locationCbox [entries]="circModifiers"></eg-combobox>
-</ng-template>
-
-<!-- ROW 1 -->
+<div class="row d-flex">
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Status" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('status')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Location / Collection" i18n-label            
-      [labelCounts]="itemAttrCounts('location')"
-      [editTemplate]="locationEditTemplate"
-      (changesSaved)="locationChanged(locationModCbox.selected)">               
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
+  <!-- COLUMN 1 -->
   <div class="flex-1 p-1">
-  </div>
-</div>
 
-<!-- ROW 2 -->
+    <div class="mb-1">
+      <eg-batch-item-attr label="Status" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('status')">
+      </eg-batch-item-attr>
+    </div>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Barcode" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('barcode')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-</div>
+    <div class="mb-1">
+      <eg-batch-item-attr label="Barcode" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('barcode')">
+      </eg-batch-item-attr>
+    </div>
 
-<!-- ROW 3 -->
+    <div class="mb-1">
+      <eg-batch-item-attr label="Creation Date" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('create_date')">
+      </eg-batch-item-attr>
+    </div>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Creation Date" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('create_date')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-</div>
+    <div class="mb-1">
+      <eg-batch-item-attr label="Active Date" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('active_date')">
+      </eg-batch-item-attr>
+    </div>
 
-<!-- ROW 4 -->
+    <div class="mb-1">
+      <eg-batch-item-attr label="Creator" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('creator')">
+      </eg-batch-item-attr>
+    </div>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Active Date" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('active_date')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-</div>
+    <div class="mb-1">
+      <eg-batch-item-attr label="Last Edit Date" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('edit_date')">
+      </eg-batch-item-attr>
+    </div>
 
-<!-- ROW 5 -->
+    <div class="mb-1">
+      <eg-batch-item-attr label="Last Editor" i18n-label            
+        [readOnly]="true"
+        [labelCounts]="itemAttrCounts('editor')">
+      </eg-batch-item-attr>
+    </div>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Creator" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('creator')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
   </div>
+
+  <!-- COLUMN 2 -->
   <div class="flex-1 p-1">
-  </div>
-</div>
 
-<!-- ROW 6 -->
+    <div>
+      <ng-template #locationEditTemplate>
+        <eg-item-location-select (valueChange)="batchLocation = $event"
+          [required]="true" permFilter="UPDATE_COPY">
+        </eg-item-location-select>
+      </ng-template>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Last Edit Date" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('edit_date')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-  <div class="flex-1 p-1">
-  </div>
-</div>
+      <eg-batch-item-attr label="Location / Collection" i18n-label            
+        [labelCounts]="itemAttrCounts('location')"
+        [editTemplate]="locationEditTemplate"
+        (changesSaved)="locationChanged()">               
+      </eg-batch-item-attr>
+    </div>
 
-<div class="row d-flex mb-1">
-  <div class="flex-1 p-1">
-    <eg-batch-item-attr label="Last Editor" i18n-label            
-      [readOnly]="true"
-      [labelCounts]="itemAttrCounts('editor')">
-    </eg-batch-item-attr>
-  </div>
-  <div class="flex-1 p-1">
-  </div>
+  </div> 
+
+  <!-- COLUMN 3 -->
   <div class="flex-1 p-1">
-  </div>
+  </div> 
+
+  <!-- COLUMN 4 -->
   <div class="flex-1 p-1">
-  </div>
+  </div> 
+
+  <!-- COLUMN 5 -->
   <div class="flex-1 p-1">
-  </div>
+  </div> 
 </div>
 
+
index 9ef3b05..5b8e122 100644 (file)
@@ -20,6 +20,8 @@ export class CopyAttrsComponent implements OnInit {
 
     @Input() context: VolCopyContext;
 
+    batchLocation: any;
+
     constructor(
         private router: Router,
         private route: ActivatedRoute,
@@ -53,6 +55,9 @@ export class CopyAttrsComponent implements OnInit {
                         value = this.volcopy.copyStatuses[value].name();
                     }
 
+                } else if (field === 'location') {
+                    value = value.name();
+
                 } else if (field.match(/date/)) {
                     value = this.format.transform({
                        datatype: 'timestamp',
@@ -71,6 +76,19 @@ export class CopyAttrsComponent implements OnInit {
 
         return counts;
     }
+
+    applyCopyValue(field: string, value: any) {
+        this.context.copyList().forEach(copy => {
+            if (copy[field] && copy[field]() !== value) {
+                copy[field](value);
+                copy.ischanged(true);
+            }
+        });
+    }
+
+    locationChanged() {
+        this.applyCopyValue('location', this.batchLocation);
+    }
 }
 
 
index 7a267fe..7400161 100644 (file)
@@ -7,6 +7,7 @@ import {VolCopyComponent} from './volcopy.component';
 import {VolEditComponent} from './vol-edit.component';
 import {VolCopyService} from './volcopy.service';
 import {CopyAttrsComponent} from './copy-attrs.component';
+import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module';
 
 @NgModule({
   declarations: [
@@ -18,7 +19,8 @@ import {CopyAttrsComponent} from './copy-attrs.component';
     StaffCommonModule,
     CommonWidgetsModule,
     HoldingsModule,
-    VolCopyRoutingModule
+    VolCopyRoutingModule,
+    ItemLocationSelectModule
   ],
   providers: [
     VolCopyService
index 73d8654..abaa8b8 100644 (file)
@@ -39,7 +39,12 @@ export class VolCopyService {
             defaults => {
                 this.defaultValues = defaults || {};
             }
-        );
+        ).then(_ => {
+
+            // Default to location ID 1 (Stacks)
+            return this.pcrud.retrieve('acpl', 1).toPromise()
+            .then(loc => this.defaultValues.location = loc);
+        });
     }
 
     fetchCopyStats(): Promise<any> {
@@ -99,7 +104,7 @@ export class VolCopyService {
         copy.deposit_amount(0);
         copy.fine_level(2);     // Normal
         copy.loan_duration(2);  // Normal
-        copy.location(1);       // Stacks
+        copy.location(this.defaultValues.location);  // Stacks / fleshed
         copy.circulate('t');
         copy.holdable('t');
         copy.opac_visible('t');