--- /dev/null
+
+<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>
+
--- /dev/null
+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();
+ }
+}
+
+
+
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: [
DeleteHoldingDialogComponent,
ConjoinedItemsDialogComponent,
TransferItemsComponent,
- TransferHoldingsComponent
+ TransferHoldingsComponent,
+ BatchItemAttrComponent
],
imports: [
StaffCommonModule
DeleteHoldingDialogComponent,
ConjoinedItemsDialogComponent,
TransferItemsComponent,
- TransferHoldingsComponent
+ TransferHoldingsComponent,
+ BatchItemAttrComponent
],
providers: [
HoldingsService