LP#1916969: improvement to report filter parameter selector user/gmcharlt/lp1916969_rpt_datepicker_in_list
authorGalen Charlton <gmc@equinoxOLI.org>
Wed, 22 Mar 2023 22:21:07 +0000 (18:21 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Wed, 22 Mar 2023 22:21:07 +0000 (18:21 -0400)
This patch teaches the legacy reporter how to handle
editing a report parameter that uses the 'in list' operator
and a date/relative date selector.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
 #

Open-ILS/web/reports/oils_rpt_widget.js

index f711089..3b2e61f 100644 (file)
@@ -45,7 +45,29 @@ oilsRptSetWidget.prototype.draw = function() {
                     this_.addButton.onclick();
                 });
                 this_.inputWidget.dest.value = '';
-
+            } else if (this_.inputWidget instanceof oilsRptTruncPicker) {
+                // add each seed value to the input widget, then
+                // propagate the value into our multiselect.
+                // when done, clear the value from the date widget.
+                dojo.forEach(this_.seedValue, function(val) {
+                    if (seed = val) {
+                        if (typeof seed == 'string') {
+                            this_.inputWidget.calWidget.input.value = seed;
+                        } else {
+                            // relative date transform
+                            if (seed.transform.match(/relative/)) {
+                                setSelector(this_.inputWidget.selector, 2)
+                                setSelector(this_.inputWidget.numberPicker.selector,
+                                    Math.abs(seed.params[0]));
+                            }
+                        }
+                    }
+                    this_.addButton.onclick();
+                    this_.inputWidget.calWidget.input.value = '';
+                    setSelector(this_.inputWidget.selector, 1)
+                    setSelector(this_.inputWidget.numberPicker.selector, 1);
+                    this_.inputWidget.selector.onchange();
+                });
             } else {
                 this_.addButton.onclick();
             }
@@ -250,7 +272,12 @@ function oilsRptCalWidget(args) {
        this.node = args.node;
        this.calFormat = args.calFormat;
        this.input = elem('input',{type:'text',size:12});
-    this.seedValue = args.value;
+    if (!dojo.isArray(args.value)) {
+        // if the value is an array, we're probably
+        // in an oilsRptTruncPicker that is inside
+        // an oilsRptSetWidget
+        this.seedValue = args.value;
+    }
     this.input.disabled = Boolean(args.readonly);
 
        oilsRptMonitorWidget(this.input, args.regex);
@@ -556,6 +583,12 @@ oilsRptTruncPicker.prototype.draw = function() {
                }
        }
 
+    if (dojo.isArray(this.seedValue)) {
+        // we're part of a in-list selector, so let
+        // post-draw handle this
+        return;
+    }
+
     if (seed = this.seedValue) {
         if (typeof seed == 'string') {
             this.calWidget.value = seed;