added support for grabbing the pre-defined template params and dislpaying the values...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Apr 2007 19:40:16 +0000 (19:40 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Apr 2007 19:40:16 +0000 (19:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7178 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt.js
Open-ILS/web/reports/oils_rpt_param_editor.js
Open-ILS/web/reports/oils_rpt_widget.js

index 223bd20..ee5b540 100644 (file)
@@ -142,4 +142,43 @@ oilsReport.prototype._gatherParams = function(params, arr, type, field) {
 
 
 
+oilsReport.prototype.gatherTemplateParams = function() {
+    var arr = this.__gatherTemplateParams(this.def.where, 'where');
+    arr.concat(this.__gatherTemplateParams(this.def.having, 'having'));
+    _debug("template params: " + js2JSON(arr));
+    return arr;
+}
+
+oilsReport.prototype.__gatherTemplateParams = function(arr, type) {
+
+    if(!arr) return [];
+    var params = [];
+
+       for( var i = 0; i < arr.length; i++ ) {
+
+               var obj = arr[i];
+               var node = obj.condition;
+           var op = oilsRptObjectKeys(node)[0];
+               var key = node[op];
+
+        /** if this is a dynamic param, skip it */
+        if( key && key.match(/::.*/) ) continue;
+
+               _debug("template params: op = " + op + ", value = " + js2JSON(key));
+
+               params.push( { 
+                       key             : key, /* key == value, since this is not a dynamic param */
+                       op              : op,
+            value   : key,
+                       column  : obj.column,
+                       path    : obj.path,
+                       type    : type, 
+                       relation : obj.relation,
+                       field   : field
+               });
+       }
+
+    return params;
+}
+
 
index d56d24d..ef7639e 100644 (file)
@@ -43,6 +43,21 @@ oilsRptParamEditor.prototype.draw = function() {
                par.widget = this.buildWidget(par, $n(row, 'widget'));
                par.widget.draw();
        }
+
+    /** draw the pre-defined template params so the user will know
+        what params are already set */
+    var tparams = this.report.gatherTemplateParams();
+
+       for( var p = 0; p < params.length; p++ ) {
+               var par = tparams[p];
+               var row = oilsRptParamEditor.row.cloneNode(true);
+               this.tbody.appendChild(row);
+               $n(row, 'column').appendChild(text(oilsRptMakeLabel(par.path)));
+               $n(row, 'transform').appendChild(text(OILS_RPT_TRANSFORMS[par.column.transform].label));
+               $n(row, 'action').appendChild(text(OILS_RPT_FILTERS[par.op].label));
+               par.widget = this.buildWidget(par, $n(row, 'widget'));
+               par.widget.draw();
+       }
 }
 
 oilsRptParamEditor.prototype.buildWidget = function(param, node) {
@@ -173,6 +188,9 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node) {
                case 'not in':
                        widgetArgs.inputWidget = atomicWidget;
                        return new oilsRptSetWidget(widgetArgs);
+        case 'is':
+        case 'is not':
+            return new oilsRptNullWidget(widgetArgs);
                case 'between':
                case 'not between':
                        widgetArgs.startWidget = atomicWidget;
index 18d3e99..7b19f43 100644 (file)
@@ -401,6 +401,19 @@ oilsRptNumberWidget.prototype.getDisplayValue = function() {
 /* --------------------------------------------------------------------- 
        Relative dates widget
        --------------------------------------------------------------------- */
+
+function oilsRptNullWidget(args) {
+    this.node = args.node;
+    this.type = args.type;
+}
+oilsRptNullWidget.prototype.draw = function() {}
+oilsRptNullWidget.prototype.getValue = function() {
+    return null;
+}
+
+/* --------------------------------------------------------------------- 
+       Relative dates widget
+       --------------------------------------------------------------------- */
 function oilsRptTruncPicker(args) {
        this.node = args.node;
        this.type = args.type;