Return an object for egw message in order to have access to it after display

This commit is contained in:
Hadi Nategh 2020-07-30 15:01:50 +02:00
parent 9c63ee5d23
commit e120bdb189
5 changed files with 30 additions and 15 deletions

View File

@ -173,8 +173,6 @@ class admin_hooks
}
// allow apps to hook into "Admin >> Clear cache and register hooks"
Api\Hooks::process('clear_cache', array(), true);
Api\Json\Response::get()->apply('egw.message', array(lang('Done'), 'success'));
}
/**

View File

@ -1101,9 +1101,13 @@ var AdminApp = /** @class */ (function (_super) {
* cache to use different method not requiring eg. so much memory
*/
AdminApp.prototype.clear_cache = function () {
this.egw.message(this.egw.lang('Clear cache and register hooks') + "\n" + this.egw.lang('Please wait...'), 'info');
this.egw.json('admin.admin_hooks.ajax_clear_cache').sendRequest(true, undefined, jQuery.proxy(function (_xmlhttp, _err) {
this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1').sendRequest(true);
var wait = this.egw.message(this.egw.lang('Clear cache and register hooks') + "\n" + this.egw.lang('Please wait...'), 'info');
var success = function () {
wait.close();
egw.message('Done');
};
this.egw.json('admin.admin_hooks.ajax_clear_cache', null, success).sendRequest(true, undefined, jQuery.proxy(function (_xmlhttp, _err) {
this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1', null, success).sendRequest(true);
}, this));
};
/**

View File

@ -1335,11 +1335,14 @@ class AdminApp extends EgwApp
*/
clear_cache()
{
this.egw.message(this.egw.lang('Clear cache and register hooks')+"\n"+this.egw.lang('Please wait...'),'info');
this.egw.json('admin.admin_hooks.ajax_clear_cache').sendRequest(true, undefined, jQuery.proxy(function(_xmlhttp, _err)
let wait = this.egw.message(this.egw.lang('Clear cache and register hooks')+"\n"+this.egw.lang('Please wait...'),'info');
let success = function (){
wait.close();
egw.message('Done');
};
this.egw.json('admin.admin_hooks.ajax_clear_cache', null, success).sendRequest(true, undefined, jQuery.proxy(function(_xmlhttp, _err)
{
this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1').sendRequest(true);
this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1', null, success).sendRequest(true);
}, this));
}

View File

@ -827,8 +827,10 @@ declare interface IegwWndLocal extends IegwGlobal
* @param {string} _discardID unique string id (appname:id) in order to register
* the message as discardable. If no appname given, the id will be prefixed with
* current app. The discardID will be stored in local storage.
*
* @returns {object} returns an object containing data and methods related to the message
*/
message(_msg : string, _type? : "help"|"info"|"error"|"warning"|"success", _discardID? : string) : void;
message(_msg: string, _type?: "help" | "info" | "error" | "warning" | "success", _discardID?: string): {node: JQuery, message: string, index: number, close: Function};
/**
* Are we running in a popup
*

View File

@ -62,6 +62,8 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
* @param {string} _discardID unique string id (appname:id) in order to register
* the message as discardable. If no appname given, the id will be prefixed with
* current app. The discardID will be stored in local storage.
*
* @return {object} returns an object containing data and methods related to the message
*/
message: function(_msg, _type, _discardID)
{
@ -206,6 +208,12 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
}, 5000);
}
}
return {
node: msg_div,
message: _msg,
index: msg_index,
close: function(){msg_close.click();}
};
},
/**