mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-17 20:11:23 +02:00
New push method, with base implementation of delete client side
This commit is contained in:
@@ -133,26 +133,24 @@ var EgwApp = /** @class */ (function () {
|
||||
EgwApp.prototype.observer = function (_msg, _app, _id, _type, _msg_type, _links) {
|
||||
};
|
||||
/**
|
||||
* Push method receives push notification about updates to entries from the application
|
||||
* Handle a push notification about entry changes from the websocket
|
||||
*
|
||||
* It can use the extra _data parameter to determine if the client has read access to
|
||||
* the entry - if an update of the list is necessary.
|
||||
*
|
||||
* @param _type either 'update', 'edit', 'delete', 'add' or null
|
||||
* @param pushData
|
||||
* @param {string} pushData.app application name
|
||||
* @param {(string|number)} pushData.id id of entry to refresh or null
|
||||
* @param {string} pushData.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 _app application name incl. sub-type eg. "projectmanager-element"
|
||||
* @param _id id of entry to refresh or null
|
||||
* @param _data eg. owner or responsible to decide if update is necessary
|
||||
* @returns {undefined}
|
||||
* @param {object|null} pushData.acl Extra data for determining relevance. eg: owner or responsible to decide if update is necessary
|
||||
* @param {number} pushData.account_id User that caused the notification
|
||||
*/
|
||||
EgwApp.prototype.push = function (_type, _app, _id, _data) {
|
||||
EgwApp.prototype.push = function (pushData) {
|
||||
// only handle delete by default, for simple case of uid === "$app::$id"
|
||||
if (_type === 'delete') {
|
||||
egw(window).refresh('', _app, _id, "delete");
|
||||
if (pushData.type === 'delete') {
|
||||
egw.dataStoreUID(pushData.app + '::' + pushData.id, null);
|
||||
}
|
||||
};
|
||||
/**
|
||||
|
@@ -204,28 +204,26 @@ export abstract class EgwApp
|
||||
}
|
||||
|
||||
/**
|
||||
* Push method receives push notification about updates to entries from the application
|
||||
* Handle a push notification about entry changes from the websocket
|
||||
*
|
||||
* It can use the extra _data parameter to determine if the client has read access to
|
||||
* the entry - if an update of the list is necessary.
|
||||
*
|
||||
* @param _type either 'update', 'edit', 'delete', 'add' or null
|
||||
* @param pushData
|
||||
* @param {string} pushData.app application name
|
||||
* @param {(string|number)} pushData.id id of entry to refresh or null
|
||||
* @param {string} pushData.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 _app application name incl. sub-type eg. "projectmanager-element"
|
||||
* @param _id id of entry to refresh or null
|
||||
* @param _data eg. owner or responsible to decide if update is necessary
|
||||
* @returns {undefined}
|
||||
* @param {object|null} pushData.acl Extra data for determining relevance. eg: owner or responsible to decide if update is necessary
|
||||
* @param {number} pushData.account_id User that caused the notification
|
||||
*/
|
||||
push(_type : string, _app : string, _id : string|number, _data? : any)
|
||||
push(pushData)
|
||||
{
|
||||
// only handle delete by default, for simple case of uid === "$app::$id"
|
||||
if (_type === 'delete')
|
||||
if (pushData.type === 'delete')
|
||||
{
|
||||
egw(window).refresh('', _app, _id, "delete");
|
||||
egw.dataStoreUID(pushData.app + '::' + pushData.id, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -395,6 +395,45 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
}
|
||||
//alert('egw_refresh() about to call '+href);
|
||||
win.location.href = href;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Handle a push notification about entry changes from the websocket
|
||||
*
|
||||
* @param pushData
|
||||
* @param {string} pushData.app application name
|
||||
* @param {(string|number)} pushData.id id of entry to refresh or null
|
||||
* @param {string} pushData.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 {object|null} pushData.acl Extra data for determining relevance. eg: owner or responsible to decide if update is necessary
|
||||
* @param {number} pushData.account_id User that caused the notification
|
||||
*/
|
||||
push: function(pushData)
|
||||
{
|
||||
// Log for debugging purposes
|
||||
this.debug("log", "push(%o)", pushData);
|
||||
|
||||
if (typeof pushData == "undefined")
|
||||
{
|
||||
this.debug('warn', "Push sent nothing");
|
||||
return;
|
||||
}
|
||||
|
||||
// notify app observers
|
||||
for (var app in _wnd.egw.window.app) // run observers in main window (eg. not iframe, which might be opener!)
|
||||
{
|
||||
var app_obj = _wnd.egw.window.app[app];
|
||||
if (typeof app_obj.push == 'function')
|
||||
{
|
||||
app_obj.push(pushData);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user