more grunt work
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Sep 2006 22:09:41 +0000 (22:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Sep 2006 22:09:41 +0000 (22:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6170 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt.css
Open-ILS/web/reports/oils_rpt.js
Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_builder.xhtml
Open-ILS/web/reports/oils_rpt_tree.js
Open-ILS/web/reports/oils_rpt_utils.js
Open-ILS/web/reports/oils_rpt_vars.js

index 84e87c9..e202ea9 100644 (file)
@@ -2,6 +2,19 @@ body { font-size: 9pt; }
 .hide_me { display: none; visibility: hidden; }
 .welcome_box { position:absolute; top: 5px; right: 5px; }
 
+
+.oils_rpt_main_link {
+       padding: 5px;
+       font-size: 10pt;
+}
+
+#oils_rpt_name_div {
+       vertical-align: middle;
+       padding: 5px;
+       background: #E0F0F0; 
+       margin-bottom: 20px;
+}
+
 #oils_rpt_table {
        width: 100%;
        border-top: 2px solid #E0E0E0;
@@ -36,7 +49,8 @@ body { font-size: 9pt; }
 
 .oils_rpt_info_selector {
        border: 1px solid blue; 
-       background: #E0F0E0; 
+       /*background: #E0F0E0;*/
+       background: #E0F0F0; 
        min-height: 130px;
        max-height: 240px;
        overflow: scroll;
index 5c6b692..bdce9bf 100644 (file)
@@ -1,9 +1,5 @@
 
 function oilsInitReports() {
-       oilsRpt = new oilsReport();
-       oilsRptDisplaySelector  = $('oils_rpt_display_selector');
-       oilsRptFilterSelector   = $('oils_rpt_filter_selector');
-
        /* tell FF to capture mouse movements */
        document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = setMousePos;
@@ -12,18 +8,10 @@ function oilsInitReports() {
        fetchUser(cgi.param('ses'));
        $('oils_rpt_user').appendChild(text(USER.usrname()));
        oilsRptDebugEnabled = cgi.param('dbg');
-
-       oilsDrawRptTree(
-               function() { 
-                       hideMe($('oils_rpt_tree_loading')); 
-                       unHideMe($('oils_rpt_table')); 
-               }
-       );
-
 }
 
 function oilsCleanupReports() {
-       if(oilsRptDebugWindow) oilsRptDebugWindow.close();
+       try {oilsRptDebugWindow.close();} catch(e) {}
 }
 
 
@@ -31,10 +19,13 @@ function oilsCleanupReports() {
        Define the report object
        --------------------------------------------------------------------- */
 function oilsReport() {
-       this.select             = [];
-       this.from               = {};
-       this.where              = [];
-       this.params             = {};
+       this.def = {
+               select  : [],
+               from            : {},
+               where           : []
+       };
+       this.params     = {};
+       this.name       = ""
 }
 
 oilsReport.prototype.toString = function() {
index d6942cb..3ce92b4 100644 (file)
@@ -1,3 +1,18 @@
+function oilsInitReportBuilder() {
+       oilsInitReports();
+       oilsRpt = new oilsReport();
+       oilsRptDisplaySelector  = $('oils_rpt_display_selector');
+       oilsRptFilterSelector   = $('oils_rpt_filter_selector');
+       oilsDrawRptTree(
+               function() { 
+                       hideMe($('oils_rpt_tree_loading')); 
+                       unHideMe($('oils_rpt_table')); 
+               }
+       );
+}
+
+
+
 function oilsRptSplitPath(path) {
        var parts = path.split(/-/);
        var column = parts.pop();
@@ -30,7 +45,9 @@ function oilsAddRptDisplayItem(val, name) {
        /* add the selected columns to the report output */
        var splitp = oilsRptSplitPath(val);
        name = (name) ? name : splitp[1];
-       oilsRpt.select.push( {relation:splitp[0], column:splitp[1], alias:name} );
+       var param = oilsRptNextParam();
+       oilsRpt.def.select.push( {relation:splitp[0], column:splitp[1], alias:param} );
+       oilsRpt.params[param] = name;
        oilsRptDebug();
 }
 
@@ -44,18 +61,21 @@ function oilsDelSelectedDisplayItems() {
        var list = oilsDelSelectedItems(oilsRptDisplaySelector);
 
        /* remove the de-selected columns from the report output */
-       oilsRpt.select = grep( oilsRpt.select, 
+       oilsRpt.def.select = grep( oilsRpt.def.select, 
                function(i) {
                        for( var j = 0; j < list.length; j++ ) {
                                var d = list[j];
                                var arr = oilsRptSplitPath(d);
-                               _debug(arr);
-                               if( arr[0] == i.relation && arr[1] == i.column ) return false;
+                               if( arr[0] == i.relation && arr[1] == i.column ) {
+                                       var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
+                                       if( param ) delete oilsRpt.params[param];
+                                       return false;
+                               }
                        }
                        return true;
                }
        );
-       if(!oilsRpt.select) oilsRpt.select = [];
+       if(!oilsRpt.def.select) oilsRpt.def.select = [];
        oilsRptDebug();
 }
 
@@ -118,6 +138,10 @@ function oilsRptHideEditorDivs() {
 }
 
 
+/**
+  This draws the 3-tabbed window containing the transform,
+  filter, and aggregate filter picker window
+  */
 function oilsRptDrawDataWindow(path) {
 
        var parts = path.split(/-/);
@@ -140,7 +164,6 @@ function oilsRptDrawDataWindow(path) {
        /* focus after all the shifting to make sure the div is at least visible */
        $('oils_rpt_tform_label_input').focus();
 
-
        /* give the tab links behavior */
        $('oils_rpt_tform_tab').onclick = 
                function(){oilsRptHideEditorDivs();unHideMe($('oils_rpt_tform_div'))};
@@ -151,6 +174,7 @@ function oilsRptDrawDataWindow(path) {
 }
 
 
+/* draws the transform window */
 function oilsRptDrawTransformWindow(path, col, cls, field) {
        appendClear($('oils_rpt_tform_label'), text(oilsRptMakeLabel(path)));
        $('oils_rpt_tform_label_input').value = oilsRptMakeLabel(path);
index 74da54e..afd2af8 100644 (file)
@@ -42,7 +42,7 @@
 
        </head>
 
-       <body onload='oilsInitReports();' onunload='oilsCleanupReports();'>
+       <body onload='oilsInitReportBuilder();' onunload='oilsCleanupReports();'>
 
                <div class='welcome_box'>
                        <span>You are logged in as </span><b><span id='oils_rpt_user'/></b>
                        <tbody>
                                <tr>
                                        <td id='oils_rpt_table_left_td' align='left'>
+                                               <div id='oils_rpt_name_div'>
+                                                       <span style='padding-right: 10px;'>Report Name: </span>
+                                                       <input size='32' onchange="oilsRpt.name=this.value"/>
+                                               </div>
                                                <div id='oils_rpt_tree_div'>
                                                </div>
                                        </td>
                                                <div class='oils_rpt_info_div'>
                                                        <div class='oils_rpt_info_item oils_rpt_info_title'>Report Display Items</div>
                                                        <select id='oils_rpt_display_selector' class='oils_rpt_info_item oils_rpt_info_selector' multiple='multiple'/>
-                                                       <button onclick='oilsDelSelectedDisplayItems();'><u>X</u> Remove Selected Values</button>
+                                                       <button onclick='oilsDelSelectedDisplayItems();'><u>X</u> Remove Selected</button>
                                                </div>
                                                <div class='oils_rpt_info_div'>
                                                        <div class='oils_rpt_info_item oils_rpt_info_title'>Report Filters</div>
                                                        <select id='oils_rpt_filter_selector' class='oils_rpt_info_item oils_rpt_info_selector' multiple='multiple'/>
-                                                       <button onclick='oilsDelSelectedFilterItems();'><u>X</u> Remove Selected Filters</button>
+                                                       <button onclick='oilsDelSelectedFilterItems();'><u>X</u> Remove Selected</button>
                                                </div>
                                        </td>   
                                </tr>
@@ -86,7 +90,8 @@
                        </tr></tbody></table>
 
                        <div id='oils_rpt_tform_div'>
-                               <b style='padding-right: 10px;' id='oils_rpt_tform_label'/>&nbsp;&nbsp;&nbsp;<input id='oils_rpt_tform_label_input'/>
+                               <b style='padding-right: 15px;' id='oils_rpt_tform_label'/>
+                               <input size='28' id='oils_rpt_tform_label_input'/>
                                <br/><br/>
                                <button id='oils_rpt_tform_submit'>Add Item</button>
                        </div>
index bd6c083..b913cee 100644 (file)
@@ -29,10 +29,10 @@ function oilsParseRptTree(IDL, callback) {
 
                var obj = { 
                        fields  : oilsRptParseFields(node),
-                       table           : node.getAttribute('oils_persist:tablename'),
                        name            : node.getAttribute('id'),
-                       core            : node.getAttribute('reporter:core'),
-                       label           : node.getAttribute('reporter:label')
+                       table           : node.getAttributeNS(oilsIDLPersistNS, 'tablename'),
+                       core            : node.getAttributeNS(oilsIDLReportsNS, 'core'),
+                       label           : node.getAttributeNS(oilsIDLReportsNS, 'label')
                };
 
                if( obj.core == 'true' ) obj.core = true;
@@ -65,7 +65,7 @@ function oilsRptParseFields( node ) {
                var obj = {
                        field : fields[i],
                        name    : name,
-                       label : field.getAttribute('reporter:label'),
+                       label : field.getAttributeNS(oilsIDLReportsNS,'label'),
                        type    : 'field'
                }
 
@@ -83,7 +83,7 @@ function oilsRptParseFields( node ) {
                        obj.key = link.getAttribute('key');
                        obj['class'] = link.getAttribute('class');
                } else {
-                       if( fields[i].getAttribute('oils_persist:virtual') == 'true' ) 
+                       if( fields[i].getAttributeNS(oilsIDLPersistNS, 'virtual') == 'true' ) 
                                continue;
                }
 
index 9322536..d5bcb31 100644 (file)
@@ -1,8 +1,13 @@
 var oilsRptID = 0;
+var oilsRptID2 = 0;
 function oilsNextId() {
        return 'oils_'+ (oilsRptID++);
 }
 
+function oilsRptNextParam() {
+       return '::PARAM'+ (oilsRptID2++);
+}
+
 function nodeText(id) {
        if($(id))
                return $(id).innerHTML;
index 7e58594..f4e4979 100644 (file)
@@ -27,3 +27,6 @@ var oilsMouseX;
 var oilsMouseY;
 var oilsPageXMid;
 var oilsPageYMid;
+
+var oilsIDLReportsNS = 'http://open-ils.org/spec/opensrf/IDL/reporter/v1';
+var oilsIDLPersistNS = 'http://open-ils.org/spec/opensrf/IDL/persistance/v1';