fixed infinit loop for apps running in iframe by refactoring frameworked templates work with client-side api:

- moved shared etemplate2 part into static etemplate2.app_refresh() method
- egw_message.refresh() calls framework.refresh() which can return a DOMwindow for egw.refresh() to work on, instead of calling egw.refresh recursive
This commit is contained in:
Ralf Becker 2014-05-23 08:21:11 +00:00
parent ae3e4cedfd
commit 24ee68bdf2
2 changed files with 34 additions and 20 deletions

View File

@ -729,13 +729,13 @@ etemplate2.prototype.getValues = function(_root)
* If there's a message provided, we try to find where it goes and set it directly. Then
* we look for a nextmatch widget, and tell it to refresh its data based on that ID.
*
* @see egw_message.refresh()
*
* @param {string} msg message to try to display. eg: "Entry added" (not used anymore, handeled by egw_refresh and egw_message)
* @param {string} app app-name
* @param {(string|null)} id application specific entry ID to try to refresh
* @param {(string|null)} type type of change. One of 'update','edit', 'delete', 'add' or null
*
* @see jsapi.egw_refresh()
* @see egw_fw.egw_refresh()
* @return {boolean} true if nextmatch found and refreshed, false if not
*/
etemplate2.prototype.refresh = function(msg, app, id, type)
{
@ -752,6 +752,28 @@ etemplate2.prototype.refresh = function(msg, app, id, type)
return refresh_done;
};
/**
* "Intelligently" refresh a given app
*
* @see egw_message.refresh()
*
* @param {string} _msg message to try to display. eg: "Entry added" (not used anymore, handeled by egw_refresh and egw_message)
* @param {string} _app app-name
* @param {(string|null)} _id application specific entry ID to try to refresh
* @param {(string|null)} _type type of change. One of 'update','edit', 'delete', 'add' or null
* @return {boolean} true if nextmatch found and refreshed, false if not
*/
etemplate2.app_refresh = function(_msg, _app, _id, _type)
{
var refresh_done = false;
var et2 = etemplate2.getByApplication(_app);
for(var i = 0; i < et2.length; i++)
{
refresh_done = et2[i].refresh(_msg,_app,_id,_type) || refresh_done;
}
return refresh_done;
};
// Some static things to make getting into widget context a little easier //
/**

View File

@ -203,10 +203,10 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
}
if (no_regular_refresh) return;
// if we have a framework, let it deal with refresh
if (win.framework && win.framework.refresh)
// if we have a framework template, let it deal with refresh, unless it returns a DOMwindow for us to refresh
if (win.framework && win.framework.refresh &&
!(win = win.framework.refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)))
{
win.framework.refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
return;
}
@ -219,28 +219,20 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
}
// etemplate2 specific to avoid reloading whole page
if(typeof etemplate2 != "undefined" && etemplate2.getByApplication)
if(typeof etemplate2 != "undefined" && etemplate2.app_refresh)
{
var refresh_done = false;
var et2 = etemplate2.getByApplication(_app);
for(var i = 0; i < et2.length; i++)
{
refresh_done = et2[i].refresh(_msg,_app,_id,_type);
}
var refresh_done = etemplate2.app_refresh(_msg, _app, _id, _type);
// Refresh target or current app too
if ((_targetapp || egw_appName) != _app)
if ((_targetapp || this.app_name()) != _app)
{
var et2t = etemplate2.getByApplication(_targetapp || egw_appName);
for(var i = 0; i < et2t.length; i++)
{
refresh_done = et2t[i].refresh(_msg,_app,_id,_type);
}
refresh_done = etemplate2.app_refresh(_msg, _targetapp || this.app_name()) || refresh_done;
}
//In case that we have etemplate2 ready but it's empty and refresh is not done
if (et2.length >= 1 && refresh_done) return;
if (refresh_done) return;
}
// fallback refresh by reloading window
var href = win.location.href;
if (typeof _replace != 'undefined')