<label class="font-weight-bold" i18n>Record Type</label>
</div>
<div class="col-lg-3">
- <select class="form-control" [(ngModel)]="recordType"
- (change)="recordTypeChanged($event)">
+ <select class="form-control" [(ngModel)]="recordType">
<option value='bib' i18n>Bibliographic Records</option>
<option value='auth' i18n>Authority Records</option>
<option value='bib-acq' i18n>Acquisitions Records</option>
</div>
</div>
<div class="row">
- <div class="col-lg-3">
+ <div class="col-lg-3 pb-2">
<label class="font-weight-bold" i18n>Create a New Upload Queue</label>
</div>
<div class="col-lg-3">
<label class="font-weight-bold" i18n>or Add to an Existing Queue</label>
</div>
<div class="col-lg-3">
- <eg-typeahead [entries]="queueEntries"></eg-typeahead>
+ <eg-typeahead [entries]="formatEntries('activeQueues')"></eg-typeahead>
+ </div>
+ </div>
+ <div class="row pb-2">
+ <div class="col-lg-3">
+ <label class="font-weight-bold" i18n>Record Match Set</label>
+ </div>
+ <div class="col-lg-3">
+ <eg-typeahead [entries]="formatEntries('matchSets')"></eg-typeahead>
+ </div>
+ </div>
+ <div class="row pb-2">
+ <div class="col-lg-3">
+ <label class="font-weight-bold" i18n>Holdings Import Profile</label>
+ </div>
+ <div class="col-lg-3"> <!-- TODO disable for authority -->
+ <eg-typeahead [entries]="formatEntries('importItemDefs')"></eg-typeahead>
+ </div>
+ </div>
+ <div class="row pb-2">
+ <div class="col-lg-3">
+ <label class="font-weight-bold" i18n>Select a Record Source</label>
+ </div>
+ <div class="col-lg-3">
+ <eg-typeahead [entries]="formatEntries('bibSources')"></eg-typeahead>
</div>
</div>
</div>
recordType: string;
newQueueName: string;
- queueEntries: TypeaheadEntry[];
allQueues: {[qtype: string]: IdlObject[]};
activeQueues: {[qtype: string]: IdlObject[]};
attrDefs: {[atype: string]: IdlObject[]};
bibSources: IdlObject[];
bibBuckets: IdlObject[];
+ itemImportAttrDefs: IdlObject[];
matchSets: {[stype: string]: IdlObject[]};
defaultMatchSet: string;
+ matchSetEntries: TypeaheadEntry[];
+ importItemDefEntries: TypeaheadEntry[];
+
@ViewChild('progressDialog')
private progressDialog: ProgressDialogComponent;
private vandelay: VandelayService
) {
this.recordType = 'bib';
- this.queueEntries = [];
this.attrDefs = {};
this.matchSets = {};
this.activeQueues = {};
ngAfterViewInit() {
// loading startup data changes our data in the midst of a
// lifecycle hook. Run after timeout.
- setTimeout(() => this.loadStartupData());
- }
-
- // Display record-typ appropriate data when the record type changes
- recordTypeChanged($event) {
- //this.formatQueueSelector();
+ //setTimeout(() => this.loadStartupData());
+ this.loadStartupData();
}
- loadStartupData() {
- this.progressDialog.open();
+ loadStartupData(): Promise<any>{
+ // Note displaying and manipulating a progress dialog inside
+ // the AfterViewInit cycle leads to errors because the child
+ // component is modifed after dirty checking.
const promises = [
this.vandelay.getAttrDefs('bib')
this.vandelay.getAttrDefs('auth')
.then(defs => this.attrDefs.auth = defs),
this.vandelay.getActiveQueues('bib')
- .then(queues => {
- this.activeQueues.bib = queues;
- this.formatQueueSelector();
- }),
+ .then(queues => this.activeQueues.bib = queues),
this.vandelay.getActiveQueues('auth')
.then(queues => this.activeQueues.auth = queues),
- this.vandelay.getMatchSets()
- .then(sets => this.matchSets = sets),
+ this.vandelay.getMatchSets('bib')
+ .then(sets => this.matchSets.bib = sets),
+ this.vandelay.getMatchSets('auth')
+ .then(sets => this.matchSets.auth= sets),
this.vandelay.getBibBuckets()
.then(bkts => this.bibBuckets = bkts),
this.vandelay.getBibSources()
.then(srcs => this.bibSources = srcs),
+ this.vandelay.getItemImportDefs()
+ .then(defs => this.itemImportAttrDefs = defs),
this.org.settings(['vandelay.default_match_set']).then(
s => this.defaultMatchSet = s['vandelay.default_match_set'])
];
- this.progressDialog.update({value: 0, max: promises.length});
- promises.forEach(p => p.then(() => this.progressDialog.increment()));
- Promise.all(promises).then(() => this.progressDialog.close());
+ return Promise.all(promises);
}
- formatQueueSelector() {
- const queues = this.activeQueues[this.recordType];
- this.queueEntries = queues.map(q => {
- return {id: q.id(), label: q.name()};
- });
+ // Format typeahead data sets
+ formatEntries(etype: string): TypeaheadEntry[] {
+ const rtype = this.recordType;
+
+ switch (etype) {
+ case 'bibSources':
+ return (this.bibSources || []).map(s => {
+ return {id: s.id(), label: s.source()};
+ });
+
+ case 'activeQueues':
+ return (this.activeQueues[rtype] || []).map(q => {
+ return {id: q.id(), label: q.name()};
+ });
+
+ case 'matchSets':
+ return (this.matchSets[rtype] || []).map(s => {
+ return {id: s.id(), label: s.name()};
+ });
+
+ case 'importItemDefs':
+ return (this.itemImportAttrDefs || []).map(d => {
+ return {id: d.id(), label: d.name()};
+ });
+ }
}
}
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
- const queues = [];
const qt = (qtype === 'bib') ? qtype : 'authority';
return this.net.request(
'open-ils.vandelay',
`open-ils.vandelay.${qt}_queue.owner.retrieve`,
this.auth.token(), null, {complete: 'f'}
).pipe(tap(
- queue => {
- if (!this.activeQueues[qtype]) {
- this.activeQueues[qtype] = [];
- }
- this.activeQueues[qtype].push(queue);
- }
- )).toPromise().then(() => queues);
+ queue => this.activeQueues[qtype].push(queue)
+ )).toPromise().then(() => this.activeQueues[qtype]);
}
getBibSources(): Promise<IdlObject[]> {
}
const owners = this.org.ancestors(this.auth.user().ws_ou(), true);
- return this.pcrud.search('viiad', {owner: owners}, {atomic: true})
+ return this.pcrud.search('viiad', {owner: owners}, {}, {atomic: true})
.toPromise().then(defs => {
this.importItemAttrDefs = defs;
return defs;
});
}
- getMatchSets(): Promise<{[mtype:string]: IdlObject[]}> {
- if (this.matchSets) {
- return Promise.resolve(this.matchSets);
+ // todo: differentiate between biblio and authority a la queue api
+ getMatchSets(mtype: string): Promise<IdlObject[]> {
+ if (this.matchSets[mtype]) {
+ return Promise.resolve(this.matchSets[mtype]);
+ } else {
+ this.matchSets[mtype] = [];
}
const owners = this.org.ancestors(this.auth.user().ws_ou(), true);
- return this.pcrud.search('vms', {owner: owners})
+ const mt = (mtype === 'bib') ? 'biblio' : 'authority';
+
+ return this.pcrud.search('vms',
+ {owner: owners, mtype: mt}, {}, {atomic: true})
.toPromise().then(sets => {
- sets.forEach(s => {
- if (!this.matchSets[s.mtype()]) {
- this.matchSets[s.mtype()] = [];
- }
- this.matchSets[s.mtype()].push(s);
- });
- return this.matchSets;
+ this.matchSets[mtype] = sets;
+ return sets;
});
}