From: Bill Erickson Date: Fri, 5 Jun 2020 15:30:13 +0000 (-0400) Subject: LPXXX Angular Volcopy X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=db924f5c01b224ce0d4a51acfc37eae9ba5356c1;p=working%2FEvergreen.git LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/routing.module.ts index 368c30a40b..fb4f44d7c5 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/routing.module.ts @@ -6,6 +6,12 @@ const routes: Routes = [{ path: 'edit/item/:copy_id', component: VolCopyComponent }, { + path: 'edit/callnumber/:vol_id', + component: VolCopyComponent + }, { + path: 'edit/record/:record_id', + component: VolCopyComponent + }, { path: 'edit/session/:session', component: VolCopyComponent /* 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 4ff4529942..115aaf3920 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 @@ -42,10 +42,10 @@
- {{orgNode.target.shortname()}} + {{orgNode.target.shortname()}}
- +
+ + + + @@ -135,6 +140,7 @@ [entryId]="part.id()" [entryLabel]="part.label()"> +
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 684b5a90cf..2d58cc76b2 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 @@ -82,6 +82,10 @@ export class VolEditComponent implements OnInit { ); } + recordHasParts(bibId: number): boolean { + return this.bibParts[bibId] && this.bibParts[bibId].length > 0; + } + flexAt(column: number): number { return this.flexSettings[column]; } 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 623075ffe1..cb4c8dcd35 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 @@ -1,12 +1,13 @@ import {Component, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {tap} from 'rxjs/operators'; 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 copy_FLESH = { +const COPY_FLESH = { flesh: 1, flesh_fields: { acp: ['call_number', 'location', 'parts'] @@ -23,7 +24,10 @@ export class VolCopyComponent implements OnInit { // Note in multi-record mode this value will be unset. recordId: number; - // Load the editor for a specific copy by ID. + // Load specific call number by ID. + volId: number; + + // Load specific copy by ID. copyId: number; session: string; @@ -47,15 +51,11 @@ export class VolCopyComponent implements OnInit { } negotiateRoute(params: ParamMap) { - const copyId = +params.get('copy_id'); - if (copyId) { - if (copyId !== this.copyId) { - this.copyId = copyId; - this.load(); - } - } else { - this.copyId = null; - } + this.recordId = +params.get('record_id') || null; + this.volId = +params.get('vol_id') || null; + this.copyId = +params.get('copy_id') || null; + this.session = params.get('session') || null; + this.load(); } load() { @@ -66,22 +66,58 @@ export class VolCopyComponent implements OnInit { .then(_ => this.holdings.fetchCallNumberPrefixes()) .then(_ => this.holdings.fetchCallNumberSuffixes()) .then(_ => this.context.sortHoldings()) + .then(_ => this.setRecordId()) .then(_ => this.loading = false); } + setRecordId() { + if (!this.recordId) { + this.recordId = this.context.getRecordId(); + } + } + fetchHoldings(): Promise { if (this.copyId) { - return this.fetchCopy(); + return this.fetchCopies(this.copyId); + } else if (this.volId) { + return this.fetchVols(this.volId); + } else if (this.recordId) { + return this.fetchRecords(this.recordId); } } - fetchCopy(): Promise { - return this.pcrud.retrieve('acp', this.copyId, copy_FLESH) - .toPromise().then(copy => { - this.recordId = copy.call_number().record(); - this.context.findOrCreateCopyNode(copy); - }); + fetchCopies(copyIds: number | number[]): Promise { + const ids = [].concat(copyIds); + return this.pcrud.search('acp', {id: ids}, COPY_FLESH) + .pipe(tap(copy => this.context.findOrCreateCopyNode(copy))) + .toPromise(); + } + + // Fetch call numbers and copies by call number ids. + fetchVols(volIds?: number | number[]): Promise { + const ids = [].concat(volIds); + + return this.pcrud.search('acn', {id: ids}) + .pipe(tap(vol => this.context.findOrCreateVolNode(vol))) + .pipe(tap(vol => { + return this.pcrud.search('acp', + {call_number: ids, deleted: 'f'}, COPY_FLESH + ).pipe(tap(copy => this.context.findOrCreateCopyNode(copy)) + ).toPromise(); + })).toPromise(); + } + + // Fetch call numbers and copies by record ids. + fetchRecords(recordIds: number | number[]): Promise { + const ids = [].concat(recordIds); + + return this.pcrud.search('acn', + {record: ids, deleted: 'f'}, + {}, {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 4d5f799740..0f1ad56638 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,6 +32,24 @@ 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; + this.orgNodes().forEach(orgNode => { + orgNode.children.forEach(volNode => { + if (id === null) { + id = volNode.target.record(); + } else if (id !== volNode.target.record()) { + nope = true; + } + }) + }); + + return nope ? null : id; + } + // Adds an org unit node; unsorted. findOrCreateOrgNode(orgId: number): HoldingsTreeNode { @@ -50,7 +68,7 @@ export class VolCopyContext { return node; } - findOrCreateCallNumNode(vol: IdlObject): HoldingsTreeNode { + findOrCreateVolNode(vol: IdlObject): HoldingsTreeNode { const orgId = vol.owning_lib(); const orgNode = this.findOrCreateOrgNode(orgId); @@ -72,7 +90,7 @@ export class VolCopyContext { findOrCreateCopyNode(copy: IdlObject): HoldingsTreeNode { - const volNode = this.findOrCreateCallNumNode(copy.call_number()); + const volNode = this.findOrCreateVolNode(copy.call_number()); const existing = volNode.children.filter( c => c.target.id() === copy.id())[0]; 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 b4f6e27221..6b42543382 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 @@ -89,7 +89,6 @@ export class HoldingsService { .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; }); }