eg-grid: Add ignoreFields support to suppress selected IDL-generated grid fields
authorMike Rylander <mrylander@gmail.com>
Tue, 25 Feb 2020 18:24:24 +0000 (13:24 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Feb 2020 18:24:24 +0000 (13:24 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.ts

index 191bec6..7412bac 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;
@@ -159,6 +165,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 b1fbf90..258153a 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);
+            }
         });
     }