LP#1904244: teach grid columns how to start with a filter set
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 25 Mar 2021 17:44:44 +0000 (13:44 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Aug 2021 19:29:26 +0000 (15:29 -0400)
This adds initialFilterOperator and initialFilterValue inputs
to eg-grid-column to specify that the data set should start off
with a column filter set.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-filter-control.component.ts

index 1556d31..3822060 100644 (file)
@@ -30,6 +30,10 @@ export class GridColumnComponent implements OnInit {
     // result filtering
     @Input() filterable: boolean;
 
+    // optional initial filter values
+    @Input() initialFilterOperator: string;
+    @Input() initialFilterValue: string;
+
     // Display date and time when datatype = timestamp
     @Input() datePlusTime: boolean;
 
@@ -66,6 +70,8 @@ export class GridColumnComponent implements OnInit {
         col.disableTooltip = this.disableTooltip;
         col.isSortable = this.sortable;
         col.isFilterable = this.filterable;
+        col.filterOperator = this.initialFilterOperator;
+        col.filterValue = this.initialFilterValue;
         col.isMultiSortable = this.multiSortable;
         col.datatype = this.datatype;
         col.datePlusTime = this.datePlusTime;
index 36fcfae..e5add56 100644 (file)
@@ -33,7 +33,11 @@ export class GridFilterControlComponent implements OnInit {
         private org: OrgService
     ) {}
 
-    ngOnInit() { }
+    ngOnInit() {
+        if (this.col.filterValue !== undefined) {
+           this.applyFilter(this.col);
+        }
+    }
 
     operatorChanged(col: GridColumn) {
         if (col.filterOperator === 'null' || col.filterOperator === 'not null') {