<div class="p-1" [ngStyle]="{flex: flexAt(7)}">
<label class="font-weight-bold" i18n>Batch</label>
<div>
- <button class="btn btn-outline-dark label-with-material-icon"
+ <button class="btn btn-sm btn-outline-dark label-with-material-icon"
(click)="batchVolApply()">
<span i18n>Apply</span>
<span class="material-icons">arrow_downward</span>
<div class="p-1" [ngStyle]="{flex: flexAt(3)}">
<ng-container *ngIf="copyIdx == 0">
<eg-combobox
- [startId]="volNode.target.label_class()"
+ [selectedId]="volNode.target.label_class()"
[smallFormControl]="true"
[required]="true"
(onChange)="applyVolValue(volNode.target, 'label_class', $event ? $event.id : null)">
<div class="p-1" [ngStyle]="{flex: flexAt(4)}">
<ng-container *ngIf="copyIdx == 0">
<eg-combobox
- [startId]="volNode.target.prefix()"
+ [selectedId]="volNode.target.prefix()"
[required]="true"
[smallFormControl]="true"
(onChange)="applyVolValue(volNode.target, 'prefix', $event ? $event.id : null)">
<div class="p-1" [ngStyle]="{flex: flexAt(5)}">
<ng-container *ngIf="copyIdx == 0">
<input class="form-control form-control-sm" type="text"
+ spellcheck="false"
[required]="true"
[ngModel]="volNode.target.label()"
(onChange)="applyVolValue(volNode.target, 'label', $event)">
<div class="p-1" [ngStyle]="{flex: flexAt(6)}">
<ng-container *ngIf="copyIdx == 0">
<eg-combobox
- [startId]="volNode.target.suffix()"
+ [selectedId]="volNode.target.suffix()"
[required]="true"
[smallFormControl]="true"
(onChange)="applyVolValue(volNode.target, 'suffix', $event ? $event.id : null)">
</div>
<div class="p-1" [ngStyle]="{flex: flexAt(8)}">
<input type="text" class="form-control form-control-sm"
+ id="barcode-input-{{copyNode.target.id()}}"
+ spellcheck="false"
[required]="true"
+ (keyup.enter)="selectNextBarcode(copyNode.target.id())"
+ (keyup.shift.enter)="selectNextBarcode(copyNode.target.id(), true)"
[ngModel]="copyNode.target.barcode()"
(ngModelChange)="applyCopyValue(copyNode.target, 'barcode', $event)"/>
</div>
<ng-container *ngIf="recordHasParts(volNode.target.record())">
<eg-combobox
[disabled]="bibParts[volNode.target.record()].length == 0"
- [startId]="copyNode.target.parts()[0] ? copyNode.target.parts()[0].id() : null"
+ [selectedId]="copyNode.target.parts()[0] ? copyNode.target.parts()[0].id() : null"
[smallFormControl]="true"
(onChange)="copyPartChanged(copyNode, $event)">
<eg-combobox-entry *ngFor="let part of bibParts[volNode.target.record()]"
volSuffixes: IdlObject[] = null;
bibParts: {[bibId: number]: IdlObject[]} = {};
- batchVolClass: number = null;
- batchVolPrefix: number = null;
- batchVolSuffix: number = null;
- batchVolLabel: string = null;
+ batchVolClass: ComboboxEntry;
+ batchVolPrefix: ComboboxEntry;
+ batchVolSuffix: ComboboxEntry;
+ batchVolLabel: ComboboxEntry;
+
recordVolLabels: string[] = [];
constructor(
+ private renderer: Renderer2,
private pcrud: PcrudService,
private net: NetService,
private holdings: HoldingsService
}
batchVolApply() {
+ this.context.volNodes().forEach(volNode => {
+ const vol = volNode.target;
+ console.log('batch vol class', this.batchVolClass.id);
+ if (this.batchVolClass) {
+ this.applyVolValue(vol, 'label_class', this.batchVolClass.id);
+ }
+ if (this.batchVolPrefix) {
+ this.applyVolValue(vol, 'prefix', this.batchVolPrefix.id);
+ }
+ if (this.batchVolSuffix) {
+ this.applyVolValue(vol, 'suffix', this.batchVolSuffix.id);
+ }
+ if (this.batchVolLabel) {
+ this.applyVolValue(vol, 'label', this.batchVolLabel.id);
+ }
+ });
+ }
+
+ selectNextBarcode(id: number, previous?: boolean) {
+ let found = false;
+ let nextId: number = null;
+ let firstId: number = null;
+
+ let copies = this.context.copyList();
+ if (previous) { copies = copies.reverse(); }
+
+ // Find the ID of the next item. If this is the last item,
+ // loop back to the first item.
+ copies.forEach(copy => {
+ if (nextId !== null) { return; }
+
+ // In case we have to loop back to the first copy.
+ if (firstId === null) { firstId = copy.id(); }
+
+ if (found) {
+ if (nextId === null) {
+ nextId = copy.id();
+ }
+ } else if (copy.id() === id) {
+ found = true;
+ }
+ });
+
+ this.renderer.selectRootElement(
+ '#barcode-input-' + (nextId || firstId)).select();
}
}
return this.holdings.root.children;
}
+ volNodes(): HoldingsTreeNode[] {
+ let vols = [];
+ this.orgNodes().forEach(orgNode =>
+ vols = vols.concat(orgNode.children));
+ return vols;
+ }
+
+ copyList(): IdlObject[] {
+ let copies = [];
+ this.volNodes().forEach(volNode => {
+ copies = copies.concat(volNode.children.map(c => c.target));
+ });
+ return copies;
+ }
+
// Returns IDs for all bib records represented in our holdings tree.
getRecordIds(): number[] {
const idHash: {[id: number]: boolean} = {};