From ccfa98ff9f74e5c5bfce0f838f9e56f53e687603 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 28 Dec 2010 03:02:49 +0000 Subject: [PATCH] new method to refresh an egroupware applications view, with the possibility for the application to overwrite the default handing of reloading everything --- phpgwapi/js/jsapi/jsapi.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/phpgwapi/js/jsapi/jsapi.js b/phpgwapi/js/jsapi/jsapi.js index 1176b7ad1c..be3d8b928c 100644 --- a/phpgwapi/js/jsapi/jsapi.js +++ b/phpgwapi/js/jsapi/jsapi.js @@ -114,6 +114,41 @@ function egw_appWindow(_app) return window; } +/** + * Refresh given application _app display of entry _id, incl. outputting _msg + * + * Default implementation here only reloads window with it's current url with an added msg=_msg attached + * + * @param string _msg message (already translated) to show, eg. 'Entry deleted' + * @param string _app application name + * @param string|int _id=null id of entry to refresh + * @param _type=null either 'edit', 'delete', 'add' or null + */ +function egw_refresh(_msg, _app, _id, _type) +{ + //alert("egw_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')"); + var win = egw_appWindow(_app); + + // if window defines an app_refresh method, just call it + if (typeof win.app_refresh != 'undefined') + { + win.app_refresh(_msg, _app, _id, _type); + return; + } + var href = win.location.href; + + if (href.indexOf('msg=') != -1) + { + href.replace(/msg=[^&]*/,'msg='+encodeURIComponent(_msg)); + } + else if (_msg) + { + href += (href.indexOf('?') != -1 ? '&' : '?') + 'msg=' + encodeURIComponent(_msg); + } + //alert('egw_refresh() about to call '+href); + win.location.href = href; +} + window.egw_getFramework = function() { if (typeof window.framework != 'undefined')