autoId = -1;
- volsToDelete: IdlObject[] = [];
- copiesToDelete: IdlObject[] = [];
deleteVolCount: number = null;
deleteCopyCount: number = null;
ngOnInit() {
- this.volsToDelete = [];
- this.copiesToDelete = [];
this.deleteVolCount = null;
this.deleteCopyCount = null;
volNode.children.splice(copyIdx, 1);
if (!copy.isnew()) {
copy.isdeleted(true);
- this.copiesToDelete.push(copy);
+ this.context.copiesToDelete.push(copy);
}
if (volNode.children.length === 0) {
// Mark volume and attached copies as deleted
// and track for later deletion.
targetVol.isdeleted(true);
- this.volsToDelete.push(targetVol);
+ this.context.volsToDelete.push(targetVol);
volNode.children.forEach(copyNode => {
const copy = copyNode.target;
// New copies can simply be discarded.
} else {
copy.isdeleted(true);
- this.copiesToDelete.push(copy);
+ this.context.copiesToDelete.push(copy);
}
});
}
volNode.children.forEach(copyNode => {
const copy = copyNode.target;
+ if (copy.isnew() && !copy.barcode()) {
+ // A new copy w/ no barcode is a stub copy sitting
+ // on an empty call number. Ignore it.
+ return;
+ }
+
if (copy.ischanged() || copy.isnew() || copy.isdeleted()) {
const copyClone = this.idl.clone(copy);
// De-flesh call number
}
});
- // TODO: deletedVols and deletedCopies
+ this.context.volsToDelete.forEach(vol => {
+ const cloneVol = this.idl.clone(vol);
+ // If a deleted volume also has deleted copies, they will
+ // be appended below.
+ cloneVol.copies([]);
+ volumes.push(cloneVol);
+ });
+
+ this.context.copiesToDelete.forEach(copy => {
+ const cloneCopy = this.idl.clone(copy);
+ const copyVol = cloneCopy.call_number();
+ cloneCopy.call_number(copyVol.id()); // de-flesh
+
+ let vol = volumes.filter(v => v.id() === copyVol.id())[0];
+
+ if (vol) {
+ vol.copies().push(cloneCopy);
+ } else {
+ vol = this.idl.clone(copyVol);
+ vol.copies([cloneCopy]);
+ }
+
+ volumes.push(vol);
+ })
if (volumes.length > 0) {
this.saveApi(volumes);
+ } else {
+ this.loading = false;
}
}
holdings: HoldingsTree = new HoldingsTree();
org: OrgService; // injected
+ volsToDelete: IdlObject[] = [];
+ copiesToDelete: IdlObject[] = [];
+
reset() {
this.holdings = new HoldingsTree();
+ this.volsToDelete = [];
+ this.copiesToDelete = [];
}
orgNodes(): HoldingsTreeNode[] {