LP#1850547: eg-grid: Add ignoreFields support to suppress selected IDL-generated...
authorMike Rylander <mrylander@gmail.com>
Tue, 25 Feb 2020 18:24:24 +0000 (13:24 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 3 Sep 2020 15:51:45 +0000 (11:51 -0400)
This adds an ignoreFields attribute to eg-grid to specify IDL fields
that should not be automatically added as columns to the grid.

Sponsored-by: Evergreen Community Development Initiative
Sponsored-by: Georgia Public Library Service
Sponsored-by: Indiana State Library
Sponsored-by: C/W MARS
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Tiffany Little <tlittle@georgialibraries.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.ts

index 191bec6..23996ee 100644 (file)
@@ -80,6 +80,12 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
     // the selected fields will be hidden.
     @Input() hideFields: string;
 
+    // comma-separated list of fields to ignore when generating columns
+    // from the IDL.
+    // This does not imply all other fields should be available, only
+    // that the selected fields will be ignored.
+    @Input() ignoreFields: string;
+
     // When true, only display columns that are declared in the markup
     // and leave all auto-generated fields hidden.
     @Input() showDeclaredFieldsOnly: boolean;
@@ -152,6 +158,7 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
         this.context.rowFlairCallback = this.rowFlairCallback;
         this.context.disablePaging = this.disablePaging === true;
         this.context.cellTextGenerator = this.cellTextGenerator;
+        this.context.ignoredFields = [];
 
         if (this.showFields) {
             this.context.defaultVisibleFields = this.showFields.split(',');
@@ -159,6 +166,9 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
         if (this.hideFields) {
             this.context.defaultHiddenFields = this.hideFields.split(',');
         }
+        if (this.ignoreFields) {
+            this.context.ignoredFields = this.ignoreFields.split(',');
+        }
 
         if (this.pageOffset) {
             this.context.pager.offset = this.pageOffset;
index 678651e..d40ac55 100644 (file)
@@ -505,6 +505,7 @@ export class GridContext {
     cellClassCallback: (row: any, col: GridColumn) => string;
     defaultVisibleFields: string[];
     defaultHiddenFields: string[];
+    ignoredFields: string[];
     overflowCells: boolean;
     disablePaging: boolean;
     showDeclaredFieldsOnly: boolean;
@@ -1079,20 +1080,22 @@ export class GridContext {
         this.idl.classes[this.columnSet.idlClass].fields
         .filter(field => !field.virtual)
         .forEach(field => {
-            const col = new GridColumn();
-            col.name = field.name;
-            col.label = field.label || field.name;
-            col.idlFieldDef = field;
-            col.idlClass = this.columnSet.idlClass;
-            col.datatype = field.datatype;
-            col.isIndex = (field.name === pkeyField);
-            col.isAuto = true;
-
-            if (this.showDeclaredFieldsOnly) {
-                col.hidden = true;
-            }
+            if (!this.ignoredFields.filter(ignored => ignored === field.name).length) {
+                const col = new GridColumn();
+                col.name = field.name;
+                col.label = field.label || field.name;
+                col.idlFieldDef = field;
+                col.idlClass = this.columnSet.idlClass;
+                col.datatype = field.datatype;
+                col.isIndex = (field.name === pkeyField);
+                col.isAuto = true;
+
+                if (this.showDeclaredFieldsOnly) {
+                    col.hidden = true;
+                }
 
-            this.columnSet.add(col);
+                this.columnSet.add(col);
+            }
         });
     }