LP1936233 Retain row selection after grid action
authorBill Erickson <berickxx@gmail.com>
Thu, 5 Aug 2021 15:40:08 +0000 (11:40 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 5 Aug 2021 15:40:08 +0000 (11:40 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts

index f4032a7..3be53f3 100644 (file)
@@ -205,6 +205,9 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
                 }
                 this.itemService.scannedItems.forEach((item, idx) => {
                     if (item.id() === updatedCopy.id()) {
+                        // Retain the original grid index value so row
+                        // selection can persist.
+                        updatedCopy._index = item._index;
                         this.itemService.scannedItems.splice(idx, 1, updatedCopy);
                     }
                 });
@@ -316,6 +319,8 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
         });
     }
 
+    // In fetchOnly mode, item data is fetched but not added directly to
+    // the grid.
     getItemById(id: number, fetchOnly?: boolean): Promise<any> {
 
         const flesh = {
@@ -341,9 +346,9 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
         .toPromise().then(item => {
             this.mungeIsbns(item);
             this.selectInput();
-            item._index = ItemStatusComponent.rowIndex++;
 
             if (!fetchOnly) {
+                item._index = ItemStatusComponent.rowIndex++;
                 if (this.tab === 'list') {
                     this.itemService.scannedItems.unshift(item);
                 } else {
@@ -358,10 +363,9 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
             }
 
             return this.getItemCirc(item).then(_ => {
-                if (this.grid) {
+                if (this.grid && !fetchOnly) {
                     this.grid.reload();
                 }
-
                 return item;
             });
         });