From: Bill Erickson <berickxx@gmail.com>
Date: Fri, 29 Mar 2019 16:47:27 +0000 (+0000)
Subject: LP1821382 Grid showDeclaredFieldsOnly option; sort repair.
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=28f955619a2d2d4665ff31c8efd2918a0e7532dd;p=evergreen%2Fjoelewis.git

LP1821382 Grid showDeclaredFieldsOnly option; sort repair.

Adds a @Input() showDeclaredFieldsOnly option which tells the grid to
avoid showing auto-generated columns by default and only show those
declared in the markup.

Also repairs a grid column sorting/insert bug where declared columns
would be displayed in the wrong order when mixed with auto columns.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
---

diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
index e1f988ff9f..2b28d2db17 100644
--- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
@@ -76,6 +76,10 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
     // the selected fields will be hidden.
     @Input() hideFields: string;
 
+    // When true, only display columns that are declared in the markup
+    // and leave all auto-generated fields hidden.
+    @Input() showDeclaredFieldsOnly: boolean;
+
     // Allow the caller to jump directly to a specific page of
     // grid data.
     @Input() pageOffset: number;
@@ -133,6 +137,7 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
         this.context.showLinkSelectors = this.showLinkSelectors === true;
         this.context.disableMultiSelect = this.disableMultiSelect === true;
         this.context.rowFlairIsEnabled = this.rowFlairIsEnabled  === true;
+        this.context.showDeclaredFieldsOnly = this.showDeclaredFieldsOnly;
         this.context.rowFlairCallback = this.rowFlairCallback;
         this.context.disablePaging = this.disablePaging === true;
         if (this.showFields) {
diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.ts
index fc50f59332..b133d1ad13 100644
--- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts
+++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts
@@ -130,7 +130,7 @@ export class GridColumnSet {
                 if (idx === 0) {
                     this.columns.unshift(col);
                 } else {
-                    this.columns.splice(idx - 1, 0, col);
+                    this.columns.splice(idx, 0, col);
                 }
                 return true;
             }
@@ -444,6 +444,7 @@ export class GridContext {
     overflowCells: boolean;
     showLinkSelectors: boolean;
     disablePaging: boolean;
+    showDeclaredFieldsOnly: boolean;
 
     // Allow calling code to know when the select-all-rows-in-page
     // action has occurred.
@@ -990,6 +991,10 @@ export class GridContext {
                 }
             }
 
+            if (this.showDeclaredFieldsOnly) {
+                col.hidden = true;
+            }
+
             this.columnSet.add(col);
         });
     }