mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-24 17:04:14 +01:00
New push method, with base implementation of delete client side
This commit is contained in:
parent
ff50df67d0
commit
76a5793a0a
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
@ -56,17 +56,6 @@ var TimesheetApp = /** @class */ (function (_super) {
|
||||
this.filter2_change();
|
||||
}
|
||||
};
|
||||
TimesheetApp.prototype.observer = function (_msg, _app, _id, _type, _msg_type, _links) {
|
||||
switch (_app) {
|
||||
case 'timesheet':
|
||||
switch (_type) {
|
||||
case 'delete':
|
||||
egw.dataStoreUID(_app + '::' + _id, null);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -181,31 +170,6 @@ var TimesheetApp = /** @class */ (function (_super) {
|
||||
if (widget)
|
||||
return widget.options.value;
|
||||
};
|
||||
/**
|
||||
* Push method receives push notification about updates to entries from the application
|
||||
*
|
||||
* 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
|
||||
* - 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}
|
||||
*/
|
||||
TimesheetApp.prototype.push = function (_type, _app, _id, _data) {
|
||||
console.log('app.timesheet.push', arguments);
|
||||
switch (_type) {
|
||||
case 'delete':
|
||||
_super.prototype.push.apply(this, arguments);
|
||||
break;
|
||||
}
|
||||
};
|
||||
return TimesheetApp;
|
||||
}(egw_app_1.EgwApp));
|
||||
app.classes.timesheet = TimesheetApp;
|
||||
|
@ -48,22 +48,6 @@ class TimesheetApp extends EgwApp
|
||||
}
|
||||
}
|
||||
|
||||
observer(_msg, _app, _id, _type, _msg_type, _links) {
|
||||
|
||||
switch(_app)
|
||||
{
|
||||
case 'timesheet':
|
||||
switch(_type)
|
||||
{
|
||||
case 'delete':
|
||||
egw.dataStoreUID(_app + '::' + _id, null);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -207,35 +191,6 @@ class TimesheetApp extends EgwApp
|
||||
var widget = this.et2.getWidgetById('ts_title');
|
||||
if(widget) return widget.options.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push method receives push notification about updates to entries from the application
|
||||
*
|
||||
* 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
|
||||
* - 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}
|
||||
*/
|
||||
push(_type : string, _app : string, _id : string|number, _data? : any)
|
||||
{
|
||||
console.log('app.timesheet.push', arguments);
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case 'delete':
|
||||
super.push.apply(this, arguments);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.classes.timesheet = TimesheetApp;
|
||||
|
Loading…
Reference in New Issue
Block a user