From 1b2e1b5c60cd3b236a1d9d787aa59a638c891ce2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 5 Jun 2020 17:49:31 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/vol-edit.component.html | 8 +- .../app/staff/cat/volcopy/vol-edit.component.ts | 87 +++++++++++++++++++++- .../src/app/staff/cat/volcopy/volcopy.component.ts | 3 +- .../src/eg2/src/app/staff/cat/volcopy/volcopy.ts | 17 ----- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index a5f42a555e..a8a74c722b 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -116,9 +116,9 @@ {{orgNode.target.shortname()}}
- + @@ -174,7 +174,7 @@
@@ -195,7 +195,7 @@ Duplicate Barcode
-
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index ecef3b5734..29692eb362 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit, AfterViewInit, ViewChild, Input, Renderer2} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {tap} from 'rxjs/operators'; -import {IdlObject} from '@eg/core/idl.service'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; import {AuthService} from '@eg/core/auth.service'; import {NetService} from '@eg/core/net.service'; @@ -43,8 +43,11 @@ export class VolEditComponent implements OnInit { autoBarcodeInProgress = false; useCheckdigit = false; + autoId = -1; + constructor( private renderer: Renderer2, + private idl: IdlService, private pcrud: PcrudService, private net: NetService, private auth: AuthService, @@ -54,7 +57,8 @@ export class VolEditComponent implements OnInit { ngOnInit() { this.fetchRecordVolLabels() - .then(_ => this.fetchBibParts()); + .then(_ => this.fetchBibParts()) + .then(_ => this.addStubCopies()); // TODO: Filter these to only show org-scoped values // plus any values otherwise needed for the current @@ -137,13 +141,90 @@ export class VolEditComponent implements OnInit { } volCountChanged(orgNode: HoldingsTreeNode, count: number) { - console.log('vol set set to ', count); + const diff = count - orgNode.children.length; + if (diff > 0) { + this.createVols(orgNode, diff); + } else if (diff < 0) { + this.deleteVols(orgNode, diff); + } + } + + createStubVol(orgId: number): IdlObject { + // Volume creation should only be available as an option when + // working with a specific call bib record. + const recId = +this.context.getRecordIds()[0]; + + const vol = this.idl.create('acn'); + vol.id(this.autoId--); + vol.isnew(true); + vol.record(recId); + vol.label(this.recordVolLabels[0] || ''); + vol.owning_lib(orgId); + + return vol; + } + + + createStubCopy(vol: IdlObject): IdlObject { + + const copy = this.idl.create('acp'); + copy.id(this.autoId--); + copy.isnew(true); + copy.circ_lib(vol.owning_lib()); + copy.call_number(vol.id()); + copy.deposit(0); + copy.price(0); + copy.deposit_amount(0); + copy.fine_level(2); // Normal + copy.loan_duration(2); // Normal + copy.location(1); // Stacks + copy.circulate('t'); + copy.holdable('t'); + copy.opac_visible('t'); + copy.ref('f'); + copy.mint_condition('t'); + + // TODO: status / fast-add / defaults? + + return copy; } copyCountChanged(volNode: HoldingsTreeNode, count: number) { console.log('vol set set to ', count); } + createVols(orgNode: HoldingsTreeNode, count: number) { + for (let i = 0; i < count; i++) { + + // This will vivify the volNode if needed. + const vol = this.createStubVol(orgNode.target.id()) + + // Our context assumes copies are fleshed with volumes + const copy = this.createStubCopy(vol); + copy.call_number(vol); + this.context.findOrCreateCopyNode(copy); + } + } + + + deleteVols(orgNode: HoldingsTreeNode, count: number) { + } + + + // Empty volumes get a stub copy + addStubCopies() { + + // TODO: timing issue -- all vols getting stubs + this.context.volNodes().forEach(volNode => { + if (volNode.children.length == 0) { + const vol = volNode.target; + const copy = this.createStubCopy(vol); + copy.call_number(vol); + this.context.findOrCreateCopyNode(copy); + } + }); + } + applyVolValue(vol: IdlObject, key: string, value: any) { if (value === null && (key === 'prefix' || key === 'suffix')) { diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts index 8a5999e41b..dd9173f86c 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts @@ -89,7 +89,6 @@ export class VolCopyComponent implements OnInit { } } - fetchCopies(copyIds: number | number[]): Promise { const ids = [].concat(copyIds); return this.pcrud.search('acp', {id: ids}, COPY_FLESH) @@ -116,7 +115,7 @@ export class VolCopyComponent implements OnInit { const ids = [].concat(recordIds); return this.pcrud.search('acn', - {record: ids, deleted: 'f'}, + {record: ids, deleted: 'f', label: {'!=' : '##URI##'}}, {}, {idlist: true, atomic: true} ).toPromise().then(volIds =>this.fetchVols(volIds)); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts index aa07966725..6a515d89e5 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts @@ -137,21 +137,4 @@ export class VolCopyContext { o1.target.shortname() < o2.target.shortname() ? -1 : 1); } - // Sorted list of holdings tree nodes - /* - flattenHoldings(): HoldingsTreeNode[] { - this.sortHoldings(); - let nodes: HoldingsTreeNode[] = []; - - this.orgNodes().forEach(orgNode => { - nodes.push(orgNode); - orgNode.children.forEach(volNode => { - nodes.push(volNode); - nodes = nodes.concat(volNode.children); - }); - }); - - return nodes; - } - */ } -- 2.11.0