diff --git a/api/js/etemplate/et2_widget_portlet.js b/api/js/etemplate/et2_widget_portlet.js index 9ad2250f0c..5603c32327 100644 --- a/api/js/etemplate/et2_widget_portlet.js +++ b/api/js/etemplate/et2_widget_portlet.js @@ -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 diff --git a/api/js/etemplate/et2_widget_portlet.ts b/api/js/etemplate/et2_widget_portlet.ts index c2cdb15046..dfbb10bdcd 100644 --- a/api/js/etemplate/et2_widget_portlet.ts +++ b/api/js/etemplate/et2_widget_portlet.ts @@ -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); } /** diff --git a/api/js/etemplate/etemplate2.js b/api/js/etemplate/etemplate2.js index 351a889e3c..b54b4d6001 100644 --- a/api/js/etemplate/etemplate2.js +++ b/api/js/etemplate/etemplate2.js @@ -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()" diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index 98bbbf13c6..6f0dfed182 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -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}; } diff --git a/calendar/js/app.js b/calendar/js/app.js index 283d686172..ef46e7b442 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -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; } diff --git a/calendar/js/app.ts b/calendar/js/app.ts index adf2c0511b..1e9f18ddf3 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -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; } @@ -3803,7 +3806,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; } diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 3836a51d97..cb04bd2e00 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -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')) { diff --git a/calendar/js/et2_widget_event.ts b/calendar/js/et2_widget_event.ts index c9d1a06f0c..0ebbd749fb 100644 --- a/calendar/js/et2_widget_event.ts +++ b/calendar/js/et2_widget_event.ts @@ -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')) diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 75a09032da..1406e46c4f 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -354,15 +354,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(','); } @@ -395,6 +396,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(','); } @@ -406,7 +408,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; @@ -753,12 +755,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; } @@ -901,7 +904,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) { @@ -915,12 +919,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(); diff --git a/calendar/js/et2_widget_planner.ts b/calendar/js/et2_widget_planner.ts index f287916ead..2e153fc9bc 100644 --- a/calendar/js/et2_widget_planner.ts +++ b/calendar/js/et2_widget_planner.ts @@ -716,18 +716,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(','); @@ -772,6 +773,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(','); @@ -786,7 +788,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++) { @@ -965,13 +967,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 ) { @@ -1157,7 +1160,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) @@ -1176,14 +1180,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(); diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index e070db5967..0e33776fa3 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -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 { diff --git a/calendar/js/et2_widget_timegrid.ts b/calendar/js/et2_widget_timegrid.ts index 04674005c5..f806426de2 100644 --- a/calendar/js/et2_widget_timegrid.ts +++ b/calendar/js/et2_widget_timegrid.ts @@ -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'); } diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index 1e8c97ac1e..e9245bc72f 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -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 diff --git a/calendar/js/et2_widget_view.ts b/calendar/js/et2_widget_view.ts index b43b9ff1f2..e18e572935 100644 --- a/calendar/js/et2_widget_view.ts +++ b/calendar/js/et2_widget_view.ts @@ -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; } diff --git a/home/js/app.js b/home/js/app.js index 278d946c65..9ec00b7f24 100644 --- a/home/js/app.js +++ b/home/js/app.js @@ -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);