From 2f2859c083d25c3384931267ed756722c2a639fc Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 7 Aug 2014 13:16:36 -0400 Subject: [PATCH] LP#1329503 propagate 'in list' values for editing For example, ensure a previously selected list of copy locations are propagated into the selected values list during report editing. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier Signed-off-by: Ben Shum --- Open-ILS/web/reports/oils_rpt_param_editor.js | 1 + .../web/reports/oils_rpt_report_editor.js | 2 +- Open-ILS/web/reports/oils_rpt_widget.js | 43 ++++++++++++++++--- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/reports/oils_rpt_param_editor.js b/Open-ILS/web/reports/oils_rpt_param_editor.js index 40acd1bd06..e66a986ca0 100644 --- a/Open-ILS/web/reports/oils_rpt_param_editor.js +++ b/Open-ILS/web/reports/oils_rpt_param_editor.js @@ -178,6 +178,7 @@ oilsRptParamEditor.prototype.buildWidget = function(param, node, fromTemplate) { widgetArgs.class = cls; widgetArgs.field = field; widgetArgs.column = param.column.colname; + widgetArgs.async = true; } switch(cls) { diff --git a/Open-ILS/web/reports/oils_rpt_report_editor.js b/Open-ILS/web/reports/oils_rpt_report_editor.js index 4cbebcf813..5bc5e89ef9 100644 --- a/Open-ILS/web/reports/oils_rpt_report_editor.js +++ b/Open-ILS/web/reports/oils_rpt_report_editor.js @@ -122,7 +122,7 @@ oils_rpt_editor_pivot_data DOM.oils_rpt_format_html.checked = run.html_format() == 't'; DOM.oils_rpt_format_chart_bar.checked = run.chart_bar() == 't'; DOM.oils_rpt_format_chart_line.checked = run.chart_line() == 't'; - DOM.oils_rpt_param_editor_sched_email = run.email(); + DOM.oils_rpt_param_editor_sched_email.value = run.email(); if (run.run_time()) { DOM.oils_rpt_report_editor_schedule.checked = true; diff --git a/Open-ILS/web/reports/oils_rpt_widget.js b/Open-ILS/web/reports/oils_rpt_widget.js index f4f5263c45..2d617ef49d 100644 --- a/Open-ILS/web/reports/oils_rpt_widget.js +++ b/Open-ILS/web/reports/oils_rpt_widget.js @@ -4,8 +4,10 @@ --------------------------------------------------------------------- */ function oilsRptSetWidget(args) { this.node = args.node; + this.seedValue = args.value; this.inputWidget = new args.inputWidget(args); this.readonly = Boolean(args.readonly); + this.asyncInput = args.async; this.dest = elem('select', {multiple:'multiple','class':'oils_rpt_small_info_selector'}); this.dest.disabled = this.readonly; @@ -26,16 +28,23 @@ oilsRptSetWidget.prototype.draw = function() { this.delButton.onclick = function(){obj.removeSelected()}; removeChildren(this.node); - this.inputWidget.draw(); + + var this_ = this; + var post_draw = function() { + // propagate the values from the input widget into the our display. + if (this_.inputWidget.seedValue) + this_.addButton.onclick(); + } + + this.inputWidget.draw(post_draw); this.node.appendChild(elem('br')) this.node.appendChild(this.addButton); this.node.appendChild(this.delButton); this.node.appendChild(elem('br')) this.node.appendChild(this.dest); - // propagate the values from the input widget into the our display. - if (this.inputWidget.seedValue) - this.addButton.onclick(); + if (!this.asyncInput) post_draw(); + } oilsRptSetWidget.prototype.addDisplayItems = function(list) { @@ -574,12 +583,13 @@ function oilsRptRemoteWidget(args) { this.class = args.class; this.field = args.field; this.column = args.column; + this.seedValue = args.value; this.source = elem('select', {multiple:'multiple','class':'oils_rpt_small_info_selector'}); this.source.disabled = Boolean(args.readonly); } -oilsRptRemoteWidget.prototype.draw = function() { +oilsRptRemoteWidget.prototype.draw = function(callback) { var orgcol; iterate(oilsIDL[this.class].fields, function(i) { @@ -600,7 +610,20 @@ oilsRptRemoteWidget.prototype.draw = function() { var obj = this; this.node.appendChild(this.source); - req.callback(function(r){obj.render(r.getResultObject())}); + req.callback(function(r){ + // render selects values from seed data if necessary + obj.render(r.getResultObject()); + if (callback) { + // presence of a callback suggests there is a container widget + // (e.g. SetWidget) for tracking our values. Callback lets + // the container extract the selected values, then we deselect + // in the input widget (us) since it's redundant. + callback(); + dojo.forEach(obj.source.options, function(o) { + o.selected = false; + }); + } + }); req.send(); } @@ -618,7 +641,13 @@ oilsRptRemoteWidget.prototype.render = function(objs) { var label = obj[this.field.selector](); var value = obj[this.column](); _debug("inserted remote object "+label + ' : ' + value); - insertSelectorVal(this.source, -1, label, value); + var opt = insertSelectorVal(this.source, -1, label, value); + if (this.seedValue && ( + this.seedValue.indexOf(Number(value)) > -1 + || this.seedValue.indexOf(''+value) > -1 + )) { + opt.selected = true; + } } } -- 2.43.2