LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Jun 2020 21:48:25 +0000 (17:48 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 16 Jun 2020 21:48:25 +0000 (17:48 -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.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html
Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts

index 139597f..253b3bc 100644 (file)
@@ -1,2 +1,156 @@
 
 
+<div class="row">
+  <!-- templates row -->
+</div>
+
+<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 class="flex-1 p-1"><h3 class="font-weight-bold" i18n>Circulation</h3></div>
+  <div class="flex-1 p-1"><h3 class="font-weight-bold" i18n>Miscellaneous</h3></div>
+  <div class="flex-1 p-1"><h3 class="font-weight-bold" i18n>Statistics</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 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>
+  <div class="flex-1 p-1">
+  </div>
+</div>
+
+<!-- ROW 2 -->
+
+<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>
+
+<!-- ROW 3 -->
+
+<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>
+
+<!-- ROW 4 -->
+
+<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>
+
+<!-- ROW 5 -->
+
+<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>
+  <div class="flex-1 p-1">
+  </div>
+</div>
+
+<!-- ROW 6 -->
+
+<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>
+
+<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 class="flex-1 p-1">
+  </div>
+  <div class="flex-1 p-1">
+  </div>
+  <div class="flex-1 p-1">
+  </div>
+</div>
+
index f32b4d3..9ef3b05 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
+import {Component, Input, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {tap} from 'rxjs/operators';
 import {IdlObject, IdlService} from '@eg/core/idl.service';
@@ -10,14 +10,15 @@ import {PcrudService} from '@eg/core/pcrud.service';
 import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
 import {VolCopyContext} from './volcopy';
 import {VolCopyService} from './volcopy.service';
-
-
+import {FormatService} from '@eg/core/format.service';
 
 @Component({
+  selector: 'eg-copy-attrs',
   templateUrl: 'copy-attrs.component.html'
 })
 export class CopyAttrsComponent implements OnInit {
 
+    @Input() context: VolCopyContext;
 
     constructor(
         private router: Router,
@@ -30,13 +31,46 @@ export class CopyAttrsComponent implements OnInit {
         private auth: AuthService,
         private pcrud: PcrudService,
         private holdings: HoldingsService,
-        private volcopy: VolCopyService
+        private volcopy: VolCopyService,
+        private format: FormatService
     ) { }
 
 
     ngOnInit() {
     }
 
+    itemAttrCounts(field: string): {[value: string]: number} {
+
+        const counts = {};
+        this.context.copyList().forEach(copy => {
+            let value = copy[field]();
+            if (value === undefined || value === null) { value = ''; }
+
+            if (value !== '') {
+
+                if (field === 'status') {
+                    if (value in this.volcopy.copyStatuses) {
+                        value = this.volcopy.copyStatuses[value].name();
+                    }
+
+                } else if (field.match(/date/)) {
+                    value = this.format.transform({
+                       datatype: 'timestamp',
+                       value: value
+                    });
+                } else if (field === 'creator' || field === 'editor') {
+                    value = value.usrname();
+                }
+            }
+
+            if (counts[value] === undefined) {
+                counts[value] = 0;
+            };
+            counts[value]++;
+        });
+
+        return counts;
+    }
 }
 
 
index 7eec480..086edc9 100644 (file)
 
   <eg-bib-summary *ngIf="context.recordId" [recordId]="context.recordId"></eg-bib-summary>
   
-  <div class="mt-3">
+  <div class="mt-3" *ngIf="!context.hideVols">
     <eg-vol-edit [context]="context"></eg-vol-edit>
   </div>
 
+  <div class="mt-3" *ngIf="!context.hideCopies">
+    <eg-copy-attrs [context]="context"></eg-copy-attrs>
+  </div>
 
   <div class="row m-2 p-2 border border-info">
     <div class="col-lg-12 d-flex">
index 6b24704..5932ffb 100644 (file)
@@ -16,7 +16,7 @@ import {VolCopyService} from './volcopy.service';
 const COPY_FLESH = {
     flesh: 1,
     flesh_fields: {
-        acp: ['call_number', 'location', 'parts']
+        acp: ['call_number', 'location', 'parts', 'creator', 'editor']
     }
 };
 
index 64fd34d..1d673b4 100644 (file)
@@ -2,7 +2,7 @@
 <div class="border rounded p-1">
   <div class="font-weight-bold">{{label}}</div>
   <div *ngIf="!editing" tabindex="0" class="p-1"
-    [ngClass]="{'bg-info': hasChanged}" (click)="editing = true">
+    [ngClass]="{'bg-info': hasChanged}" (click)="toggleEditMode()">
     <div class="d-flex" 
       *ngFor="let count of labelCounts | keyvalue">
       <div class="flex-1">
index dc3be46..46b8958 100644 (file)
@@ -30,6 +30,9 @@ export class BatchItemAttrComponent {
     // human friendly.
     @Input() displayAs: 'bool' | 'currency' = null;
 
+    // Display only
+    @Input() readOnly = false;
+
     @Output() changesSaved: EventEmitter<void> = new EventEmitter<void>();
     @Output() changesCanceled: EventEmitter<void> = new EventEmitter<void>();
 
@@ -50,6 +53,12 @@ export class BatchItemAttrComponent {
         this.editing = false;
         this.changesCanceled.emit();
     }
+
+    toggleEditMode() {
+        if (!this.readOnly) {
+            this.editing = !this.editing;
+        }
+    }
 }