From c92afb7660ebd94ef833740a2d74737149e2061a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 12 Jul 2018 11:05:01 -0400 Subject: [PATCH] LP#1779158 Merge target selection improvements Signed-off-by: Bill Erickson --- .../app/staff/cat/vandelay/queue-list.component.ts | 3 ++ .../app/staff/cat/vandelay/queue.component.html | 1 + .../src/app/staff/cat/vandelay/queue.component.ts | 5 ++ .../vandelay/queued-record-matches.component.html | 15 +++++- .../vandelay/queued-record-matches.component.ts | 54 +++++++++++++--------- .../src/app/staff/cat/vandelay/vandelay.service.ts | 6 +++ 6 files changed, 59 insertions(+), 25 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts index 84c73a3e39..888c8a57f4 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts @@ -36,6 +36,9 @@ export class QueueListComponent { this.queueType = 'bib'; this.queueSource = new GridDataSource(); + // Reset queue grid offset + this.vandelay.queuePageOffset = 0; + // queue API does not support sorting this.queueSource.getRows = (pager: Pager) => { return this.loadQueues(pager); 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 dab90bc375..6136b13f2b 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 @@ -119,6 +119,7 @@ because there are a lot of them. { + this.vandelay.queuePageOffset = pager.offset; return this.loadQueueRecords(pager); }; @@ -81,6 +82,10 @@ export class QueueComponent implements OnInit, AfterViewInit { ngOnInit() { } + queuePageOffset(): number { + return this.vandelay.queuePageOffset; + } + ngAfterViewInit() { if (this.queueType) { this.applyQueueType(); diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html index b6215d4725..db72a9aa24 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html @@ -5,17 +5,28 @@ + + + check_circle + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts index 32e7917ccb..74e70f1f9e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts @@ -5,7 +5,7 @@ import 'rxjs/add/observable/of'; import {map} from 'rxjs/operators/map'; import {Pager} from '@eg/share/util/pager'; import {GridComponent} from '@eg/share/grid/grid.component'; -import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid'; +import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; import {IdlObject} from '@eg/core/idl.service'; import {EventService} from '@eg/core/event.service'; import {NetService} from '@eg/core/net.service'; @@ -29,7 +29,8 @@ export class QueuedRecordMatchesComponent implements OnInit { bibDataSource: GridDataSource; authDataSource: GridDataSource; markOverlayTarget: (rows: any[]) => any; - matchRowCallback: (row: any) => GridRowFlairEntry; + matchRowClick: (row: any) => void; + matchMap: {[id: number]: IdlObject}; constructor( private router: Router, @@ -53,36 +54,41 @@ export class QueuedRecordMatchesComponent implements OnInit { } */ - this.markOverlayTarget = (rows: any[]) => { + // Mark or un-mark as row as the merge target on row click + this.matchRowClick = (row: any) => { + this.toggleMergeTarget(row.id); + } + } + + toggleMergeTarget(matchId: number) { + + if (this.isOverlayTarget(matchId)) { + + // clear selection on secondary click; + delete this.vandelay.importSelection.overlayMap[this.recordId]; + + } else { + // Add to selection. + // Start a new one if necessary, which will be adopted + // and completed by the queue UI before import. - // Start a new import selection object if needed. - // This will be adopted by the queue UI before import. let selection = this.vandelay.importSelection; if (!selection) { selection = new VandelayImportSelection(); this.vandelay.importSelection = selection; } - - // Grid is configured for single-row-select. - const match = rows[0]; - selection.overlayMap[this.recordId] = match.eg_record; - } - - this.matchRowCallback = (row: any) => { - const selection = this.vandelay.importSelection; - if (selection) { - const target = selection.overlayMap[this.recordId]; - if (target === row.eg_record) { - return {icon: 'check_circle'}; - } - } - return null; + const match = this.matchMap[matchId]; + selection.overlayMap[this.recordId] = match.eg_record(); } } - hasOverlayTarget(rid: number): boolean { - return this.vandelay.importSelection && - Boolean(this.vandelay.importSelection.overlayMap[rid]); + isOverlayTarget(matchId: number): boolean { + const selection = this.vandelay.importSelection; + if (selection) { + const match = this.matchMap[matchId]; + return selection.overlayMap[this.recordId] === match.eg_record(); + } + return false; } ngOnInit() {} @@ -96,7 +102,9 @@ export class QueuedRecordMatchesComponent implements OnInit { const matches = this.queuedRecord.matches(); const recIds = []; + this.matchMap = {}; matches.forEach(m => { + this.matchMap[m.id()] = m; if (!recIds.includes(m.eg_record())) { recIds.push(m.eg_record()); } 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 178b2f0b72..375a84107a 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 @@ -46,6 +46,11 @@ export class VandelayService { // the import page. Fields managed externally. importSelection: VandelayImportSelection; + // Track the last grid offset in the queue page so we + // can return the user to the same page of data after + // going to the matches page. + queuePageOffset: number; + constructor( private http: HttpClient, private idl: IdlService, @@ -61,6 +66,7 @@ export class VandelayService { this.allQueues = {}; this.matchSets = {}; this.importSelection = null; + this.queuePageOffset = 0; } getAttrDefs(dtype: string): Promise { -- 2.11.0