mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 23:59:39 +01:00
Home using non-global EgwApp instances for portlets
This commit is contained in:
parent
80b72bfb3c
commit
5379a0c924
@ -150,7 +150,7 @@ var et2_portlet = /** @class */ (function (_super) {
|
||||
}
|
||||
// Add in defaults, but let provided actions override them
|
||||
this.options.actions = jQuery.extend(true, {}, defaults, actions);
|
||||
_super.prototype.set_actions.call(this, [this.options.actions]);
|
||||
_super.prototype.set_actions.call(this, this.options.actions);
|
||||
};
|
||||
/**
|
||||
* Override _link_actions to remove edit action, if there is no settings
|
||||
|
@ -208,7 +208,7 @@ class et2_portlet extends et2_valueWidget
|
||||
|
||||
// Add in defaults, but let provided actions override them
|
||||
this.options.actions = jQuery.extend(true,{},defaults,actions);
|
||||
super.set_actions([this.options.actions]);
|
||||
super.set_actions(this.options.actions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,7 +361,7 @@ var etemplate2 = /** @class */ (function () {
|
||||
var appname = _name.split('.')[0];
|
||||
// if no app object provided and template app is not currentapp (eg. infolog CRM view)
|
||||
// create private app object / closure with just classes / prototypes
|
||||
if (!_app && appname && appname != currentapp && currentapp != 'home' && appname != 'home') {
|
||||
if (!_app && appname && appname != currentapp) {
|
||||
app = { classes: window.app.classes };
|
||||
}
|
||||
// remember used app object, to eg. use: onchange="widget.getInstanceMgr().app_object[app].callback()"
|
||||
|
@ -459,7 +459,7 @@ export class etemplate2
|
||||
const appname = _name.split('.')[0];
|
||||
// if no app object provided and template app is not currentapp (eg. infolog CRM view)
|
||||
// create private app object / closure with just classes / prototypes
|
||||
if (!_app && appname && appname != currentapp && currentapp != 'home' && appname != 'home')
|
||||
if (!_app && appname && appname != currentapp)
|
||||
{
|
||||
app = {classes: window.app.classes};
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ var CalendarApp = /** @class */ (function (_super) {
|
||||
return d;
|
||||
},
|
||||
end_of_week: function (date) {
|
||||
var d = app.calendar.date.start_of_week(date);
|
||||
var d = this.start_of_week(date);
|
||||
d.setUTCDate(d.getUTCDate() + 6);
|
||||
return d;
|
||||
}
|
||||
@ -558,6 +558,7 @@ var CalendarApp = /** @class */ (function (_super) {
|
||||
* @param pushData
|
||||
*/
|
||||
CalendarApp.prototype.push_calendar = function (pushData) {
|
||||
var _this = this;
|
||||
// pushData does not contain everything, just the minimum. See calendar_hooks::search_link().
|
||||
var cal_event = pushData.acl || {};
|
||||
// check visibility - grants is ID => permission of people we're allowed to see
|
||||
@ -566,9 +567,9 @@ var CalendarApp = /** @class */ (function (_super) {
|
||||
this._grants = egw.grants(this.appname);
|
||||
}
|
||||
// Filter what's allowed down to those we care about
|
||||
var filtered = Object.keys(this._grants).filter(function (account) { return app.calendar.state.owner.indexOf(account) >= 0; });
|
||||
var filtered = Object.keys(this._grants).filter(function (account) { return _this.state.owner.indexOf(account) >= 0; });
|
||||
// Check if we're interested in displaying by owner / participant
|
||||
var owner_check = et2_widget_event_1.et2_calendar_event.owner_check(cal_event, { options: { owner: filtered } });
|
||||
var owner_check = et2_widget_event_1.et2_calendar_event.owner_check(cal_event, jQuery.extend({}, { options: { owner: filtered } }, this.et2));
|
||||
if (!owner_check) {
|
||||
// The owner is not in the list of what we're allowed / care about
|
||||
return;
|
||||
@ -708,11 +709,11 @@ var CalendarApp = /** @class */ (function (_super) {
|
||||
case 'next':
|
||||
case 'previous':
|
||||
var delta = action.id == 'previous' ? -1 : 1;
|
||||
var view = CalendarApp.views[app.calendar.state.view] || false;
|
||||
var start = new Date(app.calendar.state.date);
|
||||
var view = CalendarApp.views[this.state.view] || false;
|
||||
var start = new Date(this.state.date);
|
||||
if (view) {
|
||||
start = view.scroll(delta);
|
||||
app.calendar.update_state({ date: app.calendar.date.toString(start) });
|
||||
app.calendar.update_state({ date: this.date.toString(start) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -503,10 +503,13 @@ class CalendarApp extends EgwApp
|
||||
this._grants = egw.grants(this.appname);
|
||||
}
|
||||
// Filter what's allowed down to those we care about
|
||||
let filtered = Object.keys(this._grants).filter(account => app.calendar.state.owner.indexOf(account) >= 0);
|
||||
let filtered = Object.keys(this._grants).filter(account => this.state.owner.indexOf(account) >= 0);
|
||||
|
||||
// Check if we're interested in displaying by owner / participant
|
||||
let owner_check = et2_calendar_event.owner_check(cal_event, {options: {owner: filtered}});
|
||||
let owner_check = et2_calendar_event.owner_check(cal_event, jQuery.extend({},
|
||||
{options: {owner: filtered}},
|
||||
this.et2
|
||||
));
|
||||
if(!owner_check)
|
||||
{
|
||||
// The owner is not in the list of what we're allowed / care about
|
||||
@ -670,12 +673,12 @@ class CalendarApp extends EgwApp
|
||||
case 'next':
|
||||
case 'previous':
|
||||
var delta = action.id == 'previous' ? -1 : 1;
|
||||
var view = CalendarApp.views[app.calendar.state.view] || false;
|
||||
var start = new Date(app.calendar.state.date);
|
||||
var view = CalendarApp.views[this.state.view] || false;
|
||||
var start = new Date(this.state.date);
|
||||
if (view)
|
||||
{
|
||||
start = view.scroll(delta);
|
||||
app.calendar.update_state({date:app.calendar.date.toString(start)});
|
||||
app.calendar.update_state({date:this.date.toString(start)});
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3799,7 +3802,7 @@ class CalendarApp extends EgwApp
|
||||
},
|
||||
end_of_week: function(date)
|
||||
{
|
||||
var d = app.calendar.date.start_of_week(date);
|
||||
var d = this.start_of_week(date);
|
||||
d.setUTCDate(d.getUTCDate() + 6);
|
||||
return d;
|
||||
}
|
||||
|
@ -179,7 +179,8 @@ var et2_calendar_event = /** @class */ (function (_super) {
|
||||
this._values_check(value);
|
||||
}
|
||||
// Check for changing days in the grid view
|
||||
if (!this._sameday_check(value) || !this._status_check(value, app.calendar.getState().status_filter, parent_owner)) {
|
||||
var state = this.getInstanceManager().app_obj.calendar.getState() || app.calendar.getState();
|
||||
if (!this._sameday_check(value) || !this._status_check(value, state.status_filter, parent_owner)) {
|
||||
// May need to update parent to remove out-of-view events
|
||||
parent.removeChild(this);
|
||||
if (event === null && parent && parent.instanceOf(et2_widget_daycol_1.et2_calendar_daycol)) {
|
||||
@ -927,9 +928,11 @@ var et2_calendar_event = /** @class */ (function (_super) {
|
||||
* @return {boolean} Should the event be displayed
|
||||
*/
|
||||
et2_calendar_event.owner_check = function (event, parent, owner_too) {
|
||||
var _a, _b;
|
||||
var owner_match = true;
|
||||
if (typeof owner_too === 'undefined' && app.calendar.state.status_filter) {
|
||||
owner_too = app.calendar.state.status_filter === 'owner';
|
||||
var state = ((_a = parent.getInstanceManager()) === null || _a === void 0 ? void 0 : _a.app_obj.calendar.state) || ((_b = app.calendar) === null || _b === void 0 ? void 0 : _b.state) || {};
|
||||
if (typeof owner_too === 'undefined' && state.status_filter) {
|
||||
owner_too = state.status_filter === 'owner';
|
||||
}
|
||||
var options = null;
|
||||
if (app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) {
|
||||
|
@ -223,7 +223,8 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
|
||||
}
|
||||
|
||||
// Check for changing days in the grid view
|
||||
if(!this._sameday_check(value) || !this._status_check(value, app.calendar.getState().status_filter, parent_owner))
|
||||
let state = this.getInstanceManager().app_obj.calendar.getState() || app.calendar.getState();
|
||||
if(!this._sameday_check(value) || !this._status_check(value, state.status_filter, parent_owner))
|
||||
{
|
||||
// May need to update parent to remove out-of-view events
|
||||
parent.removeChild(this);
|
||||
@ -1187,9 +1188,10 @@ export class et2_calendar_event extends et2_valueWidget implements et2_IDetached
|
||||
static owner_check(event, parent, owner_too?)
|
||||
{
|
||||
let owner_match = true;
|
||||
if(typeof owner_too === 'undefined' && app.calendar.state.status_filter)
|
||||
let state = parent.getInstanceManager()?.app_obj.calendar.state || app.calendar?.state || {}
|
||||
if(typeof owner_too === 'undefined' && state.status_filter)
|
||||
{
|
||||
owner_too = app.calendar.state.status_filter === 'owner';
|
||||
owner_too = state.status_filter === 'owner';
|
||||
}
|
||||
let options : any = null;
|
||||
if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner'))
|
||||
|
@ -348,15 +348,16 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
getInstanceManager: function () { return im; }
|
||||
}, { application: 'calendar' });
|
||||
var labels = [];
|
||||
if (!app.calendar.state.cat_id ||
|
||||
app.calendar.state.cat_id.toString() === '' ||
|
||||
app.calendar.state.cat_id.toString() == '0') {
|
||||
app.calendar.state.cat_id = '';
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if (!app_calendar.state.cat_id ||
|
||||
app_calendar.state.cat_id.toString() === '' ||
|
||||
app_calendar.state.cat_id.toString() == '0') {
|
||||
app_calendar.state.cat_id = '';
|
||||
labels.push({ id: '', value: '', label: egw.lang('none'), main: '', data: {} });
|
||||
labels = labels.concat(categories);
|
||||
}
|
||||
else {
|
||||
var cat_id = app.calendar.state.cat_id;
|
||||
var cat_id = app_calendar.state.cat_id;
|
||||
if (typeof cat_id == 'string') {
|
||||
cat_id = cat_id.split(',');
|
||||
}
|
||||
@ -389,6 +390,7 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
},
|
||||
group: function (labels, rows, event) {
|
||||
var cats = event.category;
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if (typeof event.category === 'string') {
|
||||
cats = cats.split(',');
|
||||
}
|
||||
@ -400,7 +402,7 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
if (labels[i].id == category) {
|
||||
// If there's no cat filter, only show the top level
|
||||
if (!app.calendar.state.cat_id) {
|
||||
if (!app_calendar.state.cat_id) {
|
||||
for (var j = 0; j < labels.length; j++) {
|
||||
if (labels[j].id == labels[i].main) {
|
||||
label_index = j;
|
||||
@ -747,12 +749,13 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
// Set height for rows
|
||||
this.rows.height(this.div.height() - this.headers.outerHeight());
|
||||
// Draw the rows
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
for (var key in labels) {
|
||||
if (!labels.hasOwnProperty(key))
|
||||
continue;
|
||||
// Skip sub-categories (events are merged into top level)
|
||||
if (this.options.group_by == 'category' &&
|
||||
(!app.calendar.state.cat_id || app.calendar.state.cat_id == '') &&
|
||||
(!app_calendar.state.cat_id || app_calendar.state.cat_id == '') &&
|
||||
labels[key].id != labels[key].main) {
|
||||
continue;
|
||||
}
|
||||
@ -895,7 +898,8 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
// we're not using UTC so date() formatting function works
|
||||
var t = new Date(start.valueOf());
|
||||
// Make sure we're lining up on the week
|
||||
var week_end = app.calendar.date.end_of_week(start);
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
var week_end = app_calendar.date.end_of_week(start);
|
||||
var days_in_week = Math.floor(((week_end - start) / (24 * 3600 * 1000)) + 1);
|
||||
var week_width = 100 / days * (days <= 7 ? days : days_in_week);
|
||||
for (var left = 0, i = 0; i < days; t.setUTCDate(t.getUTCDate() + 7), left += week_width) {
|
||||
@ -909,12 +913,12 @@ var et2_calendar_planner = /** @class */ (function (_super) {
|
||||
usertime.setUTCMinutes(usertime.getUTCMinutes() - start.getTimezoneOffset());
|
||||
}
|
||||
week_width = 100 / days * Math.min(days, days_in_week);
|
||||
var title = this.egw().lang('Week') + ' ' + app.calendar.date.week_number(usertime);
|
||||
var title = this.egw().lang('Week') + ' ' + app_calendar.date.week_number(usertime);
|
||||
if (start.getTimezoneOffset() > 0) {
|
||||
// Gets the right week start west of GMT
|
||||
usertime.setUTCMinutes(usertime.getUTCMinutes() + start.getTimezoneOffset());
|
||||
}
|
||||
state = app.calendar.date.start_of_week(usertime);
|
||||
state = app_calendar.date.start_of_week(usertime);
|
||||
state.setUTCHours(0);
|
||||
state.setUTCMinutes(0);
|
||||
state = state.toJSON();
|
||||
|
@ -709,18 +709,19 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
},{application: 'calendar'});
|
||||
|
||||
var labels = [];
|
||||
if(!app.calendar.state.cat_id ||
|
||||
app.calendar.state.cat_id.toString() === '' ||
|
||||
app.calendar.state.cat_id.toString() == '0'
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if(!app_calendar.state.cat_id ||
|
||||
app_calendar.state.cat_id.toString() === '' ||
|
||||
app_calendar.state.cat_id.toString() == '0'
|
||||
)
|
||||
{
|
||||
app.calendar.state.cat_id = '';
|
||||
app_calendar.state.cat_id = '';
|
||||
labels.push({id:'',value:'',label: egw.lang('none'), main: '', data: {}});
|
||||
labels = labels.concat(categories);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cat_id = app.calendar.state.cat_id;
|
||||
var cat_id = app_calendar.state.cat_id;
|
||||
if(typeof cat_id == 'string')
|
||||
{
|
||||
cat_id = cat_id.split(',');
|
||||
@ -765,6 +766,7 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
},
|
||||
group: function(labels, rows, event) {
|
||||
var cats = event.category;
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if(typeof event.category === 'string')
|
||||
{
|
||||
cats = cats.split(',');
|
||||
@ -779,7 +781,7 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
if(labels[i].id == category)
|
||||
{
|
||||
// If there's no cat filter, only show the top level
|
||||
if(!app.calendar.state.cat_id)
|
||||
if(!app_calendar.state.cat_id)
|
||||
{
|
||||
for(var j = 0; j < labels.length; j++)
|
||||
{
|
||||
@ -958,13 +960,14 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
this.rows.height(this.div.height() - this.headers.outerHeight());
|
||||
|
||||
// Draw the rows
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
for(var key in labels)
|
||||
{
|
||||
if (!labels.hasOwnProperty(key)) continue;
|
||||
|
||||
// Skip sub-categories (events are merged into top level)
|
||||
if(this.options.group_by == 'category' &&
|
||||
(!app.calendar.state.cat_id || app.calendar.state.cat_id == '') &&
|
||||
(!app_calendar.state.cat_id || app_calendar.state.cat_id == '') &&
|
||||
labels[key].id != labels[key].main
|
||||
)
|
||||
{
|
||||
@ -1150,7 +1153,8 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
var t = new Date(start.valueOf());
|
||||
|
||||
// Make sure we're lining up on the week
|
||||
var week_end = app.calendar.date.end_of_week(start);
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
var week_end = app_calendar.date.end_of_week(start);
|
||||
var days_in_week = Math.floor(((week_end-start ) / (24*3600*1000))+1);
|
||||
var week_width = 100 / days * (days <= 7 ? days : days_in_week);
|
||||
for(var left = 0,i = 0; i < days; t.setUTCDate(t.getUTCDate() + 7),left += week_width)
|
||||
@ -1169,14 +1173,14 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
|
||||
|
||||
week_width = 100 / days * Math.min(days, days_in_week);
|
||||
|
||||
var title = this.egw().lang('Week')+' '+app.calendar.date.week_number(usertime);
|
||||
var title = this.egw().lang('Week')+' '+app_calendar.date.week_number(usertime);
|
||||
|
||||
if(start.getTimezoneOffset() > 0)
|
||||
{
|
||||
// Gets the right week start west of GMT
|
||||
usertime.setUTCMinutes(usertime.getUTCMinutes() +start.getTimezoneOffset());
|
||||
}
|
||||
state = app.calendar.date.start_of_week(usertime);
|
||||
state = app_calendar.date.start_of_week(usertime);
|
||||
state.setUTCHours(0);
|
||||
state.setUTCMinutes(0);
|
||||
state = state.toJSON();
|
||||
|
@ -814,11 +814,12 @@ var et2_calendar_timegrid = /** @class */ (function (_super) {
|
||||
*/
|
||||
et2_calendar_timegrid.prototype.set_header_classes = function () {
|
||||
var day;
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
for (var i = 0; i < this.day_widgets.length; i++) {
|
||||
day = this.day_widgets[i];
|
||||
// Classes
|
||||
if (app.calendar && app.calendar.state &&
|
||||
this.day_list[i] && parseInt(this.day_list[i].substr(4, 2)) !== new Date(app.calendar.state.date).getUTCMonth() + 1) {
|
||||
if (app_calendar && app_calendar.state &&
|
||||
this.day_list[i] && parseInt(this.day_list[i].substr(4, 2)) !== new Date(app_calendar.state.date).getUTCMonth() + 1) {
|
||||
day.set_class('calendar_differentMonth');
|
||||
}
|
||||
else {
|
||||
|
@ -1087,13 +1087,14 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet
|
||||
set_header_classes()
|
||||
{
|
||||
var day;
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
for(var i = 0; i < this.day_widgets.length; i++)
|
||||
{
|
||||
day = this.day_widgets[i];
|
||||
|
||||
// Classes
|
||||
if(app.calendar && app.calendar.state &&
|
||||
this.day_list[i] && parseInt(this.day_list[i].substr(4,2)) !== new Date(app.calendar.state.date).getUTCMonth()+1)
|
||||
if(app_calendar && app_calendar.state &&
|
||||
this.day_list[i] && parseInt(this.day_list[i].substr(4,2)) !== new Date(app_calendar.state.date).getUTCMonth()+1)
|
||||
{
|
||||
day.set_class('calendar_differentMonth');
|
||||
}
|
||||
|
@ -491,7 +491,8 @@ var et2_calendar_view = /** @class */ (function (_super) {
|
||||
jQuery.extend(options, this.drag_create.start, end);
|
||||
delete (options.date);
|
||||
// Make sure parent is set, if needed
|
||||
if (this.drag_create.parent && this.drag_create.parent.options.owner !== app.calendar.state.owner && !options.owner) {
|
||||
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if (this.drag_create.parent && this.drag_create.parent.options.owner !== app_calendar.state.owner && !options.owner) {
|
||||
options.owner = this.drag_create.parent.options.owner;
|
||||
}
|
||||
// Remove empties
|
||||
|
@ -619,7 +619,8 @@ export class et2_calendar_view extends et2_valueWidget
|
||||
delete(options.date);
|
||||
|
||||
// Make sure parent is set, if needed
|
||||
if (this.drag_create.parent && this.drag_create.parent.options.owner !== app.calendar.state.owner && !options.owner)
|
||||
let app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar;
|
||||
if (this.drag_create.parent && this.drag_create.parent.options.owner !== app_calendar.state.owner && !options.owner)
|
||||
{
|
||||
options.owner = this.drag_create.parent.options.owner;
|
||||
}
|
||||
|
@ -144,14 +144,15 @@ app.classes.home = (function(){ "use strict"; return AppJS.extend(
|
||||
}
|
||||
else if (et2.uniqueId)
|
||||
{
|
||||
let portlet_container = this.portlet_container || window.app.home?.portlet_container;
|
||||
// Handle bad timing - a sub-template was finished first
|
||||
if(!this.portlet_container)
|
||||
if(!portlet_container)
|
||||
{
|
||||
window.setTimeout(jQuery.proxy(function() {this.et2_ready(et2, name);},this),200);
|
||||
return;
|
||||
}
|
||||
|
||||
var portlet = this.portlet_container.getWidgetById(et2.uniqueId);
|
||||
var portlet = portlet_container.getWidgetById(et2.uniqueId);
|
||||
// Check for existing etemplate, this one loaded over it
|
||||
// NOTE: Moving them around like this can cause problems with event handlers
|
||||
var existing = etemplate2.getById(et2.uniqueId);
|
||||
|
Loading…
Reference in New Issue
Block a user