VOLCOPY Item attr batch component
authorBill Erickson <berickxx@gmail.com>
Wed, 27 May 2020 21:04:24 +0000 (17:04 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 25 Jun 2020 14:36:18 +0000 (10:36 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts

diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.html
new file mode 100644 (file)
index 0000000..64fd34d
--- /dev/null
@@ -0,0 +1,31 @@
+
+<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">
+    <div class="d-flex" 
+      *ngFor="let count of labelCounts | keyvalue">
+      <div class="flex-1">
+        <ng-container *ngIf="displayAs == 'bool'">
+          <span *ngIf="count.key == 't'" i18n>Yes</span>
+          <span *ngIf="count.key == 'f'" i18n>No</span>
+        </ng-container>
+        <ng-container *ngIf="displayAs == 'currency'">
+          {{count.key | currency}}
+        </ng-container>
+        <ng-container *ngIf="displayAs == null">
+          {{count.key}}
+        </ng-container>
+      </div>
+      <div i18n>{{count.value}} copies</div>
+    </div>
+  </div>
+  <ng-container *ngIf="editing">
+    <ng-container *ngTemplateOutlet="editTemplate"></ng-container>
+    <div class="mt-1">
+      <button class="btn btn-outline-dark" (click)="save()" i18n>Apply</button>
+      <button class="btn btn-outline-dark ml-1" (click)="cancel()" i18n>Cancel</button>
+    </div>
+  </ng-container>
+</div>
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/batch-item-attr.component.ts
new file mode 100644 (file)
index 0000000..dc3be46
--- /dev/null
@@ -0,0 +1,56 @@
+import {Component, OnInit, Input, Output, ViewChild, Renderer2, TemplateRef,
+    EventEmitter} from '@angular/core';
+import {StringComponent} from '@eg/share/string/string.component';
+
+/**
+ * Displays attribute values and associated copy counts for managing
+ * updates to batches of items.
+ */
+
+@Component({
+  selector: 'eg-batch-item-attr',
+  templateUrl: 'batch-item-attr.component.html'
+})
+
+export class BatchItemAttrComponent {
+
+    // Main display label, e.g. "Circulation Modifier"
+    @Input() label: string;
+
+    // Maps display labels to the number of items that have the label.
+    // e.g. {"Stacks": 4, "Display": 12}
+    @Input() labelCounts: {[label: string]: number} = {};
+
+    // Ref to some type of edit widget for modifying the value.
+    // Note this component simply displays the template, it does not
+    // interact with the template in any way.
+    @Input() editTemplate: TemplateRef<any>;
+
+    // In some cases, we can map display labels to something more
+    // human friendly.
+    @Input() displayAs: 'bool' | 'currency' = null;
+
+    @Output() changesSaved: EventEmitter<void> = new EventEmitter<void>();
+    @Output() changesCanceled: EventEmitter<void> = new EventEmitter<void>();
+
+    // Is the editTtemplate visible?
+    editing = false;
+
+    hasChanged = false;
+
+    constructor() {}
+
+    save() {
+        this.hasChanged = true;
+        this.editing = false;
+        this.changesSaved.emit();
+    }
+
+    cancel() {
+        this.editing = false;
+        this.changesCanceled.emit();
+    }
+}
+
+
+
index bc93932..b33863b 100644 (file)
@@ -9,6 +9,7 @@ import {DeleteHoldingDialogComponent} from './delete-volcopy-dialog.component';
 import {ConjoinedItemsDialogComponent} from './conjoined-items-dialog.component';
 import {TransferItemsComponent} from './transfer-items.component';
 import {TransferHoldingsComponent} from './transfer-holdings.component';
+import {BatchItemAttrComponent} from './batch-item-attr.component';
 
 @NgModule({
     declarations: [
@@ -19,7 +20,8 @@ import {TransferHoldingsComponent} from './transfer-holdings.component';
       DeleteHoldingDialogComponent,
       ConjoinedItemsDialogComponent,
       TransferItemsComponent,
-      TransferHoldingsComponent
+      TransferHoldingsComponent,
+      BatchItemAttrComponent
     ],
     imports: [
         StaffCommonModule
@@ -32,7 +34,8 @@ import {TransferHoldingsComponent} from './transfer-holdings.component';
       DeleteHoldingDialogComponent,
       ConjoinedItemsDialogComponent,
       TransferItemsComponent,
-      TransferHoldingsComponent
+      TransferHoldingsComponent,
+      BatchItemAttrComponent
     ],
     providers: [
         HoldingsService