From: Bill Erickson <berickxx@gmail.com> Date: Fri, 4 Jan 2019 16:07:31 +0000 (-0500) Subject: LP1779158 Cache new queues / display active queues X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a3bae111c13dfbae6d8555db0356e277344b8a3b;p=evergreen%2Fjoelewis.git 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 <berickxx@gmail.com> Signed-off-by: Dan Wells <dbw2@calvin.edu> --- 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 @@ </div> </div> +<eg-alert-dialog #dupeQueueAlert i18n-dialogBody + dialogBody="A queue with the requested name already exists."> +</eg-alert-dialog> + <h2 i18n>MARC File Upload</h2> <div class="common-form striped-odd form-validated ml-3 mr-3"> <div class="row"> @@ -74,7 +78,7 @@ <label for="queue-select" i18n>Select or Create a Queue</label> </div> <div class="col-lg-3"> - <eg-combobox [entries]="formatEntries('allQueues')" + <eg-combobox [entries]="formatEntries('activeQueues')" id="queue-select" [startId]="startQueueId" [startIdFiresOnChange]="true" diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts index 185d88bd67..e9eb3f8e17 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts @@ -13,6 +13,7 @@ import {VandelayService, VandelayImportSelection, import {HttpClient, HttpRequest, HttpEventType} from '@angular/common/http'; import {HttpResponse, HttpErrorResponse} from '@angular/common/http'; import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {Subject} from 'rxjs/Subject'; import {ServerStoreService} from '@eg/core/server-store.service'; @@ -126,6 +127,9 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild('fallThruMergeProfileSelector') private fallThruMergeProfileSelector: ComboboxComponent; + @ViewChild('dupeQueueAlert') + private dupeQueueAlert: AlertDialogComponent; + constructor( private http: HttpClient, private toast: ToastService, @@ -248,8 +252,9 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy { list = this.vandelay.bibBuckets; break; - case 'allQueues': - list = this.vandelay.allQueues[rtype]; + case 'activeQueues': + list = (this.vandelay.allQueues[rtype] || []) + .filter(q => q.complete() === 'f'); break; case 'matchSets': @@ -372,9 +377,6 @@ export class ImportComponent implements OnInit, AfterViewInit, OnDestroy { resolveQueue(): Promise<number> { 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<IdlObject[]> { 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<IdlObject[]> { - 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<IdlObject[]> { 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()); } });