LP#1904244: combobox: add idlBaseQuery input
authorGalen Charlton <gmc@equinoxOLI.org>
Mon, 14 Jun 2021 22:43:12 +0000 (18:43 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Aug 2021 19:29:26 +0000 (15:29 -0400)
This option allows to caller to tack on additional conditions to the
auto-generated data source, e.g., to restrict a selector to only
"active" values.

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/combobox/combobox.component.ts

index 3d39398..1de3652 100644 (file)
@@ -94,6 +94,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
     // unless startIdFiresOnChange is set to true.
     @Input() startId: any = null;
     @Input() idlClass: string;
+    @Input() idlBaseQuery: any = null;
     @Input() startIdFiresOnChange: boolean;
 
     // Allow the selected entry ID to be passed via the template
@@ -245,7 +246,10 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
 
             this.asyncDataSource = term => {
                 const field = this.idlField;
-                const args = {};
+                let args = {};
+                if (this.idlBaseQuery) {
+                    args = this.idlBaseQuery;
+                }
                 const extra_args = { order_by : {} };
                 args[field] = {'ilike': `%${term}%`}; // could -or search on label
                 extra_args['order_by'][this.idlClass] = field;