dialogTitle="Delete Call Number?"
dialogBody="Delete {{deleteVolCount}} Call Number(s) and {{deleteCopyCount}} Associated Item(s)?">
</eg-confirm-dialog>
+<eg-confirm-dialog
+ #confirmDelCopy
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Delete Item?"
+ dialogBody="Delete {{deleteCopyCount}} Item(s)?">
+</eg-confirm-dialog>
<div class="row d-flex vol-row border border-info mb-2">
- <div class="p-1" [ngStyle]="{flex: flexAt(1)}">
- </div>
- <div class="p-1" [ngStyle]="{flex: flexAt(2)}">
- </div>
+ <div class="p-1" [ngStyle]="{flex: flexAt(1)}"> </div>
+ <div class="p-1" [ngStyle]="{flex: flexAt(2)}"> </div>
<div class="p-1" [ngStyle]="{flex: flexAt(3)}">
<label class="font-weight-bold" i18n>Classification</label>
<div>
</ng-container>
</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"
- [ngClass]="{'text-danger': copyNode.target._dupe_barcode}"
- (ngModelChange)="barcodeChanged(copyNode.target, $event)"
- (keyup.enter)="selectNextBarcode(copyNode.target.id())"
- (keyup.shift.enter)="selectNextBarcode(copyNode.target.id(), true)"
- (focus)="$event.target.select()"
- [ngModel]="copyNode.target.barcode()"
- (ngModelChange)="applyCopyValue(copyNode.target, 'barcode', $event)"/>
- <div *ngIf="copyNode.target._dupe_barcode"
- class="alert alert-danger font-italic p-1" i18n>
- Duplicate Barcode</div>
+
+ <div class="d-flex">
+ <button class="clear-button" (click)="deleteCopy(copyNode)"
+ title="Delete Item" i18n-title>
+ <span class="material-icons">clear</span>
+ </button>
+
+ <input type="text" class="form-control form-control-sm"
+ id="barcode-input-{{copyNode.target.id()}}"
+ spellcheck="false"
+ [required]="true"
+ [ngClass]="{'text-danger': copyNode.target._dupe_barcode}"
+ (ngModelChange)="barcodeChanged(copyNode.target, $event)"
+ (keyup.enter)="selectNextBarcode(copyNode.target.id())"
+ (keyup.shift.enter)="selectNextBarcode(copyNode.target.id(), true)"
+ (focus)="$event.target.select()"
+ [ngModel]="copyNode.target.barcode()"
+ (ngModelChange)="applyCopyValue(copyNode.target, 'barcode', $event)"/>
+ <div *ngIf="copyNode.target._dupe_barcode"
+ class="alert alert-danger font-italic p-1" i18n>
+ Duplicate Barcode</div>
+ </div>
</div>
<div class="p-1" [ngStyle]="{flex: flexAt(9)}">
<input type="number" min="0" class="form-control form-control-sm"
@ViewChild('confirmDelVol', {static: false})
confirmDelVol: ConfirmDialogComponent;
+ @ViewChild('confirmDelCopy', {static: false})
+ confirmDelCopy: ConfirmDialogComponent;
+
constructor(
private renderer: Renderer2,
private idl: IdlService,
}
// Empty volumes get a stub copy
- addStubCopies() {
+ addStubCopies(volNode?: HoldingsTreeNode) {
+ const nodes = volNode ? [volNode] : this.context.volNodes();
- this.context.volNodes().forEach(volNode => {
+ nodes.forEach(volNode => {
if (volNode.children.length == 0) {
const vol = volNode.target;
const copy = this.createStubCopy(vol);
}
}
+ deleteCopy(copyNode: HoldingsTreeNode) {
+ this.deleteCopyCount = 1;
+ this.confirmDelCopy.open().toPromise().then(confirmed => {
+ if (confirmed) { this.deleteOneCopy(copyNode); }
+ });
+ }
+
+ deleteOneCopy(copyNode: HoldingsTreeNode) {
+
+ const targetCopy = copyNode.target;
+
+ const orgNodes = this.context.orgNodes();
+ for (let orgIdx = 0; orgIdx < orgNodes.length; orgIdx++) {
+ const orgNode = orgNodes[orgIdx];
+
+ for (let volIdx = 0; volIdx < orgNode.children.length; volIdx++) {
+ const volNode = orgNode.children[volIdx];
+
+ for (let copyIdx = 0; copyIdx < volNode.children.length; copyIdx++) {
+ const copy = volNode.children[copyIdx].target;
+
+ if (copy.id() === targetCopy.id()) {
+ volNode.children.splice(copyIdx, 1);
+ if (!copy.isnew()) {
+ copy.isdeleted(true);
+ this.copiesToDelete.push(copy);
+ }
+
+ if (volNode.children.length === 0) {
+ // When removing the last copy, add a stub copy.
+ this.addStubCopies();
+ }
+
+ return;
+ }
+ }
+ }
+ }
+ }
+
+
deleteVol(volNode: HoldingsTreeNode) {
this.deleteVolCount = 1;
this.deleteCopyCount = volNode.children.length;
});
}
- if (deleteVolIdx) { break; }
+ if (deleteVolIdx !== null) { break; }
}
if (deleteVolIdx !== null) {