From 21e9f9ec79cf07d342ff2b2a87f4320d2cecb9a3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 4 Jun 2020 16:18:31 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../eg2/src/app/share/catalog/catalog.service.ts | 2 +- .../src/app/share/combobox/combobox.component.html | 5 +- .../src/app/share/combobox/combobox.component.ts | 3 + .../src/app/staff/cat/volcopy/routing.module.ts | 2 +- .../app/staff/cat/volcopy/vol-edit.component.html | 93 ++++++++++++++++++++++ .../app/staff/cat/volcopy/vol-edit.component.ts | 82 +++++++++++++++++++ .../app/staff/cat/volcopy/volcopy.component.html | 11 ++- .../src/app/staff/cat/volcopy/volcopy.component.ts | 38 +++++---- .../src/app/staff/cat/volcopy/volcopy.module.ts | 4 +- .../src/eg2/src/app/staff/cat/volcopy/volcopy.ts | 55 ++++++++----- .../share/bib-summary/bib-summary.component.ts | 28 +++---- .../app/staff/share/holdings/holdings.service.ts | 52 ++++++++++++ 12 files changed, 322 insertions(+), 53 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index c80d0b2683..39126c2c42 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -361,7 +361,7 @@ export class CatalogService { } iconFormatLabel(code: string): string { - if (this.ccvmMap) { + if (this.ccvmMap && this.ccvmMap.icon_format) { const ccvm = this.ccvmMap.icon_format.filter( format => format.code() === code)[0]; if (ccvm) { diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html index 83df22e20a..c456f80043 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html @@ -7,7 +7,10 @@
+ BATCH +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + + +
+
+ {{orgNode.target.shortname()}} +
+
+ + + +
+
+ + + + +
+
+ + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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 new file mode 100644 index 0000000000..a39f5f43e9 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -0,0 +1,82 @@ +import {Component, OnInit, AfterViewInit, ViewChild, Input, Renderer2} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {IdlObject} from '@eg/core/idl.service'; +import {OrgService} from '@eg/core/org.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {VolCopyContext, HoldingsTreeNode} from './volcopy'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; +import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; + +@Component({ + selector: 'eg-vol-edit', + templateUrl: 'vol-edit.component.html' +}) + + +export class VolEditComponent implements OnInit { + + @Input() context: VolCopyContext; + + // There are 10 columns in the editor form. Set the flex values + // here so they don't have to be hard-coded and repeated in the + // markup. Changing a flex value here will propagate to all + // rows in the form. + flexSettings: {[column: number]: number} = { + 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: 1, 8: 2, 9: 1, 10: 1}; + + volClasses: IdlObject[] = null; + volPrefixes: IdlObject[] = null; + volSuffixes: IdlObject[] = null; + + constructor( + private holdings: HoldingsService + ) {} + + ngOnInit() { + + // TODO: Filter these to only show org-scoped values + // plus any values otherwise needed for the current + // holdings tree. + + this.holdings.fetchCallNumberClasses().then( + classes => this.volClasses = classes); + + this.holdings.fetchCallNumberPrefixes().then(prefixes => { + this.volPrefixes = prefixes.filter(pfx => pfx.id() !== -1) + }); + + this.holdings.fetchCallNumberSuffixes().then(suffixes => + this.volSuffixes = suffixes.filter(pfx => pfx.id() !== -1)); + } + + flexAt(column: number): number { + return this.flexSettings[column]; + } + + volCountChanged(orgNode: HoldingsTreeNode, value: number) { + console.log('vol set set to ', value); + } + + applyVolValue(vol: IdlObject, key: string, value: any) { + if (vol[key]() !== value) { + vol[key](value); + vol.ischanged(true); + } + } + + volClassChanged(volNode: HoldingsTreeNode, entry: ComboboxEntry) { + if (!entry) { return; } + this.applyVolValue(volNode.target, 'label_class', entry.id); + } + + volPrefixChanged(volNode: HoldingsTreeNode, entry: ComboboxEntry) { + if (!entry) { return; } + this.applyVolValue(volNode.target, 'prefix', entry.id); + } + + volSuffixChanged(volNode: HoldingsTreeNode, entry: ComboboxEntry) { + if (!entry) { return; } + this.applyVolValue(volNode.target, 'suffix', entry.id); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html index 0945cf3379..df54f573a7 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html @@ -1,2 +1,11 @@ + -VOLCOPY + + + + +
+ +
+ +
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 36c2b67477..696406b0c6 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 @@ -3,9 +3,10 @@ import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; import {VolCopyContext} from './volcopy'; -const ITEM_FLESH = { +const copy_FLESH = { flesh: 1, flesh_fields: { acp: ['call_number', 'location'] @@ -18,16 +19,18 @@ const ITEM_FLESH = { export class VolCopyComponent implements OnInit { context: VolCopyContext; - itemId: number; + recordId: number; + copyId: number; session: string; - loading = false; + loading = true; constructor( private router: Router, private route: ActivatedRoute, private renderer: Renderer2, private org: OrgService, - private pcrud: PcrudService + private pcrud: PcrudService, + private holdings: HoldingsService ) { } ngOnInit() { @@ -39,14 +42,14 @@ export class VolCopyComponent implements OnInit { } negotiateRoute(params: ParamMap) { - const itemId = +params.get('item_id'); - if (itemId) { - if (itemId !== this.itemId) { - this.itemId = itemId; + const copyId = +params.get('copy_id'); + if (copyId) { + if (copyId !== this.copyId) { + this.copyId = copyId; this.load(); } } else { - this.itemId = null; + this.copyId = null; } } @@ -54,19 +57,24 @@ export class VolCopyComponent implements OnInit { this.loading = true; this.context.reset(); this.fetchHoldings() + .then(_ => this.holdings.fetchCallNumberClasses()) + .then(_ => this.holdings.fetchCallNumberPrefixes()) + .then(_ => this.holdings.fetchCallNumberSuffixes()) + .then(_ => this.context.sortHoldings()) .then(_ => this.loading = false); } fetchHoldings(): Promise { - if (this.itemId) { - return this.fetchItem(); + if (this.copyId) { + return this.fetchCopy(); } } - fetchItem(): Promise { - return this.pcrud.retrieve('acp', this.itemId, ITEM_FLESH) - .toPromise().then(item => { - this.context.findOrCreateItemNode(item); + fetchCopy(): Promise { + return this.pcrud.retrieve('acp', this.copyId, copy_FLESH) + .toPromise().then(copy => { + this.recordId = copy.call_number().record(); + this.context.findOrCreateCopyNode(copy); }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.module.ts index 3e31b8ad40..cdd9e19d16 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.module.ts @@ -4,10 +4,12 @@ import {CommonWidgetsModule} from '@eg/share/common-widgets.module'; import {HoldingsModule} from '@eg/staff/share/holdings/holdings.module'; import {VolCopyRoutingModule} from './routing.module'; import {VolCopyComponent} from './volcopy.component'; +import {VolEditComponent} from './vol-edit.component'; @NgModule({ declarations: [ - VolCopyComponent + VolCopyComponent, + VolEditComponent ], imports: [ StaffCommonModule, 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 5824d1da42..4d5f799740 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 @@ -1,9 +1,9 @@ import {IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; -class HoldingsTreeNode { +export class HoldingsTreeNode { children: HoldingsTreeNode[]; - nodeType: 'org' | 'callNum' | 'item'; + nodeType: 'org' | 'vol' | 'copy'; target: any; parentNode: HoldingsTreeNode; constructor() { @@ -50,18 +50,18 @@ export class VolCopyContext { return node; } - findOrCreateCallNumNode(callNum: IdlObject): HoldingsTreeNode { - const orgId = callNum.owning_lib(); + findOrCreateCallNumNode(vol: IdlObject): HoldingsTreeNode { + const orgId = vol.owning_lib(); const orgNode = this.findOrCreateOrgNode(orgId); const existing = orgNode.children.filter( - n => n.target.id() === callNum.id())[0]; + n => n.target.id() === vol.id())[0]; if (existing) { return existing; } const node: HoldingsTreeNode = new HoldingsTreeNode(); - node.nodeType = 'callNum'; - node.target = callNum; + node.nodeType = 'vol'; + node.target = vol; node.parentNode = orgNode; orgNode.children.push(node); @@ -70,21 +70,21 @@ export class VolCopyContext { } - findOrCreateItemNode(item: IdlObject): HoldingsTreeNode { + findOrCreateCopyNode(copy: IdlObject): HoldingsTreeNode { - const callNumNode = this.findOrCreateCallNumNode(item.call_number()); + const volNode = this.findOrCreateCallNumNode(copy.call_number()); - const existing = callNumNode.children.filter( - c => c.target.id() === item.id())[0]; + const existing = volNode.children.filter( + c => c.target.id() === copy.id())[0]; if (existing) { return existing; } const node: HoldingsTreeNode = new HoldingsTreeNode(); - node.nodeType = 'item'; - node.target = item. - node.parentNode = callNumNode; + node.nodeType = 'copy'; + node.target = copy; + node.parentNode = volNode; - callNumNode.children.push(node); + volNode.children.push(node); return node; } @@ -93,10 +93,10 @@ export class VolCopyContext { sortHoldings() { this.orgNodes().forEach(orgNode => { - orgNode.children.forEach(callNumNode => { + orgNode.children.forEach(volNode => { - // Sort items by barcode code - callNumNode.children = callNumNode.children.sort((c1, c2) => + // Sort copys by barcode code + volNode.children = volNode.children.sort((c1, c2) => c1.target.barcode() < c2.target.barcode() ? -1 : 1); }); @@ -106,9 +106,26 @@ export class VolCopyContext { c1.target.label() < c2.target.label() ? -1 : 1); }); - // sort org units by shortname this.holdings.root.children = this.orgNodes().sort((o1, o2) => 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; + } + */ } diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts index 39b8944d3a..4b1a4b830b 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts @@ -45,30 +45,30 @@ export class BibSummaryComponent implements OnInit { ngOnInit() { - if (this.summary) { - this.summary.getBibCallNumber(); - } else { - if (this.recordId) { - this.loadSummary(); - } - } - this.store.getItem('eg.cat.record.summary.collapse') .then(value => this.expand = !value) - .then(() => this.initDone = true); + .then(_ => this.cat.fetchCcvms()) + .then(_ => { + if (this.summary) { + return this.summary.getBibCallNumber(); + } else { + if (this.recordId) { + return this.loadSummary(); + } + } + }).then(_ => this.initDone = true); } saveExpandState() { this.store.setItem('eg.cat.record.summary.collapse', !this.expand); } - loadSummary(): void { - this.bib.getBibSummary(this.recordId).toPromise() + loadSummary(): Promise { + return this.bib.getBibSummary(this.recordId).toPromise() .then(summary => { - summary.getBibCallNumber(); - this.bib.fleshBibUsers([summary.record]); this.summary = summary; - }); + return summary.getBibCallNumber(); + }).then(_ => this.bib.fleshBibUsers([this.summary.record])); } orgName(orgId: number): string { diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts index 5c91a68474..7597020caf 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts @@ -2,10 +2,12 @@ * Common code for mananging holdings */ import {Injectable, EventEmitter} from '@angular/core'; +import {IdlObject, IdlService} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {AnonCacheService} from '@eg/share/util/anon-cache.service'; import {AuthService} from '@eg/core/auth.service'; import {EventService} from '@eg/core/event.service'; +import {PcrudService} from '@eg/core/pcrud.service'; interface NewCallNumData { owner?: number; @@ -17,9 +19,14 @@ interface NewCallNumData { @Injectable() export class HoldingsService { + callNumberClasses: IdlObject[]; + callNumberPrefixes: IdlObject[]; + callNumberSuffixes: IdlObject[]; + constructor( private net: NetService, private auth: AuthService, + private pcrud: PcrudService, private evt: EventService, private anonCache: AnonCacheService ) {} @@ -57,5 +64,50 @@ export class HoldingsService { }); }); } + + // Returns a sorted list of call number classes + fetchCallNumberClasses(): Promise { + if (this.callNumberClasses) { + return Promise.resolve(this.callNumberClasses); + } + + return this.pcrud.retrieveAll('acnc', {}, {atomic: true}) + .toPromise().then(classes => { + this.callNumberClasses = classes.sort( + (c1, c2) => c1.name() < c2.name() ? -1 : 1); + return this.callNumberClasses; + }); + } + + // Returns a sorted list of call number prefixes + fetchCallNumberPrefixes(): Promise { + if (this.callNumberPrefixes) { + console.log('H2', this.callNumberPrefixes); + return Promise.resolve(this.callNumberPrefixes); + } + + return this.pcrud.retrieveAll('acnp', {}, {atomic: true}) + .toPromise().then(prefixes => { + this.callNumberPrefixes = prefixes.sort( + (c1, c2) => c1.label_sortkey() < c2.label_sortkey() ? -1 : 1); + console.log('H1', this.callNumberPrefixes); + return this.callNumberPrefixes; + }); + } + + // Returns a sorted list of call number suffixes + fetchCallNumberSuffixes(): Promise { + if (this.callNumberSuffixes) { + return Promise.resolve(this.callNumberSuffixes); + } + + return this.pcrud.retrieveAll('acns', {}, {atomic: true}) + .toPromise().then(suffixes => { + this.callNumberSuffixes = suffixes.sort( + (c1, c2) => c1.label_sortkey() < c2.label_sortkey() ? -1 : 1); + return this.callNumberSuffixes; + }); + } + } -- 2.11.0