From 04a845fa357f5948f5c707fa6b169b4d2f6d443c Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Sat, 11 Jan 2014 11:53:23 +0000 Subject: [PATCH] Enhance refreshItem() to optionally take the data needed for refreshing to avoid an extra call to the server --- etemplate/js/et2_widget_tree.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_widget_tree.js b/etemplate/js/et2_widget_tree.js index 339da9f235..7cfa086511 100644 --- a/etemplate/js/et2_widget_tree.js +++ b/etemplate/js/et2_widget_tree.js @@ -450,10 +450,12 @@ var et2_tree = et2_inputWidget.extend( * Updates a leaf of the tree by requesting new information from the server using the * autoloading attribute. * - * @param _id ID of the node + * @param {string} _id ID of the node + * @param {Object} [data] If provided, the item is refreshed directly with + * the provided data instead of asking the server * @return void */ - refreshItem: function(_id) { + refreshItem: function(_id,data) { if(this.input == null) return null; this.input.deleteChildItems(_id); this.input.setDataMode('JSON'); @@ -463,9 +465,18 @@ var et2_tree = et2_inputWidget.extend( */ var self = this; - this.input.loadJSON(this.egw().link(this.autoloading_url, {id: _id}), - function() { self._dhtmlxtree_json_callback(JSON.parse(this.response), _id);} - ); + if(typeof data != 'undefined' && data != null) + { + this.input.loadJSONObject(data, + function() { self._dhtmlxtree_json_callback(data, _id);} + ); + } + else + { + this.input.loadJSON(this.egw().link(this.autoloading_url, {id: _id}), + function() { self._dhtmlxtree_json_callback(JSON.parse(this.response), _id);} + ); + } }, /**