added support for defining pivot data and label columns
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 22 Apr 2008 18:01:05 +0000 (18:01 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 22 Apr 2008 18:01:05 +0000 (18:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9428 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt_editor.xhtml
Open-ILS/web/reports/oils_rpt_report_editor.js

index 7d06d77..007ced5 100644 (file)
                        </tr>
                        <tr>
                                <th>Report Columns:</th>
-                               <td><b id='oils_rpt_report_editor_cols'/></td>
+                               <td nowrap='nowrap'><b id='oils_rpt_report_editor_cols'/></td>
                        </tr>
+                       <tr class='hide_me' id='oils_rpt_editor_pivot_label_row'>
+                               <th>Pivot Label Column:</th>
+                               <td>
+                    <select id='oils_rpt_editor_pivot_label'>
+                        <option selected='selected' value=''> -- Select One (optional) -- </option>
+                    </select>
+                </td>
+                       </tr>
+                       <tr class='hide_me' id='oils_rpt_editor_pivot_data_row'>
+                               <th>Pivot Data Column:</th>
+                               <td>
+                    <select id='oils_rpt_editor_pivot_data'>
+                    </select>
+                </td>
+                       </tr>
+
                        <!--
                        <tr><td colspan='2'><hr/></td></tr>
                        -->
index 778078a..8f30018 100644 (file)
@@ -21,6 +21,43 @@ function oilsRptReportEditor(rptObject, folderWindow) {
                }
        );
 
+/*
+oils_rpt_editor_pivot_label
+oils_rpt_editor_pivot_data
+*/
+
+    var hasAgg = false;
+    iterate(rptObject.def.select, 
+        function(i) {
+            if(OILS_RPT_TRANSFORMS[i.column.transform].aggregate) 
+                hasAgg = true; 
+        }
+    );
+
+    while(DOM.oils_rpt_editor_pivot_label.getElementsByTagName('option').length > 1)
+        DOM.oils_rpt_editor_pivot_label.removeChild(DOM.oils_rpt_editor_pivot_label.lastChild);
+
+    while(DOM.oils_rpt_editor_pivot_data.lastChild)
+        DOM.oils_rpt_editor_pivot_data.removeChild(DOM.oils_rpt_editor_pivot_data.lastChild);
+
+    if(hasAgg) {
+        unHideMe(DOM.oils_rpt_editor_pivot_label_row);
+        unHideMe(DOM.oils_rpt_editor_pivot_data_row);
+
+        for(var i in rptObject.def.select) {
+            var col = rptObject.def.select[i];
+            if(OILS_RPT_TRANSFORMS[col.column.transform].aggregate) 
+               insertSelectorVal(DOM.oils_rpt_editor_pivot_data, -1, col.alias, parseInt(i)+1);
+            else
+               insertSelectorVal(DOM.oils_rpt_editor_pivot_label, -1, col.alias, parseInt(i)+1);
+        }
+
+    } else {
+        hideMe(DOM.oils_rpt_editor_pivot_label_row);
+        hideMe(DOM.oils_rpt_editor_pivot_data_row);
+    }
+
        if( rpt ) {
                DOM.oils_rpt_report_editor_name.value = rpt.name();
                DOM.oils_rpt_report_editor_description.value = rpt.description();
@@ -102,6 +139,12 @@ oilsRptReportEditor.prototype.save = function() {
                data[par.key] = val;
        }
 
+    if(getSelectorVal(DOM.oils_rpt_editor_pivot_data)) {
+        data.__pivot_label = getSelectorVal(DOM.oils_rpt_editor_pivot_label);
+        data.__pivot_data = getSelectorVal(DOM.oils_rpt_editor_pivot_data);
+    }
+
+
        data = js2JSON(data);
        _debug("complete report data = "+data);
        report.data(data);