From: Bill Erickson Date: Fri, 5 Jun 2020 16:30:10 +0000 (-0400) Subject: LPXXX Angular Volcopy X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=854923b0af63fc4fdc517109887a13a715a93978;p=working%2FEvergreen.git LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.css b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.css index bfbc3efa95..c109cac77e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.css +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.css @@ -1,4 +1,11 @@ input[type="number"] { - width: 5em; + /* visually accomodates numbers in the hundreds */ + width: 4.5em; +} + +.vol-row { + background-color: rgba(0,0,0,.03); + border-top: 1px solid rgba(0,0,0,.125); + border-bottom: 1px solid rgba(0,0,0,.125); } 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 115aaf3920..dbfcbea614 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 @@ -1,8 +1,64 @@ -
- BATCH +
+
+
+
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ +
+ +
+
+
+
+
+
@@ -40,7 +96,7 @@ -
+
{{orgNode.target.shortname()}}
@@ -58,7 +114,7 @@ [startId]="volNode.target.label_class()" [smallFormControl]="true" [required]="true" - (onChange)="applyVolValue(volNode.target, 'label_class', $event)"> + (onChange)="applyVolValue(volNode.target, 'label_class', $event ? $event.id : null)"> @@ -71,11 +127,7 @@ [startId]="volNode.target.prefix()" [required]="true" [smallFormControl]="true" - (onChange)="applyVolValue(volNode.target, 'prefix', $event)"> - - + (onChange)="applyVolValue(volNode.target, 'prefix', $event ? $event.id : null)"> @@ -96,11 +148,7 @@ [startId]="volNode.target.suffix()" [required]="true" [smallFormControl]="true" - (onChange)="applyVolValue(volNode.target, 'suffix', $event)"> - - + (onChange)="applyVolValue(volNode.target, 'suffix', $event ? $event.id : null)"> 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 2d58cc76b2..1a01e01b5c 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 @@ -2,6 +2,7 @@ import {Component, OnInit, AfterViewInit, ViewChild, Input, Renderer2} from '@an import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; +import {NetService} from '@eg/core/net.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {VolCopyContext, HoldingsTreeNode} from './volcopy'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; @@ -30,14 +31,22 @@ export class VolEditComponent implements OnInit { volSuffixes: IdlObject[] = null; bibParts: {[bibId: number]: IdlObject[]} = {}; + batchVolClass: number = null; + batchVolPrefix: number = null; + batchVolSuffix: number = null; + batchVolLabel: string = null; + recordVolLabels: string[] = []; + constructor( private pcrud: PcrudService, + private net: NetService, private holdings: HoldingsService ) {} ngOnInit() { - this.fetchBibParts(); + this.fetchRecordVolLabels() + .then(_ => this.fetchBibParts()); // TODO: Filter these to only show org-scoped values // plus any values otherwise needed for the current @@ -54,6 +63,26 @@ export class VolEditComponent implements OnInit { this.volSuffixes = suffixes.filter(pfx => pfx.id() !== -1)); } + fetchRecordVolLabels(): Promise { + // NOTE: see https://bugs.launchpad.net/evergreen/+bug/1874897 + // for more on MARC call numbers and classification scheme. + + this.recordVolLabels = []; + const ids = this.context.getRecordIds(); + + // It only makes sense to fetch bib call numbers when we are + // working with exactly one record. + if (ids.length !== 1) { return Promise.resolve(); } + + return this.net.request( + 'open-ils.cat', + 'open-ils.cat.biblio.record.marc_cn.retrieve', ids[0] + ).toPromise().then(res => { + this.recordVolLabels = Object.values(res) + .map(blob => Object.values(blob)[0]).sort(); + }); + } + fetchBibParts() { this.context.orgNodes().forEach(orgNode => { @@ -99,6 +128,12 @@ export class VolEditComponent implements OnInit { } applyVolValue(vol: IdlObject, key: string, value: any) { + + if (value === null && (key === 'prefix' || key === 'suffix')) { + // -1 is the empty prefix/suffix value. + value = -1; + } + if (vol[key]() !== value) { vol[key](value); vol.ischanged(true); @@ -115,5 +150,8 @@ export class VolEditComponent implements OnInit { copyPartChanged(copyNode: HoldingsTreeNode, entry: ComboboxEntry) { // TODO } + + batchVolApply() { + } } 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 cb4c8dcd35..8a5999e41b 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 @@ -72,7 +72,10 @@ export class VolCopyComponent implements OnInit { setRecordId() { if (!this.recordId) { - this.recordId = this.context.getRecordId(); + const ids = this.context.getRecordIds(); + if (ids.length === 1) { + this.recordId = ids[0]; + } } } 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 0f1ad56638..c73a6bdf14 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 @@ -32,22 +32,15 @@ export class VolCopyContext { return this.holdings.root.children; } - // If the holdings in question all link to a single bib - // record, return the ID of said record. Otherwise null. - getRecordId(): number { - let id = null; - let nope = false; + // Returns IDs for all bib records represented in our holdings tree. + getRecordIds(): number[] { + const idHash: {[id: number]: boolean} = {}; this.orgNodes().forEach(orgNode => { - orgNode.children.forEach(volNode => { - if (id === null) { - id = volNode.target.record(); - } else if (id !== volNode.target.record()) { - nope = true; - } - }) + orgNode.children.forEach( + volNode => idHash[volNode.target.record()] = true) }); - return nope ? null : id; + return Object.keys(idHash).map(id => Number(id)); } // Adds an org unit node; unsorted.