more filter work, still need to refactor parts of the delete call
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 1 Oct 2006 14:19:07 +0000 (14:19 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 1 Oct 2006 14:19:07 +0000 (14:19 +0000)
to take operations and transforms into account

git-svn-id: svn://svn.open-ils.org/ILS/trunk@6304 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt.css
Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_ops.xhtml

index f619ac0..4c2d358 100644 (file)
@@ -50,7 +50,7 @@ table { border-collapse: collapse; }
 }
 
 .oils_rpt_info_item {
-       width: 290px;
+       width: 310px;
 }
 
 .oils_rpt_info_title {
@@ -80,7 +80,7 @@ table { border-collapse: collapse; }
 
 .oils_rpt_info_div { 
        text-align: center; 
-       width: 300px; 
+       width: 320px; 
        padding-left: 10px; 
        padding: 10px;
        border-left: 2px solid #E0E0E0; 
index 6426cd4..ce1edf1 100644 (file)
@@ -193,10 +193,26 @@ function oilsRptPruneFromClause(relation, node) {
        return false;
 }
 
+function oilsRptFilterName(path, tform, filter) {
+}
+
 /* adds an item to the display window */
 function oilsAddRptFilterItem(path, tform, filter) {
        _debug("Adding filter item for "+path+" tform="+tform+" filter="+filter);
-       if( ! oilsAddSelectorItem(oilsRptFilterSelector, path) )
+
+       var name = oilsRptMakeLabel(path);
+       if(tform) name += ' ('+tform+')';
+       name += ' "' + filter + '"';
+
+       var epath = path + ':'+filter+':';
+       if(tform) epath += tform;
+
+       /*
+       if( ! oilsAddSelectorItem(oilsRptFilterSelector, path, name) )
+               return;
+               */
+
+       if( ! oilsAddSelectorItem(oilsRptFilterSelector, epath, name) )
                return;
 
        var where = {
@@ -206,6 +222,10 @@ function oilsAddRptFilterItem(path, tform, filter) {
        };
        where.condition[filter] = oilsRptNextParam();
 
+       switch(tform) {
+               case 'substring' : where.column.params = oilsRptNextParam();
+       }
+
        oilsRpt.def.where.push(where);
        mergeObjects( oilsRpt.def.from, oilsRptBuildFromClause(path));
        oilsRptDebug();
@@ -218,8 +238,26 @@ function oilsAddRptFilterItem(path, tform, filter) {
 
 /* removes selected items from the display window */
 function oilsDelSelectedFilterItems() {
+
+       /* the values in this list are formed:  <path>:<operation>:<tform (optional)> */
        var list = oilsDelSelectedItems(oilsRptFilterSelector);
 
+       var flist = [];
+
+       for( var i = 0; i < list.length; i++ ) {
+               var item = list[i];
+               flist.push( {
+                       path:           item.replace(/:.*/,''),
+                       filter: item.replace(/.*:(.*):.*/,'$1'),
+                       tform:  item.replace(/.*?:.*?:(.*)/,'$1')
+               });
+       }
+
+
+       /* XXX refactor the below to take operation and transform into account
+               since the same path can be used multiple times as long as a different
+               filter and/or transform is used */
+
        /* remove the de-selected columns from the report output */
        oilsRpt.def.where = grep( oilsRpt.def.where, 
                function(i) {
@@ -420,9 +458,30 @@ function oilsRptSetDataWindowActions(div) {
 
 
 function oilsRptDrawFilterWindow(path, col, cls, field) {
+
+       var fsel = $n(DOM.oils_rpt_filter_op_table,'selector');
+       for( var i = 0; i < fsel.options.length; i++ ){
+               var opt = fsel.options[i];
+               var dt = opt.getAttribute('datatype');
+               _debug(dt);
+
+               /* add a special case for boolean objects, since the only 
+                       operation that makes sense is "="  */
+               if( field.datatype == 'bool' ) {
+                       hideMe(opt);
+                       if( opt.getAttribute('value') == '=' )
+                               unHideMe(opt);
+
+               } else {
+                       if( dt && dt != field.datatype )
+                               hideMe(opt);
+                       else unHideMe(opt);
+               }
+       }
+
+
        DOM.oils_rpt_filter_submit.onclick = function() {
                var tsel = $n(DOM.oils_rpt_filter_tform_table,'selector');
-               var fsel = $n(DOM.oils_rpt_filter_op_table,'selector');
                var tform = getSelectorVal(tsel);
                var filter = getSelectorVal(fsel);
                oilsAddRptFilterItem(path, tform, filter);
index 1f40ed8..454fb80 100644 (file)
                                        <option value='&gt;='>Greater than or equal to</option>
                                        <option value='&lt;'>Less than</option>
                                        <option value='&lt;='>Less than or equal to</option>
-                                       <option value='&gt;'>After (Date/Time)</option>
-                                       <option value='&gt;='>On or After (Date/Time)</option>
-                                       <option value='&lt;'>Before (Date/Time)</option>
-                                       <option value='&lt;='>On or Before (Date/Time)</option>
+                                       <option value='&gt;' datatype='timestamp'>After (Date/Time)</option>
+                                       <option value='&gt;=' datatype='timestamp'>On or After (Date/Time)</option>
+                                       <option value='&lt;' datatype='timestamp'>Before (Date/Time)</option>
+                                       <option value='&lt;=' datatype='timestamp'>On or Before (Date/Time)</option>
                                        <option value='in'>In (comma separated list)</option>
                                        <option value='not in'>Not in (comma separated list)</option>
                                        <option value='between'>Between</option>