forked from extern/egroupware
- new app.js observer method which receives update notifications from all apps
- app.infolog.observer triggering refresh of InfoLog list, when a timesheet get stored - moved code of already deprecated egw_refresh() to egw.refresh() and changed etemplate to use that - framework from jdots/pixelegg template no longer overwrites window.egw_refresh, but egw.refresh calls framework.refresh for regular refreshs if framework is present
This commit is contained in:
parent
253bc18f90
commit
893091e286
@ -840,23 +840,25 @@ function etemplate2_handle_load(_type, _response)
|
|||||||
// handle egw_framework::refresh_opener()
|
// handle egw_framework::refresh_opener()
|
||||||
if (jQuery.isArray(data['refresh-opener']))
|
if (jQuery.isArray(data['refresh-opener']))
|
||||||
{
|
{
|
||||||
if (window.opener && typeof window.opener.egw_refresh == 'function')
|
if (window.opener)// && typeof window.opener.egw_refresh == 'function')
|
||||||
{
|
{
|
||||||
window.opener.egw_refresh.apply(window.opener, data['refresh-opener']);
|
var egw = window.egw(opener);
|
||||||
|
egw.refresh.apply(egw, data['refresh-opener']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var egw = window.egw(window);
|
||||||
|
|
||||||
// need to set app_header before message, as message temp. replaces app_header
|
// need to set app_header before message, as message temp. replaces app_header
|
||||||
if (typeof data.data == 'object' && typeof data.data.app_header == 'string')
|
if (typeof data.data == 'object' && typeof data.data.app_header == 'string')
|
||||||
{
|
{
|
||||||
window.egw_app_header(data.data.app_header, data.data.currentapp||null);
|
egw.app_header(data.data.app_header, data.data.currentapp||null);
|
||||||
delete data.data.app_header;
|
delete data.data.app_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle egw_framework::message()
|
// handle egw_framework::message()
|
||||||
if (jQuery.isArray(data.message))
|
if (jQuery.isArray(data.message))
|
||||||
{
|
{
|
||||||
window.egw_message.apply(window, data.message);
|
egw.message.apply(egw, data.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle egw_framework::window_close(), this will terminate execution
|
// handle egw_framework::window_close(), this will terminate execution
|
||||||
|
@ -17,13 +17,6 @@
|
|||||||
app.classes.infolog = AppJS.extend(
|
app.classes.infolog = AppJS.extend(
|
||||||
{
|
{
|
||||||
appname: 'infolog',
|
appname: 'infolog',
|
||||||
/**
|
|
||||||
* et2 widget container
|
|
||||||
*/
|
|
||||||
et2: null,
|
|
||||||
/**
|
|
||||||
* path widget
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -41,7 +34,6 @@ app.classes.infolog = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
destroy: function()
|
destroy: function()
|
||||||
{
|
{
|
||||||
delete this.et2;
|
|
||||||
// call parent
|
// call parent
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
@ -69,8 +61,35 @@ app.classes.infolog = AppJS.extend(
|
|||||||
var that = this;
|
var that = this;
|
||||||
jQuery('#infolog-edit-print').bind('load',function(){that.infolog_print_preview();});
|
jQuery('#infolog-edit-print').bind('load',function(){that.infolog_print_preview();});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observer method receives update notifications from all applications
|
||||||
|
*
|
||||||
|
* InfoLog currently reacts to timesheet updates, as it might show time-sums.
|
||||||
|
* @todo only trigger update, if times are shown
|
||||||
|
*
|
||||||
|
* @param {string} _msg message (already translated) to show, eg. 'Entry deleted'
|
||||||
|
* @param {string} _app application name
|
||||||
|
* @param {(string|number)} _id id of entry to refresh or null
|
||||||
|
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
||||||
|
* - update: request just modified data from given rows. Sorting is not considered,
|
||||||
|
* so if the sort field is changed, the row will not be moved.
|
||||||
|
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
||||||
|
* - 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
|
||||||
|
*/
|
||||||
|
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
|
||||||
|
{
|
||||||
|
switch (_app)
|
||||||
|
{
|
||||||
|
case 'timesheet':
|
||||||
|
var nm = this.et2 ? this.et2.getWidgetById('nm') : null;
|
||||||
|
if (nm) nm.applyFilters();
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +97,6 @@ app.classes.infolog = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
filter_change: function()
|
filter_change: function()
|
||||||
{
|
{
|
||||||
|
|
||||||
var filter = this.et2.getWidgetById('filter');
|
var filter = this.et2.getWidgetById('filter');
|
||||||
var nm = this.et2.getWidgetById('nm');
|
var nm = this.et2.getWidgetById('nm');
|
||||||
if(nm && filter)
|
if(nm && filter)
|
||||||
@ -94,7 +112,6 @@ app.classes.infolog = AppJS.extend(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,7 +183,6 @@ app.classes.infolog = AppJS.extend(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
var confirmDeleteDialog = et2_dialog.show_dialog(callbackDeleteDialog, this.egw.lang("Do you really want to DELETE this Rule"),this.egw.lang("Delete"), {},et2_dialog.BUTTONS_YES_NO_CANCEL, et2_dialog.WARNING_MESSAGE);
|
var confirmDeleteDialog = et2_dialog.show_dialog(callbackDeleteDialog, this.egw.lang("Do you really want to DELETE this Rule"),this.egw.lang("Delete"), {},et2_dialog.BUTTONS_YES_NO_CANCEL, et2_dialog.WARNING_MESSAGE);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -331,13 +347,10 @@ app.classes.infolog = AppJS.extend(
|
|||||||
{
|
{
|
||||||
var id = _selected[0].id.replace(/^infolog::/g,'');
|
var id = _selected[0].id.replace(/^infolog::/g,'');
|
||||||
egw_open(id,'infolog','edit',{print:1});
|
egw_open(id,'infolog','edit',{print:1});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger print() function to print the current window
|
* Trigger print() function to print the current window
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
infolog_print_preview: function ()
|
infolog_print_preview: function ()
|
||||||
{
|
{
|
||||||
|
@ -142,6 +142,28 @@ var AppJS = Class.extend(
|
|||||||
this.et2 = et2.widgetContainer;
|
this.et2 = et2.widgetContainer;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observer method receives update notifications from all applications
|
||||||
|
*
|
||||||
|
* App is responsible for only reacting to "messages" it is interested in!
|
||||||
|
*
|
||||||
|
* @param {string} _msg message (already translated) to show, eg. 'Entry deleted'
|
||||||
|
* @param {string} _app application name
|
||||||
|
* @param {(string|number)} _id id of entry to refresh or null
|
||||||
|
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
||||||
|
* - update: request just modified data from given rows. Sorting is not considered,
|
||||||
|
* so if the sort field is changed, the row will not be moved.
|
||||||
|
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
||||||
|
* - 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
|
||||||
|
*/
|
||||||
|
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an entry.
|
* Open an entry.
|
||||||
*
|
*
|
||||||
|
@ -163,28 +163,101 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh given application _targetapp display of entry _app _id, incl. outputting _msg
|
* Refresh given application _targetapp display of entry _app _id, incl. outputting _msg
|
||||||
*
|
*
|
||||||
* Default implementation here only reloads window with it's current url with an added msg=_msg attached
|
* 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} _msg message (already translated) to show, eg. 'Entry deleted'
|
||||||
* @param {string} _app application name
|
* @param {string} _app application name
|
||||||
* @param {(string|number)} _id id of entry to refresh or null
|
* @param {(string|number)} _id id of entry to refresh or null
|
||||||
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
||||||
* - update: request just modified data from given rows. Sorting is not considered,
|
* - update: request just modified data from given rows. Sorting is not considered,
|
||||||
* so if the sort field is changed, the row will not be moved.
|
* so if the sort field is changed, the row will not be moved.
|
||||||
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
||||||
* - delete: just delete the given rows clientside (no server interaction neccessary)
|
* - delete: just delete the given rows clientside (no server interaction neccessary)
|
||||||
* - add: requires full reload for proper sorting
|
* - add: requires full reload for proper sorting
|
||||||
* @param {string} _targetapp which app's window should be refreshed, default current
|
* @param {string} _targetapp which app's window should be refreshed, default current
|
||||||
* @param {(string|RegExp)} _replace regular expression to replace in url
|
* @param {(string|RegExp)} _replace regular expression to replace in url
|
||||||
* @param {string} _with
|
* @param {string} _with
|
||||||
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
|
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
|
||||||
* @todo move code from jsapi to here to deprecate egw_refresh in favor of egw.refresh()
|
*/
|
||||||
*/
|
|
||||||
refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
||||||
{
|
{
|
||||||
_wnd.egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
|
// Log for debugging purposes
|
||||||
|
this.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)", _msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
|
||||||
|
|
||||||
|
var win = typeof _targetapp != 'undefined' ? _wnd.egw_appWindow(_targetapp) : _wnd;
|
||||||
|
|
||||||
|
this.message(_msg, _msg_type);
|
||||||
|
|
||||||
|
// notify app observers: if observer for _app itself returns false, no regular refresh will take place
|
||||||
|
// app's own observer can replace current app_refresh functionality
|
||||||
|
var no_regular_refresh = false;
|
||||||
|
for(var app in _wnd.app)
|
||||||
|
{
|
||||||
|
if (typeof _wnd.app[app].observer == 'function' &&
|
||||||
|
_wnd.app[app].observer(_msg, _app, _id, _type, _msg_type, _targetapp) === false && app === _app)
|
||||||
|
{
|
||||||
|
no_regular_refresh = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (no_regular_refresh) return;
|
||||||
|
|
||||||
|
// if we have a framework, let it deal with refresh
|
||||||
|
if (win.framework && win.framework.refresh)
|
||||||
|
{
|
||||||
|
win.framework.refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if window registered an app_refresh method or overwritten app_refresh, just call it
|
||||||
|
if(typeof win.app_refresh == "function" && typeof win.app_refresh.registered == "undefined" ||
|
||||||
|
typeof win.app_refresh != "undefined" && win.app_refresh.registered(_app))
|
||||||
|
{
|
||||||
|
win.app_refresh(_msg, _app, _id, _type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// etemplate2 specific to avoid reloading whole page
|
||||||
|
if(typeof etemplate2 != "undefined" && etemplate2.getByApplication)
|
||||||
|
{
|
||||||
|
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 target or current app too
|
||||||
|
if ((_targetapp || egw_appName) != _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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//In case that we have etemplate2 ready but it's empty and refresh is not done
|
||||||
|
if (et2.length >= 1 && refresh_done) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var href = win.location.href;
|
||||||
|
|
||||||
|
if (typeof _replace != 'undefined')
|
||||||
|
{
|
||||||
|
href = href.replace(typeof _replace == 'string' ? new RegExp(_replace) : _replace, typeof _with != 'undefined' ? _with : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (href.indexOf('msg=') != -1)
|
||||||
|
{
|
||||||
|
href = 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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -213,80 +213,24 @@ function egw_getAppName()
|
|||||||
*
|
*
|
||||||
* Default implementation here only reloads window with it's current url with an added msg=_msg attached
|
* 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} _msg message (already translated) to show, eg. 'Entry deleted'
|
||||||
* @param string _app application name
|
* @param {string} _app application name
|
||||||
* @param string|int _id=null id of entry to refresh
|
* @param {(string|number)} _id id of entry to refresh or null
|
||||||
* @param string _type=null either 'update', 'edit', 'delete', 'add' or null
|
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
||||||
* - update: request just modified data from given rows. Sorting is not considered,
|
* - update: request just modified data from given rows. Sorting is not considered,
|
||||||
* so if the sort field is changed, the row will not be moved.
|
* so if the sort field is changed, the row will not be moved.
|
||||||
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
||||||
* - delete: just delete the given rows clientside (no server interaction neccessary)
|
* - delete: just delete the given rows clientside (no server interaction neccessary)
|
||||||
* - add: requires full reload for proper sorting
|
* - add: requires full reload for proper sorting
|
||||||
* @param string _targetapp which app's window should be refreshed, default current
|
* @param {string} _targetapp which app's window should be refreshed, default current
|
||||||
* @param string|RegExp _replace regular expression to replace in url
|
* @param {(string|RegExp)} _replace regular expression to replace in url
|
||||||
* @param string _with
|
* @param {string} _with
|
||||||
* @param string _msg_type 'error', 'warning' or 'success' (default)
|
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
|
||||||
* @todo move code to egw_message / egw.refresh()
|
* @deprecated use egw(window).refresh() instead
|
||||||
* @deprecated use egw.refresh() instead
|
|
||||||
*/
|
*/
|
||||||
function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
|
||||||
{
|
{
|
||||||
// Log for debugging purposes
|
egw(window).refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
|
||||||
egw.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)", _msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
|
|
||||||
|
|
||||||
//alert("egw_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
|
|
||||||
var win = typeof _targetapp != 'undefined' ? egw_appWindow(_targetapp) : window;
|
|
||||||
|
|
||||||
win.egw_message(_msg, _msg_type);
|
|
||||||
|
|
||||||
// if window registered an app_refresh method or overwritten app_refresh, just call it
|
|
||||||
if(typeof win.app_refresh == "function" && typeof win.app_refresh.registered == "undefined" ||
|
|
||||||
typeof win.app_refresh != "undefined" && win.app_refresh.registered(_app))
|
|
||||||
{
|
|
||||||
win.app_refresh(_msg, _app, _id, _type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// etemplate2 specific to avoid reloading whole page
|
|
||||||
if(typeof etemplate2 != "undefined" && etemplate2.getByApplication)
|
|
||||||
{
|
|
||||||
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 target or current app too
|
|
||||||
if ((_targetapp || egw_appName) != _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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//In case that we have etemplate2 ready but it's empty and refresh is not done
|
|
||||||
if (et2.length >= 1 && refresh_done) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var href = win.location.href;
|
|
||||||
|
|
||||||
if (typeof _replace != 'undefined')
|
|
||||||
{
|
|
||||||
href = href.replace(typeof _replace == 'string' ? new RegExp(_replace) : _replace, typeof _with != 'undefined' ? _with : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (href.indexOf('msg=') != -1)
|
|
||||||
{
|
|
||||||
href = 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user