tranform and ui updates
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 30 Sep 2006 00:19:13 +0000 (00:19 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 30 Sep 2006 00:19:13 +0000 (00:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6276 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_builder.xhtml
Open-ILS/web/reports/oils_rpt_tforms.xhtml
Open-ILS/web/reports/oils_rpt_vars.js

index 9cffb31..b5a32bf 100644 (file)
@@ -21,8 +21,10 @@ function oilsReportBuilderReset() {
        oilsRpt.name = n;
        oilsRptDisplaySelector  = DOM.oils_rpt_display_selector;
        oilsRptFilterSelector   = DOM.oils_rpt_filter_selector;
+       oilsRptAggFilterSelector= DOM.oils_rpt_agg_filter_selector;
        removeChildren(oilsRptDisplaySelector);
        removeChildren(oilsRptFilterSelector);
+       removeChildren(oilsRptAggFilterSelector);
        oilsRptDebug();
        oilsRptResetParams();
 }
@@ -174,11 +176,15 @@ function oilsDelSelectedDisplayItems() {
 
        } else {
                for( var j = 0; j < list.length; j++ ) 
-                       /* if there are no items left in the "select" clause for the given 
-                               relation, trim this relation from the "from" clause */
-                       if(!grep(oilsRpt.def.select,
-                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })) 
-                               oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+                       /* if there are no items left in the "select", "where", or "having" clauses 
+                               for the given relation, trim this relation from the "from" clause */
+                       if(     !grep(oilsRpt.def.select,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.where,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.having,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                       ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
        }
 
        oilsRptDebug();
@@ -229,7 +235,112 @@ function oilsDelFilterItem(val) {
 
 /* removes selected items from the display window */
 function oilsDelSelectedFilterItems() {
-       oilsDelSelectedItems(oilsRptFilterSelector);
+       var list = oilsDelSelectedItems(oilsRptFilterSelector);
+
+       /* remove the de-selected columns from the report output */
+       oilsRpt.def.where = grep( oilsRpt.def.where, 
+               function(i) {
+                       for( var j = 0; j < list.length; j++ ) {
+                               var d = list[j];
+                               var col = i.column;
+
+                               /* if this columsn has a transform, 
+                                       it will be an object { tform => column } */
+                               if( typeof col != 'string' ) 
+                                       for( var c in col ) col = col[c];
+
+                               /* if this transform requires params, the column 
+                                       will be the first item in the param set array */
+                               if( typeof col != 'string' ) col = col[0];
+
+                               if( oilsRptPathRel(d) == i.relation && oilsRptPathCol(d) == col ) {
+                                       var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
+                                       if( param ) delete oilsRpt.params[param];
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+       );
+
+       if(!oilsRpt.def.where) {
+               oilsRpt.def.where = [];
+               oilsReportBuilderReset();
+
+       } else {
+               for( var j = 0; j < list.length; j++ ) 
+                       /* if there are no items left in the "select", "where", or "having" clauses 
+                               for the given relation, trim this relation from the "from" clause */
+                       if(     !grep(oilsRpt.def.select,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.where,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.having,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                       ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+       }
+
+       oilsRptDebug();
+}
+
+/* adds an item to the display window */
+function oilsAddRptAggFilterItem(val) {
+       oilsAddSelectorItem(oilsRptAggFilterSelector, val);
+}
+
+/* removes a specific item from the display window */
+function oilsDelAggFilterItem(val) {
+       oilsDelSelectorItem(oilsRptAggFilterSelector, val);
+}
+
+/* removes selected items from the display window */
+function oilsDelSelectedAggFilterItems() {
+       var list = oilsDelSelectedItems(oilsRptAggFilterSelector);
+
+       /* remove the de-selected columns from the report output */
+       oilsRpt.def.having = grep( oilsRpt.def.having, 
+               function(i) {
+                       for( var j = 0; j < list.length; j++ ) {
+                               var d = list[j];
+                               var col = i.column;
+
+                               /* if this columsn has a transform, 
+                                       it will be an object { tform => column } */
+                               if( typeof col != 'string' ) 
+                                       for( var c in col ) col = col[c];
+
+                               /* if this transform requires params, the column 
+                                       will be the first item in the param set array */
+                               if( typeof col != 'string' ) col = col[0];
+
+                               if( oilsRptPathRel(d) == i.relation && oilsRptPathCol(d) == col ) {
+                                       var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
+                                       if( param ) delete oilsRpt.params[param];
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+       );
+
+       if(!oilsRpt.def.having) {
+               oilsRpt.def.having = [];
+               oilsReportBuilderReset();
+
+       } else {
+               for( var j = 0; j < list.length; j++ ) 
+                       /* if there are no items left in the "select", "where", or "having" clauses 
+                               for the given relation, trim this relation from the "from" clause */
+                       if(     !grep(oilsRpt.def.select,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.where,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                               && !grep(oilsRpt.def.having,
+                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+                       ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+       }
+
+       oilsRptDebug();
 }
 
 
index ae3c4ec..d3ca310 100644 (file)
                                                        <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</button>
                                                </div>
+                                               <div class='oils_rpt_info_div'>
+                                                       <div class='oils_rpt_info_item oils_rpt_info_title'>Report Aggregate Filters</div>
+                                                       <select id='oils_rpt_agg_filter_selector' class='oils_rpt_info_item oils_rpt_info_selector' multiple='multiple'/>
+                                                       <button onclick='oilsDelSelectedAggFilterItems();'><u>X</u> Remove Selected</button>
+                                               </div>
                                        </td>   
                                </tr>
                        </tbody>
index 1febaf7..615ddf5 100644 (file)
@@ -7,17 +7,23 @@
                                
                                        <!-- generic transforms -->
                                        <option value='Bare' selected='selected'>Raw Data</option>
-                                       <option value='count' aggregate='1'>Count</option>
-                                       <option value='count distinct' aggregate='1'>Count Distinct</option>
-                                       <option value='min' aggregate='1'>Min</option>
-                                       <option value='max' aggregate='1'>Max</option>
+                                       <option value='first'>First Value</option>
+                                       <option value='last'>Last Value</option>
                                        
                                        <!-- string transforms -->
+                                       <option value='count' datatype='string' aggregate='1'>Count</option>
+                                       <option value='count_distinct' datatype='string' aggregate='1'>Count Distinct</option>
+                                       <option value='min' datatype='string' aggregate='1'>Min</option>
+                                       <option value='max' datatype='string' aggregate='1'>Max</option>
                                        <option value='substring' datatype='string' widget='string_substring_widget' >Substring</option>
                                        <option value='lower' datatype='string'>Lower case</option>
                                        <option value='upper' datatype='string'>Upper Case</option>
                                        
                                        <!-- timestamp transforms -->
+                                       <option value='count' datatype='timestamp' aggregate='1'>Count</option>
+                                       <option value='count_distinct' datatype='timestamp' aggregate='1'>Count Distinct</option>
+                                       <option value='min' datatype='timestamp' aggregate='1'>Min</option>
+                                       <option value='max' datatype='timestamp' aggregate='1'>Max</option>
                                        <option value='dow' datatype='timestamp'>Day of Week</option>
                                        <option value='dom' datatype='timestamp'>Day of Month</option>
                                        <option value='doy' datatype='timestamp'>Day of Year</option>
                                        <option value='day_name' datatype='timestamp'>Day Name</option>
                                        <option value='month_name' datatype='timestamp'>Month Name</option>
                                        
-                                       <!-- numeric transforms -->
-                                       <option value='round' datatype='numeric' >Round</option>
-                                       <option value='int' datatype='numeric' >Drop trailing decimals</option>
+                                       <!-- int transforms -->
+                                       <option value='count' datatype='int' aggregate='1'>Count</option>
+                                       <option value='count_distinct' datatype='int' aggregate='1'>Count</option>
+                                       <option value='min' datatype='int' aggregate='1'>Min</option>
+                                       <option value='max' datatype='int' aggregate='1'>Max</option>
+                                       <option value='sum' datatype='int' aggregate='1'>Sum</option>
+                                       <option value='average' datatype='int' aggregate='1'>Average</option>
+
+                                       <!-- float transforms -->
+                                       <option value='count' datatype='float' aggregate='1'>Count</option>
+                                       <option value='count_distinct' datatype='float' aggregate='1'>Count</option>
+                                       <option value='min' datatype='float' aggregate='1'>Min</option>
+                                       <option value='max' datatype='float' aggregate='1'>Max</option>
+                                       <option value='sum' datatype='float' aggregate='1'>Sum</option>
+                                       <option value='average' datatype='int' aggregate='1'>Average</option>
+                                       <option value='round' datatype='float' >Round</option>
+                                       <option value='int' datatype='float' >Drop trailing decimals</option>
                                </select>
                        </td>
 
index c6f14f7..6cdb090 100644 (file)
@@ -29,6 +29,10 @@ var oilsRptDisplaySelector;
 
 var oilsRptFilterSelector;
 
+var oilsRptAggFilterSelector;
+
+var oilsRptOrderBySelector;
+
 /* display the currently building report object in an external window */
 var oilsRptDebugWindow;
 
@@ -48,9 +52,11 @@ var oilsRptCurrentTform;
 
 /* the current transform manager for the builder filter window */
 var oilsRptCurrentFilterTform;
+var oilsRptCurrentAggFilterTform;
 
 /* the current operation manager for the filter window */
 var oilsRptCurrentFilterOpManager;
+var oilsRptCurrentAggFilterOpManager;
 
 var OILS_RPT_FETCH_FOLDERS                     = 'open-ils.reporter:open-ils.reporter.folder.visible.retrieve';
 var OILS_RPT_FETCH_FOLDER_DATA = 'open-ils.reporter:open-ils.reporter.folder_data.retrieve';