mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
* Infolog: Push updates
This commit is contained in:
parent
efaf9771d0
commit
6d2af76576
@ -248,7 +248,7 @@ var AppJS = (function(){ "use strict"; return Class.extend(
|
|||||||
* @param uid
|
* @param uid
|
||||||
* @param current_order
|
* @param current_order
|
||||||
*/
|
*/
|
||||||
nm_refresh_add: function(nm, uid, current_order)
|
nm_refresh_index: function(nm, uid, current_order)
|
||||||
{
|
{
|
||||||
// Do we have a modified field so we can check nm sort order?
|
// Do we have a modified field so we can check nm sort order?
|
||||||
if(this.modification_field_name)
|
if(this.modification_field_name)
|
||||||
|
@ -193,7 +193,6 @@ var EgwApp = /** @class */ (function () {
|
|||||||
*/
|
*/
|
||||||
EgwApp.prototype.nm_refresh_index = function (nm, uid, current_order, update_type) {
|
EgwApp.prototype.nm_refresh_index = function (nm, uid, current_order, update_type) {
|
||||||
var _a;
|
var _a;
|
||||||
return false;
|
|
||||||
// Do we have a modified field so we can check nm sort order?
|
// Do we have a modified field so we can check nm sort order?
|
||||||
if (this.modification_field_name) {
|
if (this.modification_field_name) {
|
||||||
var value = nm.getValue();
|
var value = nm.getValue();
|
||||||
|
@ -296,7 +296,6 @@ export abstract class EgwApp
|
|||||||
*/
|
*/
|
||||||
nm_refresh_index(nm: et2_nextmatch, uid: string, current_order: string[], update_type: string) : number|boolean
|
nm_refresh_index(nm: et2_nextmatch, uid: string, current_order: string[], update_type: string) : number|boolean
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
// Do we have a modified field so we can check nm sort order?
|
// Do we have a modified field so we can check nm sort order?
|
||||||
if(this.modification_field_name)
|
if(this.modification_field_name)
|
||||||
{
|
{
|
||||||
|
@ -716,6 +716,8 @@ class infolog_bo
|
|||||||
}
|
}
|
||||||
if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items
|
if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items
|
||||||
{
|
{
|
||||||
|
Link::notify_update('infolog',$info_id,$info, 'delete');
|
||||||
|
|
||||||
// send email notifications and do the history logging
|
// send email notifications and do the history logging
|
||||||
if(!$skip_notification)
|
if(!$skip_notification)
|
||||||
{
|
{
|
||||||
@ -749,9 +751,10 @@ class infolog_bo
|
|||||||
$skip_notification=false, $throw_exception=false, $purge_cfs=null, $ignore_acl=false)
|
$skip_notification=false, $throw_exception=false, $purge_cfs=null, $ignore_acl=false)
|
||||||
{
|
{
|
||||||
$values = $values_in;
|
$values = $values_in;
|
||||||
|
$change_type = 'update';
|
||||||
//echo "boinfolog::write()values="; _debug_array($values);
|
//echo "boinfolog::write()values="; _debug_array($values);
|
||||||
if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) &&
|
if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0, Acl::EDIT, $values['info_owner']) &&
|
||||||
!$this->check_access(0,Acl::ADD,$values['info_owner'])))
|
!$this->check_access(0, Acl::ADD, $values['info_owner'])))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -760,6 +763,10 @@ class infolog_bo
|
|||||||
{
|
{
|
||||||
$old = $this->read($values['info_id'], false, 'server', $ignore_acl);
|
$old = $this->read($values['info_id'], false, 'server', $ignore_acl);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$change_type = 'add';
|
||||||
|
}
|
||||||
|
|
||||||
if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values,Acl::EDIT)))
|
if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values,Acl::EDIT)))
|
||||||
{
|
{
|
||||||
@ -830,6 +837,7 @@ class infolog_bo
|
|||||||
if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
|
if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
|
||||||
}
|
}
|
||||||
$check_defaults = false;
|
$check_defaults = false;
|
||||||
|
$change_type = 'update';
|
||||||
}
|
}
|
||||||
if ($check_defaults)
|
if ($check_defaults)
|
||||||
{
|
{
|
||||||
@ -1012,7 +1020,7 @@ class infolog_bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify the link-class about the update, as other apps may be subscribt to it
|
// notify the link-class about the update, as other apps may be subscribt to it
|
||||||
Link::notify_update('infolog',$info_id,$values);
|
Link::notify_update('infolog',$info_id,$values, $change_type);
|
||||||
|
|
||||||
// pre-cache the new values
|
// pre-cache the new values
|
||||||
self::set_link_cache($values);
|
self::set_link_cache($values);
|
||||||
|
@ -73,6 +73,7 @@ class infolog_hooks
|
|||||||
'edit_id' => 'info_id',
|
'edit_id' => 'info_id',
|
||||||
'edit_popup' => '760x570',
|
'edit_popup' => '760x570',
|
||||||
'merge' => true,
|
'merge' => true,
|
||||||
|
'push_data' => ['info_type', 'info_owner','info_responsible', 'info_modified']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1826,7 +1826,7 @@ class infolog_ui
|
|||||||
$GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']);
|
$GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']);
|
||||||
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
||||||
$content['msg'] = lang('InfoLog entry saved');
|
$content['msg'] = lang('InfoLog entry saved');
|
||||||
Framework::refresh_opener($content['msg'],'infolog',$info_id,$operation);
|
Framework::message($content['msg']);
|
||||||
}
|
}
|
||||||
$content['tabs'] = $active_tab;
|
$content['tabs'] = $active_tab;
|
||||||
|
|
||||||
@ -1881,12 +1881,12 @@ class infolog_ui
|
|||||||
);
|
);
|
||||||
if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return; // checks ACL first
|
if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return; // checks ACL first
|
||||||
|
|
||||||
Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
|
Framework::message($content['msg']);
|
||||||
}
|
}
|
||||||
// called again after delete confirmation dialog
|
// called again after delete confirmation dialog
|
||||||
elseif ($button == 'deleted' && $content['msg'])
|
elseif ($button == 'deleted' && $content['msg'])
|
||||||
{
|
{
|
||||||
Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
|
Framework::message($content['msg']);
|
||||||
}
|
}
|
||||||
if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
|
if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,9 @@ require("jqueryui");
|
|||||||
require("../jsapi/egw_global");
|
require("../jsapi/egw_global");
|
||||||
require("../etemplate/et2_types");
|
require("../etemplate/et2_types");
|
||||||
var egw_app_1 = require("../../api/js/jsapi/egw_app");
|
var egw_app_1 = require("../../api/js/jsapi/egw_app");
|
||||||
|
var et2_widget_dialog_1 = require("../../api/js/etemplate/et2_widget_dialog");
|
||||||
|
var etemplate2_1 = require("../../api/js/etemplate/etemplate2");
|
||||||
|
var et2_extension_nextmatch_1 = require("../../api/js/etemplate/et2_extension_nextmatch");
|
||||||
/**
|
/**
|
||||||
* UI for Infolog
|
* UI for Infolog
|
||||||
*
|
*
|
||||||
@ -44,7 +47,7 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
*/
|
*/
|
||||||
function InfologApp() {
|
function InfologApp() {
|
||||||
// call parent
|
// call parent
|
||||||
return _super.call(this, 'infolog') || this;
|
return _super.call(this, 'infolog', 'info_datemodified') || this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -143,6 +146,79 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
this.et2._inst.refresh(_msg, _app, _id, _type);
|
this.et2._inst.refresh(_msg, _app, _id, _type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 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: ask server for data, add in intelligently
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
InfologApp.prototype.push = function (pushData) {
|
||||||
|
if (pushData.app !== this.appname)
|
||||||
|
return;
|
||||||
|
// pushData does not contain everything, just the minimum.
|
||||||
|
var event = pushData.acl || {};
|
||||||
|
if (pushData.type === 'delete') {
|
||||||
|
return _super.prototype.push.call(this, pushData);
|
||||||
|
}
|
||||||
|
// check visibility - grants is ID => permission of people we're allowed to see
|
||||||
|
if (typeof this._grants === 'undefined') {
|
||||||
|
this._grants = egw.grants(this.appname);
|
||||||
|
}
|
||||||
|
if (this._grants && typeof this._grants[pushData.acl.info_owner] == "undefined") {
|
||||||
|
// No ACL access
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If we know about it & it's a update, just update.
|
||||||
|
if (pushData.type == "update" && this.egw.dataHasUID(pushData.id) || pushData.type == "edit") {
|
||||||
|
return etemplate2_1.etemplate2.app_refresh("", pushData.app, pushData.id, pushData.type);
|
||||||
|
}
|
||||||
|
// Filter what's allowed down to those we care about
|
||||||
|
var filters = {
|
||||||
|
owner: { col: "info_owner", filter_values: [] },
|
||||||
|
responsible: { col: "info_responsible", filter_values: [] }
|
||||||
|
};
|
||||||
|
for (var _i = 0, _a = etemplate2_1.etemplate2.getByApplication(this.appname); _i < _a.length; _i++) {
|
||||||
|
var et = _a[_i];
|
||||||
|
et.widgetContainer.iterateOver(function (nm) {
|
||||||
|
var value = nm.getValue();
|
||||||
|
if (!value || !value.col_filter)
|
||||||
|
return;
|
||||||
|
for (var _i = 0, _a = Object.values(filters); _i < _a.length; _i++) {
|
||||||
|
var field_filter = _a[_i];
|
||||||
|
if (value.col_filter[field_filter.col]) {
|
||||||
|
field_filter.filter_values.push(value.col_filter[field_filter.col]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this, et2_extension_nextmatch_1.et2_nextmatch);
|
||||||
|
}
|
||||||
|
var _loop_1 = function (field_filter) {
|
||||||
|
if (field_filter.filter_values.length == 0)
|
||||||
|
return "continue";
|
||||||
|
if (pushData.acl && typeof pushData.acl[field_filter.col] == "string" &&
|
||||||
|
field_filter.filter_values.indexOf(pushData.acl[field_filter.col]) <= 0) {
|
||||||
|
return { value: void 0 };
|
||||||
|
}
|
||||||
|
if (field_filter.filter_values.filter(function (account) { return pushData.acl[field_filter.col].indexOf(account) >= 0; }).length == 0)
|
||||||
|
return { value: void 0 };
|
||||||
|
};
|
||||||
|
for (var _b = 0, _c = Object.values(filters); _b < _c.length; _b++) {
|
||||||
|
var field_filter = _c[_b];
|
||||||
|
var state_1 = _loop_1(field_filter);
|
||||||
|
if (typeof state_1 === "object")
|
||||||
|
return state_1.value;
|
||||||
|
}
|
||||||
|
// Pass actual refresh on to etemplate to take care of
|
||||||
|
etemplate2_1.etemplate2.app_refresh("", pushData.app, pushData.id, pushData.type);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Retrieve the current state of the application for future restoration
|
* Retrieve the current state of the application for future restoration
|
||||||
*
|
*
|
||||||
@ -156,7 +232,7 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
var state = _super.prototype.getState.call(this);
|
var state = _super.prototype.getState.call(this);
|
||||||
var nm = {};
|
var nm = {};
|
||||||
// Get index etemplate
|
// Get index etemplate
|
||||||
var et2 = etemplate2.getById('infolog-index');
|
var et2 = etemplate2_1.etemplate2.getById('infolog-index');
|
||||||
if (et2) {
|
if (et2) {
|
||||||
var content = et2.widgetContainer.getArrayMgr('content');
|
var content = et2.widgetContainer.getArrayMgr('content');
|
||||||
nm = content && content.data && content.data.nm ? content.data.nm : {};
|
nm = content && content.data && content.data.nm ? content.data.nm : {};
|
||||||
@ -289,10 +365,10 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
child_button.style.display = children ? 'block' : 'none';
|
child_button.style.display = children ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
var callbackDeleteDialog = function (button_id) {
|
var callbackDeleteDialog = function (button_id) {
|
||||||
if (button_id == et2_dialog.YES_BUTTON) {
|
if (button_id == et2_widget_dialog_1.et2_dialog.YES_BUTTON) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
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);
|
et2_widget_dialog_1.et2_dialog.show_dialog(callbackDeleteDialog, this.egw.lang("Do you really want to DELETE this Rule"), this.egw.lang("Delete"), {}, et2_widget_dialog_1.et2_dialog.BUTTONS_YES_NO_CANCEL, et2_widget_dialog_1.et2_dialog.WARNING_MESSAGE);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Confirm delete
|
* Confirm delete
|
||||||
|
@ -18,6 +18,9 @@ import '../jsapi/egw_global';
|
|||||||
import '../etemplate/et2_types';
|
import '../etemplate/et2_types';
|
||||||
|
|
||||||
import {EgwApp} from '../../api/js/jsapi/egw_app';
|
import {EgwApp} from '../../api/js/jsapi/egw_app';
|
||||||
|
import {et2_dialog} from "../../api/js/etemplate/et2_widget_dialog";
|
||||||
|
import {etemplate2} from "../../api/js/etemplate/etemplate2";
|
||||||
|
import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI for Infolog
|
* UI for Infolog
|
||||||
@ -27,6 +30,9 @@ import {EgwApp} from '../../api/js/jsapi/egw_app';
|
|||||||
class InfologApp extends EgwApp
|
class InfologApp extends EgwApp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Hold on to ACL grants
|
||||||
|
private _grants : any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -35,7 +41,7 @@ class InfologApp extends EgwApp
|
|||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
// call parent
|
// call parent
|
||||||
super('infolog');
|
super('infolog', 'info_datemodified');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,6 +156,84 @@ class InfologApp extends EgwApp
|
|||||||
this.et2._inst.refresh(_msg, _app, _id, _type);
|
this.et2._inst.refresh(_msg, _app, _id, _type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 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: ask server for data, add in intelligently
|
||||||
|
* @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(pushData)
|
||||||
|
{
|
||||||
|
if(pushData.app !== this.appname) return;
|
||||||
|
|
||||||
|
// pushData does not contain everything, just the minimum.
|
||||||
|
let event = pushData.acl || {};
|
||||||
|
|
||||||
|
if(pushData.type === 'delete')
|
||||||
|
{
|
||||||
|
return super.push(pushData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check visibility - grants is ID => permission of people we're allowed to see
|
||||||
|
if(typeof this._grants === 'undefined')
|
||||||
|
{
|
||||||
|
this._grants = egw.grants(this.appname);
|
||||||
|
}
|
||||||
|
if(this._grants && typeof this._grants[pushData.acl.info_owner] == "undefined")
|
||||||
|
{
|
||||||
|
// No ACL access
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we know about it & it's a update, just update.
|
||||||
|
if(pushData.type == "update" && this.egw.dataHasUID(pushData.id) || pushData.type == "edit")
|
||||||
|
{
|
||||||
|
return etemplate2.app_refresh("",pushData.app, pushData.id, pushData.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter what's allowed down to those we care about
|
||||||
|
let filters = {
|
||||||
|
owner: {col: "info_owner", filter_values: []},
|
||||||
|
responsible: {col: "info_responsible", filter_values: []}
|
||||||
|
};
|
||||||
|
for(let et of etemplate2.getByApplication(this.appname))
|
||||||
|
{
|
||||||
|
et.widgetContainer.iterateOver( function(nm) {
|
||||||
|
let value = nm.getValue();
|
||||||
|
if(!value || !value.col_filter) return;
|
||||||
|
|
||||||
|
for(let field_filter of Object.values(filters))
|
||||||
|
{
|
||||||
|
if(value.col_filter[field_filter.col])
|
||||||
|
{
|
||||||
|
field_filter.filter_values.push(value.col_filter[field_filter.col]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},this, et2_nextmatch);
|
||||||
|
}
|
||||||
|
for(let field_filter of Object.values(filters))
|
||||||
|
{
|
||||||
|
if(field_filter.filter_values.length == 0) continue;
|
||||||
|
if(pushData.acl && typeof pushData.acl[field_filter.col] == "string" &&
|
||||||
|
field_filter.filter_values.indexOf(pushData.acl[field_filter.col]) <=0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(field_filter.filter_values.filter(account => pushData.acl[field_filter.col].indexOf(account) >=0).length == 0) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass actual refresh on to etemplate to take care of
|
||||||
|
etemplate2.app_refresh("",pushData.app, pushData.id, pushData.type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the current state of the application for future restoration
|
* Retrieve the current state of the application for future restoration
|
||||||
|
Loading…
Reference in New Issue
Block a user