From: Bill Erickson Date: Mon, 9 Jul 2018 21:52:57 +0000 (-0400) Subject: LP#1779158 Ang vand queue actions (import selected) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1728a3ba1d07459ed4d33131c03a5ec043bdee0;p=working%2FEvergreen.git LP#1779158 Ang vand queue actions (import selected) Signed-off-by: Bill Erickson --- 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 c5d1474cc2..68c0116c2f 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 @@ -9,11 +9,12 @@
- @@ -36,6 +37,9 @@
@@ -46,7 +50,8 @@
@@ -57,8 +62,8 @@
@@ -74,7 +79,8 @@
@@ -130,7 +136,7 @@ [(ngModel)]="autoOverlayAcqCopies">
-
+
@@ -139,6 +145,20 @@ required class="form-control" type="file"/>
+
+
+ +
+
+ + Importing {{importSelection().recordIds.length}} Record(s) + + Importing Queue {{importSelection().queue.name()}} + +
+
-
+
@@ -155,7 +175,7 @@
-
+
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 f99f0f0177..69b32b775d 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 @@ -7,7 +7,7 @@ import {OrgService} from '@eg/core/org.service'; import {AuthService} from '@eg/core/auth.service'; import {ToastService} from '@eg/share/toast/toast.service'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; -import {VandelayService} from './vandelay.service'; +import {VandelayService, VandelayImportSelection} from './vandelay.service'; import {HttpClient, HttpRequest, HttpEventType} from '@angular/common/http'; import {HttpResponse, HttpErrorResponse} from '@angular/common/http'; import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component'; @@ -35,6 +35,11 @@ export class ImportComponent implements OnInit, AfterViewInit { recordType: string; selectedQueue: ComboboxEntry; // freetext enabled + + // used for applying a default queue ID value when we have + // a load-time queue before the queue combobox entries exist. + startQueueId: number; + activeQueueId: number; selectedBucket: number; selectedBibSource: number; @@ -44,7 +49,6 @@ export class ImportComponent implements OnInit, AfterViewInit { selectedFallThruMergeProfile: number; selectedFile: File; - attrDefs: {[atype: string]: IdlObject[]}; defaultMatchSet: string; importNonMatching: boolean; @@ -84,10 +88,28 @@ export class ImportComponent implements OnInit, AfterViewInit { private org: OrgService, private vandelay: VandelayService ) { - this.recordType = 'bib'; - this.selectedBibSource = 2; // default to system local - this.attrDefs = {}; + this.applyDefaults(); + } + + applyDefaults() { + this.minQualityRatio = 0; + this.selectedBibSource = 1; // default to system local + this.recordType = 'bib'; + + if (!this.vandelay.importSelection) { + return; + } + + const queue = this.vandelay.importSelection.queue; + this.recordType = queue.queue_type(); + this.selectedMatchSet = queue.match_set(); + this.startQueueId = queue.id(); + + if (this.recordType === 'bib') { + this.selectedBucket = queue.match_bucket(); + this.selectedHoldingsProfile = queue.item_attr_def(); + } } ngOnInit() {} @@ -96,21 +118,21 @@ export class ImportComponent implements OnInit, AfterViewInit { this.loadStartupData(); } + importSelection(): VandelayImportSelection { + return this.vandelay.importSelection; + } + loadStartupData(): Promise { // 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') - .then(defs => this.attrDefs.bib = defs), - this.vandelay.getAttrDefs('auth') - .then(defs => this.attrDefs.auth = defs), this.vandelay.getMergeProfiles(), this.vandelay.getActiveQueues('bib'), - this.vandelay.getActiveQueues('auth'), + this.vandelay.getActiveQueues('authority'), this.vandelay.getMatchSets('bib'), - this.vandelay.getMatchSets('auth'), + this.vandelay.getMatchSets('authority'), this.vandelay.getBibBuckets(), this.vandelay.getBibSources(), this.vandelay.getItemImportDefs(), @@ -196,9 +218,19 @@ export class ImportComponent implements OnInit, AfterViewInit { // Required form data varies depending on context. hasNeededData(): boolean { - return this.selectedQueue - && Boolean(this.recordType) - && Boolean(this.selectedFile); + if (this.vandelay.importSelection) { + return this.importActionSelected(); + } else { + return this.selectedQueue + && Boolean(this.recordType) && Boolean(this.selectedFile) + } + } + + importActionSelected(): boolean { + return this.importNonMatching + || this.mergeOnExact + || this.mergeOnSingleMatch + || this.mergeOnBestMatch; } // 1. create queue if necessary @@ -266,6 +298,12 @@ export class ImportComponent implements OnInit, AfterViewInit { } uploadFile(): Promise { + + if (this.vandelay.importSelection) { + // Nothing to upload when processing pre-queued records. + return Promise.resolve(); + } + const formData: FormData = new FormData(); formData.append('ses', this.auth.token()); @@ -301,12 +339,18 @@ export class ImportComponent implements OnInit, AfterViewInit { } processSpool(): Promise { - const rtype = this.recordType === 'bib' ? 'bib' : 'authority'; - const method = `open-ils.vandelay.${rtype}.process_spool`; + + if (this.vandelay.importSelection) { + // Nothing to enqueue when processing pre-queued records + return Promise.resolve(); + } + + const method = `open-ils.vandelay.${this.recordType}.process_spool`; return this.net.request( 'open-ils.vandelay', method, - this.auth.token(), this.sessionKey, this.activeQueueId + this.auth.token(), this.sessionKey, this.activeQueueId, + null, null, this.selectedBibSource ).pipe(tap( resp => { const e = this.evt.parse(resp); @@ -327,24 +371,32 @@ export class ImportComponent implements OnInit, AfterViewInit { importRecords(): Promise { - // Confirm an import action was selected - if (this.importNonMatching - || this.mergeOnExact - || this.mergeOnSingleMatch - || this.mergeOnBestMatch) { - - return this.importRecordQueue() + if (!this.importActionSelected()) { + return Promise.resolve(); } - return Promise.resolve(); + const selection = this.vandelay.importSelection; + + if (selection && !selection.importQueue) { + return this.importRecordQueue(selection.recordIds); + } else { + return this.importRecordQueue(); + } } - importRecordQueue(): Promise { - const method = `open-ils.vandelay.${this.recordType}_queue.import`; + importRecordQueue(recIds?: number[]): Promise { + const rtype = this.recordType === 'bib' ? 'bib' : 'auth'; + let method = `open-ils.vandelay.${rtype}_queue.import`; const options: ImportOptions = this.compileImportOptions(); + let target: number | number[] = this.activeQueueId; + if (recIds && recIds.length) { + method = `open-ils.vandelay.${rtype}_record.list.import`; + target = recIds; + } + return this.net.request('open-ils.vandelay', - method, this.auth.token(), this.activeQueueId, options + method, this.auth.token(), target, options ).pipe(tap( resp => { const e = this.evt.parse(resp); @@ -358,9 +410,6 @@ export class ImportComponent implements OnInit, AfterViewInit { )).toPromise(); } - // TODO - //importRecordList() {} - compileImportOptions(): ImportOptions { const options: ImportOptions = { @@ -378,6 +427,11 @@ export class ImportComponent implements OnInit, AfterViewInit { return options; } + clearSelection() { + this.vandelay.importSelection = null; + this.startQueueId = null; + } + openQueue() { console.log('opening queue ' + this.activeQueueId); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html index 1392b722e3..707ccd5fb7 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html @@ -1,86 +1,69 @@

Queue {{queueSummary.queue.name()}}

-
-
-
-
Queue Actions
-
    -
-
-
-
+
Queue Summary
  • -
    -
    Records in Queue:
    -
    {{queueSummary.total}}
    -
    -
  • -
  • -
    -
    Records Imported:
    -
    {{queueSummary.imported}}
    -
    -
  • -
  • -
    -
    Records Import Failures:
    -
    {{queueSummary.rec_import_errors}}
    -
    -
  • -
  • -
    -
    Items in Queue:
    -
    {{queueSummary.total_items}}
    +
    +
    Records in Queue:
    +
    {{queueSummary.total}}
    +
    Items in Queue:
    +
    {{queueSummary.total_items}}
  • -
    -
    Items Imported:
    -
    {{queueSummary.total_items_imported}}
    +
    +
    Records Imported:
    +
    {{queueSummary.imported}}
    +
    Items Imported:
    +
    {{queueSummary.total_items_imported}}
  • -
    -
    Item Import Failures:
    -
    {{queueSummary.item_import_errors}}
    +
    +
    Records Import Failures:
    +
    {{queueSummary.rec_import_errors}}
    +
    Item Import Failures:
    +
    {{queueSummary.item_import_errors}}
-
+
-
Queue Filters
+
Queue Actions
  • -
    -
    Limit to Records with Matches:
    -
  • -
    -
    Limit to Non-Imported Records:
    -
  • -
    -
    - Limit to Records with Import Errors
    -
  • @@ -120,6 +103,16 @@ because there are a lot of them. + + + + + + + void; + limitToNonImported: (checked: boolean) => void; + limitToImportErrors: (checked: boolean) => void; // keep a local copy for convenience attrDefs: IdlObject[]; @@ -45,11 +50,24 @@ export class QueueComponent implements AfterViewInit { }); this.queueSource = new GridDataSource(); - - // queue API does not support sorting this.queueSource.getRows = (pager: Pager) => { return this.loadQueueRecords(pager); - } + }; + + this.limitToMatches = (checked: boolean) => { + this.filters.matches = checked; + this.queueGrid.reload(); + }; + + this.limitToNonImported = (checked: boolean) => { + this.filters.nonImported = checked; + this.queueGrid.reload(); + }; + + this.limitToImportErrors = (checked: boolean) => { + this.filters.withErrors = checked; + this.queueGrid.reload(); + }; } ngAfterViewInit() { @@ -83,8 +101,9 @@ export class QueueComponent implements AfterViewInit { } loadQueueSummary(): Promise { + const qtype = this.queueType === 'bib' ? 'bib' : 'auth'; const method = - `open-ils.vandelay.${this.queueType}_queue.summary.retrieve`; + `open-ils.vandelay.${qtype}_queue.summary.retrieve`; return this.net.request( 'open-ils.vandelay', method, this.auth.token(), this.queueId) @@ -97,11 +116,13 @@ export class QueueComponent implements AfterViewInit { clear_marc: true, offset: pager.offset, limit: pager.limit, - flesh_import_items: true + flesh_import_items: true, + non_imported: this.filters.nonImported, + with_import_error: this.filters.withErrors } return this.vandelay.getQueuedRecords( - this.queueId, this.queueType, options) + this.queueId, this.queueType, options, this.filters.matches) .pipe(map(rec => { const recHash: any = { @@ -122,5 +143,15 @@ export class QueueComponent implements AfterViewInit { return recHash; })); } + + importSelected() { + const rows = this.queueGrid.context.getSelectedRows(); + if (rows.length === 0) { return; } + const selection = new VandelayImportSelection(); + selection.recordIds = rows.map(row => row.id); + selection.queue = this.queueSummary.queue; + this.vandelay.importSelection = selection; + this.router.navigate(['/staff/cat/vandelay/import']); + } } 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 5bd16d2582..41e3df617e 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 @@ -11,6 +11,12 @@ import {PermService} from '@eg/core/perm.service'; import {EventService} from '@eg/core/event.service'; import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; +export class VandelayImportSelection { + recordIds: number[]; + queue: IdlObject; + importQueue: boolean; // import the whole queue +} + @Injectable() export class VandelayService { @@ -25,6 +31,10 @@ export class VandelayService { bibTrashGroups: IdlObject[]; mergeProfiles: IdlObject[]; + // Used for tracking records between the queue page and + // the import page. Fields managed externally. + importSelection: VandelayImportSelection; + constructor( private idl: IdlService, private org: OrgService, @@ -80,10 +90,9 @@ export class VandelayService { } // could be a big list, invoke in streaming mode - const qt = (qtype === 'bib') ? qtype : 'authority'; return this.net.request( 'open-ils.vandelay', - `open-ils.vandelay.${qt}_queue.owner.retrieve`, + `open-ils.vandelay.${qtype}_queue.owner.retrieve`, this.auth.token(), null, {complete: 'f'} ).pipe(tap( queue => this.activeQueues[qtype].push(queue) @@ -126,10 +135,9 @@ export class VandelayService { } const owners = this.org.ancestors(this.auth.user().ws_ou(), true); - const mt = (mtype === 'bib') ? 'biblio' : 'authority'; return this.pcrud.search('vms', - {owner: owners, mtype: mt}, {}, {atomic: true}) + {owner: owners, mtype: mtype}, {}, {atomic: true}) .toPromise().then(sets => { this.matchSets[mtype] = sets; return sets; @@ -190,10 +198,9 @@ export class VandelayService { matchSet: number, matchBucket: number): Promise { - const name = recordType === 'bib' ? 'bib' : 'authority'; - const method = `open-ils.vandelay.${name}_queue.create`; + const method = `open-ils.vandelay.${recordType}_queue.create`; - let qType = name; + let qType = recordType; if (recordType.match(/acq/)) { let qType = 'acq'; } @@ -215,11 +222,18 @@ export class VandelayService { }); } - getQueuedRecords(queueId: number, - queueType: string, options?: any): Observable { + getQueuedRecords(queueId: number, queueType: string, + options?: any, limitToMatches?: boolean): Observable { - const method = - `open-ils.vandelay.${queueType}_queue.records.retrieve`; + const qtype = queueType === 'bib' ? 'bib' : 'auth'; + + let method = + `open-ils.vandelay.${qtype}_queue.records.retrieve`; + + if (limitToMatches) { + method = + `open-ils.vandelay.${qtype}_queue.records.matches.retrieve`; + } return this.net.request('open-ils.vandelay', method, this.auth.token(), queueId, options);