LP#1329503 report editing additional repairs
authorBill Erickson <berick@esilibrary.com>
Wed, 6 Aug 2014 14:41:25 +0000 (10:41 -0400)
committerBen Shum <bshum@biblio.org>
Fri, 8 Aug 2014 01:51:58 +0000 (21:51 -0400)
* correctly propagate values for the "between" widget
* propagate pivot data and label when present
* propagate report run time
* improvements to report email propagation

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/web/reports/oils_rpt_report_editor.js
Open-ILS/web/reports/oils_rpt_widget.js

index cec13ef..4cbebcf 100644 (file)
@@ -106,6 +106,14 @@ oils_rpt_editor_pivot_data
             setSelector(DOM.oils_rpt_recur_interval_type, parts[1]);
         }
 
+        if (rpt.data()) { 
+            var rpt_data = JSON2js(rpt.data());
+            if (rpt_data.__pivot_label)
+                setSelector(DOM.oils_rpt_editor_pivot_label, rpt_data.__pivot_label);
+            if (rpt_data.__pivot_data)
+                setSelector(DOM.oils_rpt_editor_pivot_data, rpt_data.__pivot_data);
+        }
+
         if (run = this.last_run) {
                    DOM.oils_rpt_report_editor_name.disabled = true;
                    DOM.oils_rpt_report_editor_desc.disabled = true;
@@ -114,6 +122,25 @@ oils_rpt_editor_pivot_data
             DOM.oils_rpt_format_html.checked = run.html_format() == 't';
             DOM.oils_rpt_format_chart_bar.checked = run.chart_bar() == 't';
             DOM.oils_rpt_format_chart_line.checked = run.chart_line() == 't';
+            DOM.oils_rpt_param_editor_sched_email = run.email();
+
+            if (run.run_time()) {
+                DOM.oils_rpt_report_editor_schedule.checked = true;
+                if (new Date(Date.parse(run.run_time())) < new Date()) {
+                    // editing a report with a past-tense run time
+                    // clear the value so the user will have to edit
+                    DOM.oils_rpt_param_editor_sched_start_date.value = '';
+                } else {
+                    DOM.oils_rpt_param_editor_sched_start_date.value = 
+                        run.run_time().match(/(\d\d\d\d-\d\d-\d\d)/)[1]
+                    setSelector(
+                        DOM.oils_rpt_param_editor_sched_start_hour,
+                        run.run_time().match(/T(\d\d:\d\d)/)[1]
+                    );
+                }
+            } else {
+                DOM.oils_rpt_param_editor_sched_start_date.value = mkYearMonDay();
+            }
         }
        }
 
@@ -223,8 +250,6 @@ oils_rpt_editor_pivot_data
        DOM.oils_rpt_param_editor_sched_email.value = 
         this.last_run ? this.last_run.email() : USER.email();
 
-       DOM.oils_rpt_param_editor_sched_start_date.value = mkYearMonDay();
-
        _debug("fleshing template:\n" + tmpl.name() + '\n' + formatJSON(tmpl.data()));
 }
 
index 5f4dc26..f4f5263 100644 (file)
@@ -96,7 +96,10 @@ oilsRptSetWidget.prototype.strToObj = function(str) {
        --------------------------------------------------------------------- */
 function oilsRptBetweenWidget(args) {
        this.node = args.node;
+       var seedValue = args.value;
+       if (seedValue) args.value = seedValue[0];
        this.startWidget = new args.startWidget(args);
+       if (seedValue) args.value = seedValue[1];
        this.endWidget = new args.endWidget(args);
 }
 oilsRptBetweenWidget.prototype.draw = function() {