From a3bae111c13dfbae6d8555db0356e277344b8a3b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 4 Jan 2019 11:07:31 -0500 Subject: [PATCH] LP1779158 Cache new queues / display active queues * Only list active (non-complete) queues in the Vandelay queue selector combobox. * Display an alert message when the user attempts to create a queue whose name collides with an existing queue for the user. * Be sure newly created queues are added to the local cache of queues in the Vandelay service. * Remove unused activeQueue list from vandelay.service to avoid having to maintain 2 separate queue caches. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- .../staff/cat/vandelay/import.component.html | 6 +++- .../staff/cat/vandelay/import.component.ts | 32 ++++++++++++------- .../staff/cat/vandelay/vandelay.service.ts | 31 +++--------------- 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html index a00b35fcff..5f7352f8b8 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html @@ -8,6 +8,10 @@ + + +

MARC File Upload

@@ -74,7 +78,7 @@
- q.complete() === 'f'); break; case 'matchSets': @@ -372,9 +377,6 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy { resolveQueue(): Promise { if (this.selectedQueue.freetext) { - /* - if (this.selectedQueue && this.selectedQueue.freetext) { - */ // Free text queue selector means create a new entry. // TODO: first check for name dupes @@ -384,15 +386,23 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy { this.selectedHoldingsProfile, this.selectedMatchSet, this.selectedBucket - ); + ).then( + id => id, + err => { + const evt = this.evt.parse(err); + if (evt) { + if (evt.textcode.match(/QUEUE_EXISTS/)) { + this.dupeQueueAlert.open(); + } else { + alert(evt); // server error + } + } + return Promise.reject('Queue Create Failed'); + } + ); } else { return Promise.resolve(this.selectedQueue.id); - /* - var queue_id = this.startQueueId; - if (this.selectedQueue) queue_id = this.selectedQueue.id; - return Promise.resolve(queue_id); - */ } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts index 45d1de556d..3f4a1973b9 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts @@ -1,4 +1,4 @@ -import {Injectable, EventEmitter} from '@angular/core'; +import {Injectable} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {tap} from 'rxjs/operators/tap'; import {map} from 'rxjs/operators/map'; @@ -32,7 +32,6 @@ export class VandelayImportSelection { export class VandelayService { allQueues: {[qtype: string]: IdlObject[]}; - activeQueues: {[qtype: string]: IdlObject[]}; attrDefs: {[atype: string]: IdlObject[]}; bibSources: IdlObject[]; bibBuckets: IdlObject[]; @@ -62,7 +61,6 @@ export class VandelayService { private perm: PermService ) { this.attrDefs = {}; - this.activeQueues = {}; this.allQueues = {}; this.matchSets = {}; this.importSelection = null; @@ -99,8 +97,6 @@ export class VandelayService { } // Returns a promise resolved with the list of queues. - // Also emits the onQueueListUpdate event so listeners - // can detect queue content changes. getAllQueues(qtype: string): Promise { if (this.allQueues[qtype]) { return Promise.resolve(this.allQueues[qtype]); @@ -118,27 +114,6 @@ export class VandelayService { )).toPromise().then(() => this.allQueues[qtype]); } - - // Returns a promise resolved with the list of queues. - // Also emits the onQueueListUpdate event so listeners - // can detect queue content changes. - getActiveQueues(qtype: string): Promise { - if (this.activeQueues[qtype]) { - return Promise.resolve(this.activeQueues[qtype]); - } else { - this.activeQueues[qtype] = []; - } - - // could be a big list, invoke in streaming mode - return this.net.request( - 'open-ils.vandelay', - `open-ils.vandelay.${qtype}_queue.owner.retrieve`, - this.auth.token(), null, {complete: 'f'} - ).pipe(tap( - queue => this.activeQueues[qtype].push(queue) - )).toPromise().then(() => this.activeQueues[qtype]); - } - getBibSources(): Promise { if (this.bibSources) { return Promise.resolve(this.bibSources); @@ -256,9 +231,11 @@ export class VandelayService { ).subscribe(queue => { const e = this.evt.parse(queue); if (e) { - alert(e); reject(e); } else { + // createQueue is always called after queues have + // been fetched and cached. + this.allQueues[qType].push(queue); resolve(queue.id()); } }); -- 2.43.2