</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">
<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"
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';
@ViewChild('fallThruMergeProfileSelector')
private fallThruMergeProfileSelector: ComboboxComponent;
+ @ViewChild('dupeQueueAlert')
+ private dupeQueueAlert: AlertDialogComponent;
+
constructor(
private http: HttpClient,
private toast: ToastService,
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':
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
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);
- */
}
}
-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';
export class VandelayService {
allQueues: {[qtype: string]: IdlObject[]};
- activeQueues: {[qtype: string]: IdlObject[]};
attrDefs: {[atype: string]: IdlObject[]};
bibSources: IdlObject[];
bibBuckets: IdlObject[];
private perm: PermService
) {
this.attrDefs = {};
- this.activeQueues = {};
this.allQueues = {};
this.matchSets = {};
this.importSelection = null;
}
// 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]);
)).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);
).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());
}
});