From 65cf3cf25d6ba7bc5c5e14e6e128f99ab0412872 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 27 Apr 2007 19:40:16 +0000 Subject: [PATCH] added support for grabbing the pre-defined template params and dislpaying the values in the report builder interface 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 | 39 +++++++++++++++++++++++++++ Open-ILS/web/reports/oils_rpt_param_editor.js | 18 +++++++++++++ Open-ILS/web/reports/oils_rpt_widget.js | 13 +++++++++ 3 files changed, 70 insertions(+) diff --git a/Open-ILS/web/reports/oils_rpt.js b/Open-ILS/web/reports/oils_rpt.js index 223bd208f2..ee5b5404a6 100644 --- a/Open-ILS/web/reports/oils_rpt.js +++ b/Open-ILS/web/reports/oils_rpt.js @@ -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; +} + diff --git a/Open-ILS/web/reports/oils_rpt_param_editor.js b/Open-ILS/web/reports/oils_rpt_param_editor.js index d56d24de09..ef7639ec10 100644 --- a/Open-ILS/web/reports/oils_rpt_param_editor.js +++ b/Open-ILS/web/reports/oils_rpt_param_editor.js @@ -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; diff --git a/Open-ILS/web/reports/oils_rpt_widget.js b/Open-ILS/web/reports/oils_rpt_widget.js index 18d3e992cf..7b19f4351e 100644 --- a/Open-ILS/web/reports/oils_rpt_widget.js +++ b/Open-ILS/web/reports/oils_rpt_widget.js @@ -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; -- 2.11.0