LP1843837 Vandelay queue import selection persistence
authorBill Erickson <berickxx@gmail.com>
Mon, 14 Oct 2019 19:40:12 +0000 (15:40 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 24 Apr 2020 21:17:06 +0000 (17:17 -0400)
Manage grid row selection locally for the Vandelay Inspect Queue
interface (similar to the Record Matches interface) so the set of
selected records and optional merge/overlay targets may persist across
grid renderings without having to synchronize selection between the grid
and the Vandelay service.

To test, create a queue with matches, select some items in the grid,
click on one of the matches to select a match, then return to the grid.
Both the newly selected match-target row and the previously selected
rows will retain their selection.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html
Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts
Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts

index b3b39a8..1aff1af 100644 (file)
@@ -127,10 +127,19 @@ definitions.  Hide a number of stock record attributes by default
 because there are a lot of them.
 -->
 
+<ng-template #selectTemplate let-row="row">
+  <ng-container *ngIf="rowIsSelected(row.id)">
+    <span i18n-title title="Row is Selected"
+      class="material-icons">check_circle</span>
+  </ng-container>
+</ng-template>
+
 <eg-grid #queueGrid [dataSource]="queueSource"
   persistKey="cat.vandelay.queue.{{queueType}}"
   (onRowActivate)="openRecord($event)"
+  (onRowClick)="rowClicked($event)"
   [pageOffset]="queuePageOffset()" [cellTextGenerator]="cellTextGenerator"
+  [disableSelect]="true"
   hideFields="language,pagination,price,rec_identifier,eg_tcn_source,eg_identifier,item_barcode,zsource">
 
   <eg-grid-toolbar-checkbox i18n-label label="Records With Matches"
@@ -142,6 +151,9 @@ because there are a lot of them.
   <eg-grid-toolbar-checkbox i18n-label label="Records with Import Errors"
     (onChange)="limitToImportErrors($event)"></eg-grid-toolbar-checkbox>
 
+  <eg-grid-column name="selected" i18n-label label="Select"
+    [cellTemplate]="selectTemplate"></eg-grid-column>
+
   <eg-grid-column name="id" [index]="true" [hidden]="true"></eg-grid-column>
   <eg-grid-column i18n-label label="Matches" name="+matches" 
     [cellTemplate]="matchesTmpl"></eg-grid-column>
index 484e456..a3496a3 100644 (file)
@@ -205,12 +205,25 @@ export class QueueComponent implements OnInit, AfterViewInit {
             Boolean(this.vandelay.importSelection.overlayMap[rid]);
     }
 
+    rowIsSelected(rowId: number): boolean {
+        return this.vandelay.importSelection &&
+            this.vandelay.importSelection.recordIds.includes(rowId);
+    }
+
+    rowClicked(row: any) {
+        const selection = this.findOrCreateImportSelection();
+        if (selection.recordIds.includes(row.id)) {
+            selection.recordIds = selection.recordIds.filter(
+                rid => rid !== row.id);
+        } else {
+            selection.recordIds.push(row.id);
+        }
+    }
+
     importSelected() {
-        const rows = this.queueGrid.context.getSelectedRows();
-        if (rows.length) {
-            const selection = this.findOrCreateImportSelection();
-            selection.recordIds = rows.map(row => row.id);
-            console.log('importing: ', this.vandelay.importSelection);
+        const selection = this.findOrCreateImportSelection();
+        if (selection.recordIds.length) {
+            console.debug('importing: ', this.vandelay.importSelection);
             this.router.navigate(['/staff/cat/vandelay/import']);
         }
     }
index dfbee69..7a4d186 100644 (file)
@@ -86,6 +86,9 @@ export class QueuedRecordMatchesComponent implements OnInit {
             }
             const match = this.matchMap[matchId];
             selection.overlayMap[this.recordId] = match.eg_record();
+            if (!selection.recordIds.includes(this.recordId)) {
+                selection.recordIds.push(this.recordId);
+            }
         }
     }