LP#1329503 report editing misc. repairs
authorBill Erickson <berick@esilibrary.com>
Thu, 10 Jul 2014 18:42:31 +0000 (14:42 -0400)
committerBen Shum <bshum@biblio.org>
Fri, 8 Aug 2014 01:51:58 +0000 (21:51 -0400)
* Fixed some faultly widget rendering on report edit

* Avoid showing "save as new" for new reports.

* Repair fault report edit Exit/Cancel buttons

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 405846e..cec13ef 100644 (file)
@@ -154,9 +154,17 @@ oils_rpt_editor_pivot_data
         DOM.oils_rpt_report_editor_save.disabled = false;
 
         unHideMe(DOM.oils_rpt_report_editor_save);
-        unHideMe(DOM.oils_rpt_report_editor_save_new);
         unHideMe(DOM.oils_rpt_report_editor_cancel);
         hideMe(DOM.oils_rpt_report_editor_exit);
+
+    }
+
+    // avoid showing save-as-new for new reports, since the
+    // regular save button acts as save-as-new
+    if (rpt && !this.readonly) {
+        unHideMe(DOM.oils_rpt_report_editor_save_new);
+    } else {
+        hideMe(DOM.oils_rpt_report_editor_save_new);
     }
 
        this.paramEditor = new oilsRptParamEditor(
@@ -461,6 +469,8 @@ oilsRptReportEditor.prototype.showPendingScheduleDialog = function() {
 
 
 oilsRptReportEditor.prototype.exit = function() {
-    oilsRptCurrentFolderManager.draw();
-    this.folderWindow.draw();
+    unHideMe(DOM.oils_rpt_folder_window_contents_table);                   
+    unHideMe(DOM.oils_rpt_folder_table_right_td);
+    hideMe(DOM.oils_rpt_folder_table_alt_td);
+    hideMe(DOM.oils_rpt_editor_div);
 }
index 97c7e61..5f4dc26 100644 (file)
@@ -135,7 +135,6 @@ function oilsRptTextWidget(args) {
 }
 oilsRptTextWidget.prototype.draw = function() {
        this.node.appendChild(this.dest);
-    // TODO: untested
     if (this.seedValue) {
         this.dest.value = this.seedValue;
         this.dest.onchange(); // validation
@@ -159,7 +158,7 @@ oilsRptTextWidget.prototype.getDisplayValue = function() {
        --------------------------------------------------------------------- */
 function oilsRptBoolWidget(args) {
        this.node = args.node;
-    this.seedValue = arg.value;
+    this.seedValue = args.value;
        this.selector = elem('select');
        insertSelectorVal(this.selector, -1,'True','t');
        insertSelectorVal(this.selector, -1,'False','f');
@@ -168,7 +167,7 @@ function oilsRptBoolWidget(args) {
 
 oilsRptBoolWidget.prototype.draw = function() {
        this.node.appendChild(this.selector);
-    if (this.seedValue)  // TODO: untested
+    if (this.seedValue)  
         setSelector(this.selector, this.seedValue);
 }
 
@@ -283,7 +282,7 @@ oilsRptOrgSelector.prototype.draw = function(org) {
        if(!org) org = globalOrgTree;
        var opt = insertSelectorVal( this.selector, -1, 
                org.shortname(), org.id(), null, findOrgDepth(org) );
-       if( org.id() == oilsRptCurrentOrg )
+       if( org.id() == oilsRptCurrentOrg && !this.seedValue)
                opt.selected = true;
        
        /* sometimes we need these choices 
@@ -358,10 +357,12 @@ oilsRptAgeWidget.prototype.draw = function() {
        this.node.appendChild(this.count);
        this.node.appendChild(this.type);
 
-    if (this.seedValue) { // TODO: test me
-        var parts = this.seedValue.split(/ /);
-        setSelector(this.count, parts[0]);
-        setSelector(this.type, parts[1]);
+    if (this.seedValue) { 
+        // e.g. "2months"
+        var count = this.seedValue.match(/(\d+)([^\d]+)/)[1];
+        var type = this.seedValue.match(/(\d+)([^\d]+)/)[2];
+        setSelector(this.count, count);
+        setSelector(this.type, type);
     }
 }
 
@@ -449,7 +450,7 @@ oilsRptNumberWidget.prototype.draw = function() {
        this.node.appendChild(this.selector);
        var obj = this;
 
-    if (this.seedValue) // TODO: test me
+    if (this.seedValue)
         setSelector(this.selector, this.seedValue);
 }
 
@@ -484,7 +485,7 @@ oilsRptTemplateWidget.prototype.draw = function() {
 function oilsRptTruncPicker(args) {
        this.node = args.node;
        this.type = args.type;
-    this.seedValue = args.value; // TODO: FINISH
+    this.seedValue = args.value;
        this.realSpan = elem('span');
        this.relSpan = elem('span');
        hideMe(this.relSpan);
@@ -526,6 +527,21 @@ oilsRptTruncPicker.prototype.draw = function() {
                        hideMe(obj.realSpan);
                }
        }
+
+    if (seed = this.seedValue) {
+        if (typeof seed == 'string') {
+            this.calWidget.value = seed;
+        } else {
+            // relative date transform
+            if (seed.transform.match(/relative/)) {
+                setSelector(this.selector, 2)
+                setSelector(this.numberPicker.selector, 
+                    Math.abs(seed.params[0]));
+                           unHideMe(this.relSpan);
+                           hideMe(this.realSpan);
+            }
+        }
+    }
 }
 
 oilsRptTruncPicker.prototype.getValue = function() {