From ab4873553bd22fa6049b460e086c57f26fd4ab75 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 21 Oct 2013 22:23:02 +0000 Subject: [PATCH] - Add in any missing filter/left/right header select options from favorites or other changes instead of rejecting. Server side get_rows is responsible for actually providing the missing option(s) - Propagate changed exec_id to controller --- .../inc/class.etemplate_widget_nextmatch.inc.php | 11 ++++++++++- etemplate/js/et2_dataview_controller.js | 8 +++++++- etemplate/js/et2_extension_nextmatch.js | 14 ++++++++++++++ etemplate/js/et2_extension_nextmatch_controller.js | 8 +++++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index 1efffa8c6c..c56e1c3dac 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -328,7 +328,8 @@ class etemplate_widget_nextmatch extends etemplate_widget // Check for anything changed in the query // Tell the client about the changes $request_value =& self::get_array(self::$request->content, $form_name,true); - $no_rows = false; + $changes = $no_rows = false; + foreach($value_in as $key => $original_value) { // These keys are ignored @@ -341,6 +342,7 @@ class etemplate_widget_nextmatch extends etemplate_widget // These keys we don't send row data back, as they cause a partial reload if(in_array($key, array('template'))) $no_rows = true; + $changes = true; $request_value[$key] = $value[$key]; egw_json_response::get()->generic('assign', array( @@ -350,6 +352,13 @@ class etemplate_widget_nextmatch extends etemplate_widget 'value' => $value[$key], )); } + // Request doesn't handle changing by reference, so force it + if($changes) + { + $content = self::$request->content; + self::$request->content = array(); + self::$request->content = $content; + } if($no_rows) $rows = Array(); $row_id = isset($value['row_id']) ? $value['row_id'] : 'id'; diff --git a/etemplate/js/et2_dataview_controller.js b/etemplate/js/et2_dataview_controller.js index c9d0e31270..c1c0ea8a1b 100644 --- a/etemplate/js/et2_dataview_controller.js +++ b/etemplate/js/et2_dataview_controller.js @@ -125,8 +125,10 @@ var et2_dataview_controller = Class.extend({ * The update function queries the server for changes in the currently * managed index range -- those changes are then merged into the current * view without a complete rebuild of every row. + * + * @param {boolean} clear */ - update: function () { + update: function (clear) { // Clear the fetch queue this._queue = {}; this._clearTimer(); @@ -136,6 +138,10 @@ var et2_dataview_controller = Class.extend({ // TODO: Actually stuff here should be done if the server responds that // there at all were some changes (needs implementation of "refresh") + if(clear) + { + this._grid.clear(); + } // Remove all rows which are outside the view range this._grid.cleanup(); diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 68e9b14e3a..009f442c11 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1834,6 +1834,20 @@ var et2_nextmatch_header_bar = et2_DOMWidget.extend(et2_INextmatchHeader, { value = mgr.getEntry(child.id); if (value == null) value = ''; + /** + * Sometimes a filter value is not in current options. This can + * happen in a saved favorite, for example, or if server changes + * some filter options, and the order doesn't work out. The normal behaviour + * is to warn & not set it, but for nextmatch we'll just add it + * in, and let the server either set it properly, or ignore. + */ + if(value && child.instanceOf(et2_selectbox) && typeof child.options.select_options[value] == 'undefined') + { + var old_options = child.options.select_options; + // Actual label is not available, obviously, or it would be there + old_options[value] = child.egw().lang("Loading"); + child.set_select_options(old_options); + } child.set_value(value); } if(typeof child.get_value == "function" && child.id) diff --git a/etemplate/js/et2_extension_nextmatch_controller.js b/etemplate/js/et2_extension_nextmatch_controller.js index 4dd9f03224..b5dc90a423 100644 --- a/etemplate/js/et2_extension_nextmatch_controller.js +++ b/etemplate/js/et2_extension_nextmatch_controller.js @@ -296,7 +296,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(et2_IDataProvider, // Pass the fetch call to the API, multiplex the data about the // nextmatch instance into the call. this.egw.dataFetch( - this._execId, + this._widget.getInstanceManager().etemplate_exec_id || this._execId, _queriedRange, this._filters, this._widgetId, @@ -305,8 +305,10 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(et2_IDataProvider, }, dataRegisterUID: function (_uid, _callback, _context) { - this.egw.dataRegisterUID(_uid, _callback, _context, this._execId, - this._widgetId); + this.egw.dataRegisterUID(_uid, _callback, _context, + this._widget.getInstanceManager().etemplate_exec_id || this._execId, + this._widgetId + ); }, dataUnregisterUID: function () {