to give observer method of other apps more information about what to refresh, server-side adds now links to refresh-opener and therefore observer calls

This commit is contained in:
Ralf Becker 2014-05-26 13:29:35 +00:00
parent b1603f4fd3
commit 28b45639be
3 changed files with 28 additions and 5 deletions

View File

@ -251,6 +251,10 @@ abstract class egw_framework
*
* Calling egw_refresh and egw_message on opener in a content security save way
*
* To provide more information about necessary refresh an automatic 9th parameter is added
* containing an object with application-name as attributes containing an array of linked ids
* (adding happens in get_extras to give apps time to link new entries!).
*
* @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
@ -346,6 +350,22 @@ abstract class egw_framework
*/
public static function get_extra()
{
// adding links of refreshed entry, to give others apps more information about necessity to refresh
if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 && // do not run twice
!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2])) // app/id given
{
$links = egw_link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
$apps = array();
foreach($links as $link)
{
$apps[$link['app']][] = $link['id'];
}
while (count(self::$extra['refresh-opener']) < 8)
{
self::$extra['refresh-opener'][] = null;
}
self::$extra['refresh-opener'][] = $apps;
}
return self::$extra;
}

View File

@ -157,10 +157,11 @@ var AppJS = Class.extend(
* - delete: just delete the given rows clientside (no server interaction neccessary)
* - add: requires full reload for proper sorting
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
* @param {string} _targetapp which app's window should be refreshed, default current
* @param {object|null} _links app => array of ids of linked entries
* or null, if not triggered on server-side, which adds that info
* @return {false|*} false to stop regular refresh, thought all observers are run
*/
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
observer: function(_msg, _app, _id, _type, _msg_type, _links)
{
},

View File

@ -207,8 +207,10 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* @param {(string|RegExp)} _replace regular expression to replace in url
* @param {string} _with
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
* @param {object|null} _links app => array of ids of linked entries
* or null, if not triggered on server-side, which adds that info
*/
refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type, _links)
{
// Log for debugging purposes
this.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)", _msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
@ -224,7 +226,7 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
{
var app_obj = _wnd.egw.window.app[app];
if (typeof app_obj.observer == 'function' &&
app_obj.observer(_msg, _app, _id, _type, _msg_type, _targetapp) === false && app === _app)
app_obj.observer(_msg, _app, _id, _type, _msg_type, _links) === false && app === _app)
{
no_regular_refresh = true;
}