From 5b856b4ca6dc91f710d52b5f74da1e56112f5337 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 16 Jun 2020 12:35:54 -0400 Subject: [PATCH] LPXXX Angular accesskey sort repair Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/vol-edit.component.html | 6 ++++ .../app/staff/cat/volcopy/vol-edit.component.ts | 28 ++++++++++----- .../app/staff/cat/volcopy/volcopy.component.html | 8 ++++- .../src/app/staff/cat/volcopy/volcopy.component.ts | 40 ++++++++++++++++------ .../src/app/staff/cat/volcopy/volcopy.service.ts | 12 ++++--- 5 files changed, 69 insertions(+), 25 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 673c9c7759..b7e96d31f9 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 @@ -164,6 +164,9 @@ [required]="true" [smallFormControl]="true" (onChange)="applyVolValue(volNode.target, 'prefix', $event ? $event.id : null)"> + + @@ -186,6 +189,9 @@ [required]="true" [smallFormControl]="true" (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 20abe09816..3f927670c6 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 @@ -59,6 +59,7 @@ export class VolEditComponent implements OnInit { constructor( private renderer: Renderer2, private idl: IdlService, + private org: OrgService, private pcrud: PcrudService, private net: NetService, private auth: AuthService, @@ -76,19 +77,23 @@ export class VolEditComponent implements OnInit { .then(_ => this.fetchBibParts()) .then(_ => this.addStubCopies()); - // 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) - }); + const myOrgs = this.org.fullPath(this.auth.user().ws_ou(), true); + + // The batch edit controls only include values for "here" + this.holdings.fetchCallNumberPrefixes().then(prefixes => + this.volPrefixes = prefixes + .filter(sfx => sfx.id() !== -1) + .filter(pfx => myOrgs.includes(pfx.owning_lib())) + ); this.holdings.fetchCallNumberSuffixes().then(suffixes => - this.volSuffixes = suffixes.filter(pfx => pfx.id() !== -1)); + this.volSuffixes = suffixes + .filter(sfx => sfx.id() !== -1) + .filter(sfx => myOrgs.includes(sfx.owning_lib())) + ); } @@ -191,17 +196,22 @@ export class VolEditComponent implements OnInit { createVols(orgNode: HoldingsTreeNode, count: number) { + const vols = []; for (let i = 0; i < count; i++) { // This will vivify the volNode if needed. const vol = this.volcopy.createStubVol( this.context.recordId, orgNode.target.id()) + vols.push(vol); + // Our context assumes copies are fleshed with volumes const copy = this.volcopy.createStubCopy(vol); copy.call_number(vol); this.context.findOrCreateCopyNode(copy); } + + this.volcopy.setVolClassLabels(vols); } // This only removes vols that were created during the @@ -217,7 +227,7 @@ export class VolEditComponent implements OnInit { } } - // Empty volumes get a stub copy + // When editing existing vols, be sure each has at least one copy. addStubCopies(volNode?: HoldingsTreeNode) { const nodes = volNode ? [volNode] : this.context.volNodes(); 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 2f569ea94c..7eec4801c7 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 @@ -6,7 +6,13 @@ - +
+
+ Holdings Editor Session Expired +
+
+ + 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 cddbfc9416..f71f6da57b 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 @@ -42,6 +42,7 @@ export class VolCopyComponent implements OnInit { context: VolCopyContext; loading = true; + sessionExpired = false; @ViewChild('loadingProgress', {static: false}) loadingProgress: ProgressInlineComponent; @@ -77,12 +78,13 @@ export class VolCopyComponent implements OnInit { this.load(); } - load() { + load(copyIds?: number[]) { + this.sessionExpired = false; this.loading = true; this.context.reset(); - this.fetchHoldings() + this.fetchHoldings(copyIds) .then(_ => this.volcopy.applyVolLabels( this.context.volNodes().map(n => n.target))) .then(_ => this.holdings.fetchCallNumberClasses()) @@ -93,9 +95,13 @@ export class VolCopyComponent implements OnInit { .then(_ => this.loading = false); } - fetchHoldings(): Promise { + fetchHoldings(copyIds?: number[]): Promise { - if (this.context.session) { + if (copyIds && copyIds.length > 0) { + // Reloading copies that were just edited. + return this.fetchCopies(copyIds); + + } else if (this.context.session) { this.context.sessionType = 'mixed'; return this.fetchSession(this.context.session); @@ -118,7 +124,11 @@ export class VolCopyComponent implements OnInit { return this.cache.getItem(session, 'edit-these-copies') .then((editSession: EditSession) => { - if (!editSession) { return; } + if (!editSession) { + this.loading = false; + this.sessionExpired = true; + return Promise.reject('Session Expired'); + } this.context.recordId = editSession.record_id; this.context.hideVols = editSession.hide_vols === true; @@ -203,7 +213,6 @@ export class VolCopyComponent implements OnInit { return this.volcopy.setCopyStatus(copies, this.context.fastAdd); } - fetchCopies(copyIds: number | number[]): Promise { const ids = [].concat(copyIds); return this.pcrud.search('acp', {id: ids}, COPY_FLESH) @@ -309,12 +318,12 @@ export class VolCopyComponent implements OnInit { let method = 'open-ils.cat.asset.volume.fleshed.batch.update'; if (override) { method += '.override'; } - this.net.request('open-ils.cat', method, this.auth.token(), - volumes, 1, {auto_merge_vols: 1, create_parts: 1}).toPromise() + this.net.request('open-ils.cat', method, this.auth.token(), volumes, true, + {auto_merge_vols: true, create_parts: true, return_copy_ids: true}) - .then(resp => { + .toPromise().then(copyIds => { - const evt = this.evt.parse(resp); + const evt = this.evt.parse(copyIds); // TODO: confirm / handle overrides @@ -323,7 +332,16 @@ export class VolCopyComponent implements OnInit { return; } - return this.load(); + // In addition to the copies edited in this update call, + // reload any other copies that were previously loaded. + + const ids: any = {}; // dedupe + this.context.copyList() + .map(c => c.id()) + .concat(copyIds) + .forEach(id => ids[id] = true); + + return this.load(Object.keys(ids).map(id => Number(id))); }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts index 21d5302b5b..8bde618f12 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts @@ -42,7 +42,8 @@ export class VolCopyService { }); } - createStubVol(recordId: number, orgId: number): IdlObject { + createStubVol(recordId: number, orgId: number, options?: any): IdlObject { + if (!options) { options = {}; } const vol = this.idl.create('acn'); vol.id(this.autoId--); @@ -51,6 +52,9 @@ export class VolCopyService { vol.label(null); vol.owning_lib(Number(orgId)); + vol.prefix(options.prefix || -1); + vol.suffix(options.suffix || -1); + return vol; } @@ -95,11 +99,11 @@ export class VolCopyService { // apply it here and bypass the network call. const volsWantLabels = []; - Object.keys(orgIds).forEach(orgId => { + Object.keys(orgIds).map(orgId => Number(orgId)).forEach(orgId => { promise = promise.then(_ => { return this.org.settings( - 'cat.default_classification_scheme', Number(orgId)) + 'cat.default_classification_scheme', orgId) .then(sets => { const orgVols = vols.filter(v => v.owning_lib() === orgId); @@ -113,7 +117,7 @@ export class VolCopyService { }); }); - return promise; + return promise.then(_ => this.applyVolLabels(volsWantLabels)); } // Apply labels to volumes based on the appropriate MARC call number. -- 2.11.0