fixed all errors in calendar, thought it's still not ok

also fixed a couple of errors in egw_action
This commit is contained in:
Ralf Becker 2021-06-11 11:31:06 +02:00
parent 771d6c727f
commit 4752331427
20 changed files with 666 additions and 750 deletions

View File

@ -208,7 +208,7 @@ jQuery(window).on("contextmenu",document, function(event) {
/** /**
* Creates an unique key for the given shortcut * Creates an unique key for the given shortcut
*/ */
function egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt) export function egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt)
{ {
return "_" + _keyCode + "_" + return "_" + _keyCode + "_" +
(_shift ? "S" : "") + (_shift ? "S" : "") +
@ -229,7 +229,7 @@ var egw_registeredShortcuts = {}
* parameter. * parameter.
* @param object _context is the context in which the function will be executed * @param object _context is the context in which the function will be executed
*/ */
function egw_registerGlobalShortcut(_keyCode, _shift, _ctrl, _alt, _handler, _context) export function egw_registerGlobalShortcut(_keyCode, _shift, _ctrl, _alt, _handler, _context)
{ {
// Generate the hash map index for the shortcut // Generate the hash map index for the shortcut
var idx = egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt); var idx = egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt);
@ -250,7 +250,8 @@ function egw_registerGlobalShortcut(_keyCode, _shift, _ctrl, _alt, _handler, _co
/** /**
* Unregisters the given shortcut. * Unregisters the given shortcut.
*/ */
function egw_unregisterGlobalShortcut(_keyCode, _shift, _ctrl, _alt) { export function egw_unregisterGlobalShortcut(_keyCode, _shift, _ctrl, _alt)
{
// Generate the hash map index for the shortcut // Generate the hash map index for the shortcut
var idx = egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt); var idx = egw_shortcutIdx(_keyCode, _shift, _ctrl, _alt);

View File

@ -10,6 +10,7 @@
* @Todo: @new-js-loader port to TypeScript * @Todo: @new-js-loader port to TypeScript
*/ */
import {egwMenuImpl} from './egw_menu_dhtmlx.js'; import {egwMenuImpl} from './egw_menu_dhtmlx.js';
import {egw_shortcutIdx} from './egw_keymanager.js';
//Global variable which is used to store the currently active menu so that it //Global variable which is used to store the currently active menu so that it
//may be closed when another menu openes //may be closed when another menu openes
export var _egw_active_menu = null; export var _egw_active_menu = null;
@ -221,7 +222,7 @@ egwMenu.prototype.keyHandler = function(_keyCode, _shift, _ctrl, _alt)
{ {
for(let i = 0; i < child.children.length; i++) for(let i = 0; i < child.children.length; i++)
{ {
result = find_func(child.children[i]); const result = find_func(child.children[i]);
if(result) return result; if(result) return result;
} }
} }
@ -257,7 +258,7 @@ egwMenu.prototype.keyHandler = function(_keyCode, _shift, _ctrl, _alt)
break; break;
case EGW_KEY_ARROW_UP: case EGW_KEY_ARROW_UP:
case EGW_KEY_ARROW_DOWN: case EGW_KEY_ARROW_DOWN:
direction = _keyCode === EGW_KEY_ARROW_DOWN ? 1 : -1; const direction = _keyCode === EGW_KEY_ARROW_DOWN ? 1 : -1;
let parent = current.parent; let parent = current.parent;
let index = parent.children.indexOf(current); let index = parent.children.indexOf(current);
let cont = false; let cont = false;

View File

@ -1,39 +1,21 @@
"use strict"; export class View {
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.listview = exports.planner = exports.month = exports.weekN = exports.week = exports.day4 = exports.day = exports.View = void 0;
var View = /** @class */ (function () {
function View() {
}
/** /**
* Translated label for header * Translated label for header
* @param {Object} state * @param {Object} state
* @returns {string} * @returns {string}
*/ */
View.header = function (state) { static header(state) {
var formatDate = new Date(state.date); let formatDate = new Date(state.date);
formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000); formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000);
return View._owner(state) + date(egw.preference('dateformat'), formatDate); return View._owner(state) + date(egw.preference('dateformat'), formatDate);
}; }
/** /**
* If one owner, get the owner text * If one owner, get the owner text
* *
* @param {object} state * @param {object} state
*/ */
View._owner = function (state) { static _owner(state) {
var owner = ''; let owner = '';
if (state.owner.length && state.owner.length == 1 && app.calendar.sidebox_et2) { if (state.owner.length && state.owner.length == 1 && app.calendar.sidebox_et2) {
var own = app.calendar.sidebox_et2.getWidgetById('owner').getDOMNode(); var own = app.calendar.sidebox_et2.getWidgetById('owner').getDOMNode();
if (own.selectedIndex >= 0) { if (own.selectedIndex >= 0) {
@ -41,33 +23,33 @@ var View = /** @class */ (function () {
} }
} }
return owner; return owner;
}; }
/** /**
* Get the start date for this view * Get the start date for this view
* @param {Object} state * @param {Object} state
* @returns {Date} * @returns {Date}
*/ */
View.start_date = function (state) { static start_date(state) {
var d = state.date ? new Date(state.date) : new Date(); const d = state.date ? new Date(state.date) : new Date();
d.setUTCHours(0); d.setUTCHours(0);
d.setUTCMinutes(0); d.setUTCMinutes(0);
d.setUTCSeconds(0); d.setUTCSeconds(0);
d.setUTCMilliseconds(0); d.setUTCMilliseconds(0);
return d; return d;
}; }
/** /**
* Get the end date for this view * Get the end date for this view
* @param {Object} state * @param {Object} state
* @returns {Date} * @returns {Date}
*/ */
View.end_date = function (state) { static end_date(state) {
var d = state.date ? new Date(state.date) : new Date(); const d = state.date ? new Date(state.date) : new Date();
d.setUTCHours(23); d.setUTCHours(23);
d.setUTCMinutes(59); d.setUTCMinutes(59);
d.setUTCSeconds(59); d.setUTCSeconds(59);
d.setUTCMilliseconds(0); d.setUTCMilliseconds(0);
return d; return d;
}; }
/** /**
* Get the owner for this view * Get the owner for this view
* *
@ -77,24 +59,24 @@ var View = /** @class */ (function () {
* @param {number[]|String} state state.owner List of owner IDs, or a comma seperated list * @param {number[]|String} state state.owner List of owner IDs, or a comma seperated list
* @returns {number[]|String} * @returns {number[]|String}
*/ */
View.owner = function (state) { static owner(state) {
return state.owner || 0; return state.owner || 0;
}; }
/** /**
* Should the view show the weekends * Should the view show the weekends
* *
* @param {object} state * @param {object} state
* @returns {boolean} Current preference to show 5 or 7 days in weekview * @returns {boolean} Current preference to show 5 or 7 days in weekview
*/ */
View.show_weekend = function (state) { static show_weekend(state) {
return state.weekend; return state.weekend;
}; }
/** /**
* How big or small are the displayed time chunks? * How big or small are the displayed time chunks?
* *
* @param {object} state * @param {object} state
*/ */
View.granularity = function (state) { static granularity(state) {
var list = egw.preference('use_time_grid', 'calendar'); var list = egw.preference('use_time_grid', 'calendar');
if (list == '0' || typeof list === 'undefined') { if (list == '0' || typeof list === 'undefined') {
return parseInt('' + egw.preference('interval', 'calendar')) || 30; return parseInt('' + egw.preference('interval', 'calendar')) || 30;
@ -109,10 +91,10 @@ var View = /** @class */ (function () {
return list.indexOf(state.view) >= 0 ? return list.indexOf(state.view) >= 0 ?
0 : 0 :
parseInt(egw.preference('interval', 'calendar')) || 30; parseInt(egw.preference('interval', 'calendar')) || 30;
}; }
View.extend = function (sub) { static extend(sub) {
return jQuery.extend({}, this, { _super: this }, sub); return jQuery.extend({}, this, { _super: this }, sub);
}; }
/** /**
* Determines the new date after scrolling. The default is 1 week. * Determines the new date after scrolling. The default is 1 week.
* *
@ -120,94 +102,76 @@ var View = /** @class */ (function () {
* forward, negative for backward * forward, negative for backward
* @returns {Date} * @returns {Date}
*/ */
View.scroll = function (delta) { static scroll(delta) {
var d = new Date(app.calendar.state.date); var d = new Date(app.calendar.state.date);
d.setUTCDate(d.getUTCDate() + (7 * delta)); d.setUTCDate(d.getUTCDate() + (7 * delta));
return d; return d;
}; }
// List of etemplates to show for this view }
View.etemplates = ['calendar.view']; // List of etemplates to show for this view
return View; View.etemplates = ['calendar.view'];
}());
exports.View = View;
/** /**
* Etemplates and settings for the different views. Some (day view) * Etemplates and settings for the different views. Some (day view)
* use more than one template, some use the same template as others, * use more than one template, some use the same template as others,
* most need different handling for their various attributes. * most need different handling for their various attributes.
*/ */
var day = /** @class */ (function (_super_1) { export class day extends View {
__extends(day, _super_1); static header(state) {
function day() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
}
day.header = function (state) {
var formatDate = new Date(state.date); var formatDate = new Date(state.date);
formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000); formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000);
return date('l, ', formatDate) + _super_1.header.call(this, state); return date('l, ', formatDate) + super.header(state);
}; }
day.start_date = function (state) { static start_date(state) {
var d = _super_1.start_date.call(this, state); var d = super.start_date(state);
state.date = app.calendar.date.toString(d); state.date = app.calendar.date.toString(d);
return d; return d;
}; }
day.show_weekend = function (state) { static show_weekend(state) {
state.days = '1'; state.days = '1';
return true; return true;
}; }
day.scroll = function (delta) { static scroll(delta) {
var d = new Date(app.calendar.state.date); var d = new Date(app.calendar.state.date);
d.setUTCDate(d.getUTCDate() + (delta)); d.setUTCDate(d.getUTCDate() + (delta));
return d; return d;
};
day.etemplates = ['calendar.view', 'calendar.todo'];
return day;
}(View));
exports.day = day;
var day4 = /** @class */ (function (_super_1) {
__extends(day4, _super_1);
function day4() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
day4.end_date = function (state) { }
var d = _super_1.end_date.call(this, state); day.etemplates = ['calendar.view', 'calendar.todo'];
export class day4 extends View {
static end_date(state) {
var d = super.end_date(state);
state.days = '4'; state.days = '4';
d.setUTCHours(24 * 4 - 1); d.setUTCHours(24 * 4 - 1);
d.setUTCMinutes(59); d.setUTCMinutes(59);
d.setUTCSeconds(59); d.setUTCSeconds(59);
d.setUTCMilliseconds(0); d.setUTCMilliseconds(0);
return d; return d;
}; }
day4.show_weekend = function (state) { static show_weekend(state) {
state.weekend = 'true'; state.weekend = 'true';
return true; return true;
}; }
day4.scroll = function (delta) { static scroll(delta) {
var d = new Date(app.calendar.state.date); var d = new Date(app.calendar.state.date);
d.setUTCDate(d.getUTCDate() + (4 * delta)); d.setUTCDate(d.getUTCDate() + (4 * delta));
return d; return d;
};
return day4;
}(View));
exports.day4 = day4;
var week = /** @class */ (function (_super_1) {
__extends(week, _super_1);
function week() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
week.header = function (state) { }
export class week extends View {
static header(state) {
var end_date = state.last; var end_date = state.last;
if (!week.show_weekend(state)) { if (!week.show_weekend(state)) {
end_date = new Date(state.last); end_date = new Date(state.last);
end_date.setUTCDate(end_date.getUTCDate() - 2); end_date.setUTCDate(end_date.getUTCDate() - 2);
} }
return _super_1._owner.call(this, state) + app.calendar.egw.lang('Week') + ' ' + return super._owner(state) + app.calendar.egw.lang('Week') + ' ' +
app.calendar.date.week_number(state.first) + ': ' + app.calendar.date.week_number(state.first) + ': ' +
app.calendar.date.long_date(state.first, end_date); app.calendar.date.long_date(state.first, end_date);
}; }
week.start_date = function (state) { static start_date(state) {
return app.calendar.date.start_of_week(_super_1.start_date.call(this, state)); return app.calendar.date.start_of_week(super.start_date(state));
}; }
week.end_date = function (state) { static end_date(state) {
var d = app.calendar.date.start_of_week(state.date || new Date()); var d = app.calendar.date.start_of_week(state.date || new Date());
// Always 7 days, we just turn weekends on or off // Always 7 days, we just turn weekends on or off
d.setUTCHours(24 * 7 - 1); d.setUTCHours(24 * 7 - 1);
@ -215,87 +179,69 @@ var week = /** @class */ (function (_super_1) {
d.setUTCSeconds(59); d.setUTCSeconds(59);
d.setUTCMilliseconds(0); d.setUTCMilliseconds(0);
return d; return d;
};
return week;
}(View));
exports.week = week;
var weekN = /** @class */ (function (_super_1) {
__extends(weekN, _super_1);
function weekN() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
weekN.header = function (state) { }
return _super_1._owner.call(this, state) + app.calendar.egw.lang('Week') + ' ' + export class weekN extends View {
static header(state) {
return super._owner(state) + app.calendar.egw.lang('Week') + ' ' +
app.calendar.date.week_number(state.first) + ' - ' + app.calendar.date.week_number(state.first) + ' - ' +
app.calendar.date.week_number(state.last) + ': ' + app.calendar.date.week_number(state.last) + ': ' +
app.calendar.date.long_date(state.first, state.last); app.calendar.date.long_date(state.first, state.last);
}; }
weekN.start_date = function (state) { static start_date(state) {
return app.calendar.date.start_of_week(_super_1.start_date.call(this, state)); return app.calendar.date.start_of_week(super.start_date(state));
}; }
weekN.end_date = function (state) { static end_date(state) {
state.days = '' + (state.days >= 5 ? state.days : egw.preference('days_in_weekview', 'calendar') || 7); state.days = '' + (state.days >= 5 ? state.days : egw.preference('days_in_weekview', 'calendar') || 7);
var d = app.calendar.date.start_of_week(_super_1.start_date.call(this, state)); var d = app.calendar.date.start_of_week(super.start_date(state));
// Always 7 days, we just turn weekends on or off // Always 7 days, we just turn weekends on or off
d.setUTCHours(24 * 7 * (parseInt(app.calendar.egw.preference('multiple_weeks', 'calendar')) || 3) - 1); d.setUTCHours(24 * 7 * (parseInt(app.calendar.egw.preference('multiple_weeks', 'calendar')) || 3) - 1);
return d; return d;
};
return weekN;
}(View));
exports.weekN = weekN;
var month = /** @class */ (function (_super_1) {
__extends(month, _super_1);
function month() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
month.header = function (state) { }
export class month extends View {
static header(state) {
var formatDate = new Date(state.date); var formatDate = new Date(state.date);
formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000); formatDate = new Date(formatDate.valueOf() + formatDate.getTimezoneOffset() * 60 * 1000);
return _super_1._owner.call(this, state) + app.calendar.egw.lang(date('F', formatDate)) + ' ' + date('Y', formatDate); return super._owner(state) + app.calendar.egw.lang(date('F', formatDate)) + ' ' + date('Y', formatDate);
}; }
month.start_date = function (state) { static start_date(state) {
var d = _super_1.start_date.call(this, state); var d = super.start_date(state);
d.setUTCDate(1); d.setUTCDate(1);
return app.calendar.date.start_of_week(d); return app.calendar.date.start_of_week(d);
}; }
month.end_date = function (state) { static end_date(state) {
var d = _super_1.end_date.call(this, state); var d = super.end_date(state);
d = new Date(d.getFullYear(), d.getUTCMonth() + 1, 1, 0, -d.getTimezoneOffset(), 0); d = new Date(d.getFullYear(), d.getUTCMonth() + 1, 1, 0, -d.getTimezoneOffset(), 0);
d.setUTCSeconds(d.getUTCSeconds() - 1); d.setUTCSeconds(d.getUTCSeconds() - 1);
return app.calendar.date.end_of_week(d); return app.calendar.date.end_of_week(d);
}; }
month.scroll = function (delta) { static scroll(delta) {
var d = new Date(app.calendar.state.date); var d = new Date(app.calendar.state.date);
// Set day to 15 so we don't get overflow on short months // Set day to 15 so we don't get overflow on short months
// eg. Aug 31 + 1 month = Sept 31 -> Oct 1 // eg. Aug 31 + 1 month = Sept 31 -> Oct 1
d.setUTCDate(15); d.setUTCDate(15);
d.setUTCMonth(d.getUTCMonth() + delta); d.setUTCMonth(d.getUTCMonth() + delta);
return d; return d;
};
return month;
}(View));
exports.month = month;
var planner = /** @class */ (function (_super_1) {
__extends(planner, _super_1);
function planner() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
planner.header = function (state) { }
export class planner extends View {
static header(state) {
var startDate = new Date(state.first); var startDate = new Date(state.first);
startDate = new Date(startDate.valueOf() + startDate.getTimezoneOffset() * 60 * 1000); startDate = new Date(startDate.valueOf() + startDate.getTimezoneOffset() * 60 * 1000);
var endDate = new Date(state.last); var endDate = new Date(state.last);
endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000); endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000);
return _super_1._owner.call(this, state) + date(egw.preference('dateformat'), startDate) + return super._owner(state) + date(egw.preference('dateformat'), startDate) +
(startDate == endDate ? '' : ' - ' + date(egw.preference('dateformat'), endDate)); (startDate == endDate ? '' : ' - ' + date(egw.preference('dateformat'), endDate));
}; }
planner.group_by = function (state) { static group_by(state) {
return state.sortby ? state.sortby : 0; return state.sortby ? state.sortby : 0;
}; }
// Note: Planner uses the additional value of planner_view to determine // Note: Planner uses the additional value of planner_view to determine
// the start & end dates using other view's functions // the start & end dates using other view's functions
planner.start_date = function (state) { static start_date(state) {
// Start here, in case we can't find anything better // Start here, in case we can't find anything better
var d = _super_1.start_date.call(this, state); var d = super.start_date(state);
if (state.sortby && state.sortby === 'month') { if (state.sortby && state.sortby === 'month') {
d.setUTCDate(1); d.setUTCDate(1);
} }
@ -311,9 +257,9 @@ var planner = /** @class */ (function (_super_1) {
return d; return d;
} }
return d; return d;
}; }
planner.end_date = function (state) { static end_date(state) {
var d = _super_1.end_date.call(this, state); var d = super.end_date(state);
if (state.sortby && state.sortby === 'month') { if (state.sortby && state.sortby === 'month') {
d.setUTCDate(0); d.setUTCDate(0);
d.setUTCFullYear(d.getUTCFullYear() + 1); d.setUTCFullYear(d.getUTCFullYear() + 1);
@ -330,17 +276,17 @@ var planner = /** @class */ (function (_super_1) {
d = app.calendar.date.end_of_week(d); d = app.calendar.date.end_of_week(d);
} }
return d; return d;
}; }
planner.hide_empty = function (state) { static hide_empty(state) {
var check = state.sortby == 'user' ? ['user', 'both'] : ['cat', 'both']; var check = state.sortby == 'user' ? ['user', 'both'] : ['cat', 'both'];
return (check.indexOf(egw.preference('planner_show_empty_rows', 'calendar') + '') === -1); return (check.indexOf(egw.preference('planner_show_empty_rows', 'calendar') + '') === -1);
}; }
planner.scroll = function (delta) { static scroll(delta) {
if (app.calendar.state.planner_view && !isNaN(delta) && app.calendar.state.sortby !== "month") { if (app.calendar.state.planner_view && !isNaN(delta) && app.calendar.state.sortby !== "month") {
return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta); return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta);
} }
var d = new Date(app.calendar.state.date); let d = new Date(app.calendar.state.date);
var days = 1; let days = 1;
delta = parseInt(delta) || 0; delta = parseInt(delta) || 0;
// Yearly view, grouped by month - scroll 1 month // Yearly view, grouped by month - scroll 1 month
if (app.calendar.state.sortby === 'month') { if (app.calendar.state.sortby === 'month') {
@ -354,7 +300,7 @@ var planner = /** @class */ (function (_super_1) {
// makes things buggy // makes things buggy
if (app.calendar.state.first && app.calendar.state.last) { if (app.calendar.state.first && app.calendar.state.last) {
//@ts-ignore //@ts-ignore
var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first); let diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first);
days = Math.round(diff / (1000 * 3600 * 24)); days = Math.round(diff / (1000 * 3600 * 24));
} }
d.setUTCDate(d.getUTCDate() + (days * delta)); d.setUTCDate(d.getUTCDate() + (days * delta));
@ -362,29 +308,21 @@ var planner = /** @class */ (function (_super_1) {
d = app.calendar.date.start_of_week(d); d = app.calendar.date.start_of_week(d);
} }
return d; return d;
};
planner.etemplates = ['calendar.planner'];
return planner;
}(View));
exports.planner = planner;
var listview = /** @class */ (function (_super_1) {
__extends(listview, _super_1);
function listview() {
return _super_1 !== null && _super_1.apply(this, arguments) || this;
} }
listview.header = function (state) { }
planner.etemplates = ['calendar.planner'];
export class listview extends View {
static header(state) {
var startDate = new Date(state.first || state.date); var startDate = new Date(state.first || state.date);
startDate = new Date(startDate.valueOf() + startDate.getTimezoneOffset() * 60 * 1000); startDate = new Date(startDate.valueOf() + startDate.getTimezoneOffset() * 60 * 1000);
var start_check = '' + startDate.getFullYear() + startDate.getMonth() + startDate.getDate(); var start_check = '' + startDate.getFullYear() + startDate.getMonth() + startDate.getDate();
var endDate = new Date(state.last || state.date); var endDate = new Date(state.last || state.date);
endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000); endDate = new Date(endDate.valueOf() + endDate.getTimezoneOffset() * 60 * 1000);
var end_check = '' + endDate.getFullYear() + endDate.getMonth() + endDate.getDate(); var end_check = '' + endDate.getFullYear() + endDate.getMonth() + endDate.getDate();
return _super_1._owner.call(this, state) + return super._owner(state) +
date(egw.preference('dateformat'), startDate) + date(egw.preference('dateformat'), startDate) +
(start_check == end_check ? '' : ' - ' + date(egw.preference('dateformat'), endDate)); (start_check == end_check ? '' : ' - ' + date(egw.preference('dateformat'), endDate));
}; }
listview.etemplates = ['calendar.list']; }
return listview; listview.etemplates = ['calendar.list'];
}(View));
exports.listview = listview;
//# sourceMappingURL=View.js.map //# sourceMappingURL=View.js.map

View File

@ -2,6 +2,12 @@
* Super class for the different views. * Super class for the different views.
* *
* Each separate view overrides what it needs * Each separate view overrides what it needs
*
* @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar
* @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray
*/ */
import {etemplate2} from "../../api/js/etemplate/etemplate2"; import {etemplate2} from "../../api/js/etemplate/etemplate2";

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,12 @@
/** /**
* EGroupware - Calendar - Javascript UI * EGroupware - Calendar - Javascript UI
* *
* @link http://www.egroupware.org * @link https://www.egroupware.org
* @package calendar * @package calendar
* @author Hadi Nategh <hn-AT-stylite.de> * @author Hadi Nategh <hn-AT-egroupware.org>
* @author Nathan Gray * @author Nathan Gray
* @copyright (c) 2008-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2008-21 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -37,6 +36,19 @@ import {et2_selectbox} from "../../api/js/etemplate/et2_widget_selectbox";
import {et2_widget} from "../../api/js/etemplate/et2_core_widget"; import {et2_widget} from "../../api/js/etemplate/et2_core_widget";
import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch"; import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch";
import {et2_inputWidget} from "../../api/js/etemplate/et2_core_inputWidget"; import {et2_inputWidget} from "../../api/js/etemplate/et2_core_inputWidget";
import {et2_iframe} from "../../api/js/etemplate/et2_widget_iframe";
import {date} from "../../api/js/etemplate/lib/date.js";
import {sprintf} from "../../api/js/egw_action/egw_action_common.js";
import {egw_registerGlobalShortcut} from "";
// et2 widgets need to be imported, so they register themselves
import "./et2_widget_daycol";
import "./et2_widget_event";
import "./et2_widget_owner";
import "./et2_widget_planner";
import "./et2_widget_planner_row";
import "./et2_widget_timegrid";
import "./et2_widget_view";
/** /**
* UI for calendar * UI for calendar
@ -60,7 +72,7 @@ import {et2_inputWidget} from "../../api/js/etemplate/et2_core_inputWidget";
* changed, we discard the daywise cache and ask the server for the filtered events. * changed, we discard the daywise cache and ask the server for the filtered events.
* *
*/ */
class CalendarApp extends EgwApp export class CalendarApp extends EgwApp
{ {
/** /**

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
et2_core_valueWidget; et2_core_valueWidget;
@ -20,6 +20,8 @@ import { ClassWithAttributes } from "../../api/js/etemplate/et2_core_inheritance
import { et2_no_init } from "../../api/js/etemplate/et2_core_common"; import { et2_no_init } from "../../api/js/etemplate/et2_core_common";
import { egw } from "../../api/js/jsapi/egw_global"; import { egw } from "../../api/js/jsapi/egw_global";
import { egwIsMobile } from "../../api/js/egw_action/egw_action_common.js"; import { egwIsMobile } from "../../api/js/egw_action/egw_action_common.js";
import { CalendarApp } from "./app";
import { sprintf } from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-timegrid" XET-Tag for displaying a single days * Class which implements the "calendar-timegrid" XET-Tag for displaying a single days
* *

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
@ -25,6 +25,8 @@ import {et2_IDetachedDOM, et2_IResizeable} from "../../api/js/etemplate/et2_core
import {et2_no_init} from "../../api/js/etemplate/et2_core_common"; import {et2_no_init} from "../../api/js/etemplate/et2_core_common";
import {egw} from "../../api/js/jsapi/egw_global"; import {egw} from "../../api/js/jsapi/egw_global";
import {egwIsMobile} from "../../api/js/egw_action/egw_action_common.js"; import {egwIsMobile} from "../../api/js/egw_action/egw_action_common.js";
import {CalendarApp} from "./app";
import {sprintf} from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-timegrid" XET-Tag for displaying a single days * Class which implements the "calendar-timegrid" XET-Tag for displaying a single days

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar event widget * Egroupware Calendar event widget
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
/etemplate/js/et2_core_valueWidget; /etemplate/js/et2_core_valueWidget;

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar event widget * Egroupware Calendar event widget
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */

View File

@ -1,32 +1,17 @@
"use strict";
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_calendar_owner = void 0;
/*egw:uses /*egw:uses
et2_widget_taglist; et2_widget_taglist;
*/ */
var et2_core_widget_1 = require("../../api/js/etemplate/et2_core_widget"); import { et2_register_widget } from "../../api/js/etemplate/et2_core_widget";
import { et2_taglist_email } from "../../api/js/etemplate/et2_widget_taglist";
/** /**
* Tag list widget customised for calendar owner, which can be a user * Tag list widget customised for calendar owner, which can be a user
* account or group, or an entry from almost any app, or an email address * account or group, or an entry from almost any app, or an email address
@ -37,12 +22,11 @@ var et2_core_widget_1 = require("../../api/js/etemplate/et2_core_widget");
* @see http://nicolasbize.github.io/magicsuggest/ * @see http://nicolasbize.github.io/magicsuggest/
* @augments et2_selectbox * @augments et2_selectbox
*/ */
var et2_calendar_owner = /** @class */ (function (_super) { export class et2_calendar_owner extends et2_taglist_email {
__extends(et2_calendar_owner, _super); constructor() {
function et2_calendar_owner() { super(...arguments);
var _this = _super !== null && _super.apply(this, arguments) || this;
// Allows sub-widgets to override options to the library // Allows sub-widgets to override options to the library
_this.lib_options = { this.lib_options = {
autoSelect: false, autoSelect: false,
groupBy: 'app', groupBy: 'app',
minChars: 2, minChars: 2,
@ -52,18 +36,17 @@ var et2_calendar_owner = /** @class */ (function (_super) {
//expandOnFocus: true //expandOnFocus: true
toggleOnClick: true toggleOnClick: true
}; };
return _this;
} }
et2_calendar_owner.prototype.doLoadingFinished = function () { doLoadingFinished() {
_super.prototype.doLoadingFinished.call(this); super.doLoadingFinished();
var widget = this; var widget = this;
// onChange fired when losing focus, which is different from normal // onChange fired when losing focus, which is different from normal
this._oldValue = this.taglist.getValue(); this._oldValue = this.taglist.getValue();
return true; return true;
}; }
et2_calendar_owner.prototype.selectionRenderer = function (item) { selectionRenderer(item) {
if (this && this.options && this.options.allowFreeEntries) { if (this && this.options && this.options.allowFreeEntries) {
return _super.prototype.selectionRenderer.call(this, item); return super.selectionRenderer(item);
} }
else { else {
var label = jQuery('<span>').text(item.label); var label = jQuery('<span>').text(item.label);
@ -84,12 +67,12 @@ var et2_calendar_owner = /** @class */ (function (_super) {
} }
return label; return label;
} }
}; }
et2_calendar_owner.prototype.getValue = function () { getValue() {
if (this.taglist == null) if (this.taglist == null)
return null; return null;
return this.taglist.getValue(); return this.taglist.getValue();
}; }
/** /**
* Override parent to handle our special additional data types (c#,r#,etc.) when they * Override parent to handle our special additional data types (c#,r#,etc.) when they
* are not available client side. * are not available client side.
@ -97,11 +80,11 @@ var et2_calendar_owner = /** @class */ (function (_super) {
* @param {string|string[]} _value array of selected owners, which can be a number, * @param {string|string[]} _value array of selected owners, which can be a number,
* or a number prefixed with one character indicating the resource type. * or a number prefixed with one character indicating the resource type.
*/ */
et2_calendar_owner.prototype.set_value = function (_value) { set_value(_value) {
_super.prototype.set_value.call(this, _value); super.set_value(_value);
// If parent didn't find a label, label will be the same as ID so we // If parent didn't find a label, label will be the same as ID so we
// can find them that way // can find them that way
var missing_labels = []; let missing_labels = [];
for (var i = 0; i < this.options.value.length; i++) { for (var i = 0; i < this.options.value.length; i++) {
var value = this.options.value[i]; var value = this.options.value[i];
if (value.id == value.label) { if (value.id == value.label) {
@ -111,19 +94,15 @@ var et2_calendar_owner = /** @class */ (function (_super) {
if (Object.keys(missing_labels).length > 0) { if (Object.keys(missing_labels).length > 0) {
// Proper label was not found by parent - ask directly // Proper label was not found by parent - ask directly
egw.json('calendar_owner_etemplate_widget::ajax_owner', [missing_labels], function (data) { egw.json('calendar_owner_etemplate_widget::ajax_owner', [missing_labels], function (data) {
var _loop_1 = function (owner) { for (let owner in data) {
if (!owner || typeof owner == "undefined") if (!owner || typeof owner == "undefined")
return "continue"; continue;
var idx = this_1.options.value.find(function (element) { return element.id == owner; }); let idx = this.options.value.find(element => element.id == owner);
if (idx) { if (idx) {
idx = jQuery.extend(idx, data[owner]); idx = jQuery.extend(idx, data[owner]);
} }
// Put it in the list of options for next time // Put it in the list of options for next time
this_1.options.select_options.push(data[owner]); this.options.select_options.push(data[owner]);
};
var this_1 = this;
for (var owner in data) {
_loop_1(owner);
} }
this.set_value(this.options.value); this.set_value(this.options.value);
}, this, true, this).sendRequest(); }, this, true, this).sendRequest();
@ -132,31 +111,29 @@ var et2_calendar_owner = /** @class */ (function (_super) {
this.taglist.clear(true); this.taglist.clear(true);
this.taglist.addToSelection(this.options.value, true); this.taglist.addToSelection(this.options.value, true);
} }
}; }
et2_calendar_owner._attributes = { }
"autocomplete_url": { et2_calendar_owner._attributes = {
"default": "calendar_owner_etemplate_widget::ajax_owner" "autocomplete_url": {
}, "default": "calendar_owner_etemplate_widget::ajax_owner"
"autocomplete_params": { },
"name": "Autocomplete parameters", "autocomplete_params": {
"type": "any", "name": "Autocomplete parameters",
"default": {}, "type": "any",
"description": "Extra parameters passed to autocomplete URL. It should be a stringified JSON object." "default": {},
}, "description": "Extra parameters passed to autocomplete URL. It should be a stringified JSON object."
allowFreeEntries: { },
"default": false, allowFreeEntries: {
ignore: true "default": false,
}, ignore: true
select_options: { },
"type": "any", select_options: {
"name": "Select options", "type": "any",
// Set to empty object to use selectbox's option finding "name": "Select options",
"default": {}, // Set to empty object to use selectbox's option finding
"description": "Internally used to hold the select options." "default": {},
} "description": "Internally used to hold the select options."
}; }
return et2_calendar_owner; };
}(et2_taglist_email)); et2_register_widget(et2_calendar_owner, ["calendar-owner"]);
exports.et2_calendar_owner = et2_calendar_owner;
et2_core_widget_1.et2_register_widget(et2_calendar_owner, ["calendar-owner"]);
//# sourceMappingURL=et2_widget_owner.js.map //# sourceMappingURL=et2_widget_owner.js.map

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
@ -13,9 +13,9 @@
et2_widget_taglist; et2_widget_taglist;
*/ */
import {et2_register_widget, WidgetConfig} from "../../api/js/etemplate/et2_core_widget"; import {et2_register_widget} from "../../api/js/etemplate/et2_core_widget";
import {ClassWithAttributes} from "../../api/js/etemplate/et2_core_inheritance";
import {et2_selectbox} from "../../api/js/etemplate/et2_widget_selectbox"; import {et2_selectbox} from "../../api/js/etemplate/et2_widget_selectbox";
import {et2_taglist_email} from "../../api/js/etemplate/et2_widget_taglist";
/** /**
* Tag list widget customised for calendar owner, which can be a user * Tag list widget customised for calendar owner, which can be a user

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar timegrid * Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
/calendar/js/et2_widget_view.js; /calendar/js/et2_widget_view.js;
@ -21,6 +21,9 @@ import { et2_calendar_planner_row } from "./et2_widget_planner_row";
import { egw } from "../../api/js/jsapi/egw_global"; import { egw } from "../../api/js/jsapi/egw_global";
import { EGW_AI_DRAG_OVER, EGW_AO_FLAG_IS_CONTAINER, egw_getObjectManager, egwActionObject } from "../../api/js/egw_action/egw_action.js"; import { EGW_AI_DRAG_OVER, EGW_AO_FLAG_IS_CONTAINER, egw_getObjectManager, egwActionObject } from "../../api/js/egw_action/egw_action.js";
import { et2_compileLegacyJS } from "../../api/js/etemplate/et2_core_legacyJSFunctions"; import { et2_compileLegacyJS } from "../../api/js/etemplate/et2_core_legacyJSFunctions";
import { et2_no_init } from "../../api/js/etemplate/et2_core_common";
import { CalendarApp } from "./app";
import { sprintf } from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-planner" XET-Tag for displaying a longer * Class which implements the "calendar-planner" XET-Tag for displaying a longer
* ( > 10 days) span of time. Events can be grouped into rows by either user, * ( > 10 days) span of time. Events can be grouped into rows by either user,

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar timegrid * Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
@ -25,6 +25,9 @@ import {egw} from "../../api/js/jsapi/egw_global";
import {EGW_AI_DRAG_OVER, EGW_AO_FLAG_IS_CONTAINER, egw_getObjectManager, egwActionObject} from "../../api/js/egw_action/egw_action.js"; import {EGW_AI_DRAG_OVER, EGW_AO_FLAG_IS_CONTAINER, egw_getObjectManager, egwActionObject} from "../../api/js/egw_action/egw_action.js";
import {et2_IDetachedDOM, et2_IPrint, et2_IResizeable} from "../../api/js/etemplate/et2_core_interfaces"; import {et2_IDetachedDOM, et2_IPrint, et2_IResizeable} from "../../api/js/etemplate/et2_core_interfaces";
import {et2_compileLegacyJS} from "../../api/js/etemplate/et2_core_legacyJSFunctions"; import {et2_compileLegacyJS} from "../../api/js/etemplate/et2_core_legacyJSFunctions";
import {et2_no_init} from "../../api/js/etemplate/et2_core_common";
import {CalendarApp} from "./app";
import {sprintf} from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-planner" XET-Tag for displaying a longer * Class which implements the "calendar-planner" XET-Tag for displaying a longer

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
/calendar/js/et2_widget_view.js; /calendar/js/et2_widget_view.js;

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -76,7 +76,7 @@ export class et2_calendar_planner_row extends et2_valueWidget implements et2_IRe
this.setDOMNode(this.div[0]); this.setDOMNode(this.div[0]);
// Used for its date calculations // Used for its date calculations
this._date_helper = et2_createWidget('date-time', {}, null); this._date_helper = <et2_date>et2_createWidget('date-time', {}, null);
this._date_helper.loadingFinished(); this._date_helper.loadingFinished();
this.set_start_date(this.options.start_date); this.set_start_date(this.options.start_date);

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar timegrid * Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
/calendar/js/et2_widget_view.js; /calendar/js/et2_widget_view.js;
@ -22,6 +22,8 @@ import { et2_IResizeable } from "../../api/js/etemplate/et2_core_interfaces";
import { et2_calendar_event } from "./et2_widget_event"; import { et2_calendar_event } from "./et2_widget_event";
import { EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT, egwActionObject, egw_getObjectManager } from "../../api/js/egw_action/egw_action.js"; import { EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT, egwActionObject, egw_getObjectManager } from "../../api/js/egw_action/egw_action.js";
import { et2_compileLegacyJS } from "../../api/js/etemplate/et2_core_legacyJSFunctions"; import { et2_compileLegacyJS } from "../../api/js/etemplate/et2_core_legacyJSFunctions";
import { et2_dialog } from "../../api/js/etemplate/et2_widget_dialog";
import { sprintf } from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-timegrid" XET-Tag for displaying a span of days * Class which implements the "calendar-timegrid" XET-Tag for displaying a span of days
* *

View File

@ -1,11 +1,11 @@
/* /*
* Egroupware Calendar timegrid * Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package etemplate * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage api * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
@ -25,6 +25,8 @@ import {et2_IDetachedDOM, et2_IPrint, et2_IResizeable} from "../../api/js/etempl
import {et2_calendar_event} from "./et2_widget_event"; import {et2_calendar_event} from "./et2_widget_event";
import {EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT, egwActionObject, egw_getObjectManager} from "../../api/js/egw_action/egw_action.js"; import {EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT, egwActionObject, egw_getObjectManager} from "../../api/js/egw_action/egw_action.js";
import {et2_compileLegacyJS} from "../../api/js/etemplate/et2_core_legacyJSFunctions"; import {et2_compileLegacyJS} from "../../api/js/etemplate/et2_core_legacyJSFunctions";
import {et2_dialog} from "../../api/js/etemplate/et2_widget_dialog";
import {sprintf} from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Class which implements the "calendar-timegrid" XET-Tag for displaying a span of days * Class which implements the "calendar-timegrid" XET-Tag for displaying a span of days

View File

@ -1,30 +1,20 @@
"use strict";
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
var __extends = (this && this.__extends) || (function () { /*egw:uses
var extendStatics = function (d, b) { /etemplate/js/et2_core_valueWidget;
extendStatics = Object.setPrototypeOf || */
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || import { et2_createWidget } from "../../api/js/etemplate/et2_core_widget";
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; import { et2_valueWidget } from "../../api/js/etemplate/et2_core_valueWidget";
return extendStatics(d, b); import { ClassWithAttributes } from "../../api/js/etemplate/et2_core_inheritance";
}; import { sprintf } from "../../api/js/egw_action/egw_action_common.js";
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_calendar_view = void 0;
var et2_core_valueWidget_1 = require("../../api/js/etemplate/et2_core_valueWidget");
var et2_core_inheritance_1 = require("../../api/js/etemplate/et2_core_inheritance");
/** /**
* Parent class for the various calendar views to reduce copied code * Parent class for the various calendar views to reduce copied code
* *
@ -34,37 +24,34 @@ var et2_core_inheritance_1 = require("../../api/js/etemplate/et2_core_inheritanc
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_calendar_view = /** @class */ (function (_super) { export class et2_calendar_view extends et2_valueWidget {
__extends(et2_calendar_view, _super);
/** /**
* Constructor * Constructor
* *
*/ */
function et2_calendar_view(_parent, _attrs, _child) { constructor(_parent, _attrs, _child) {
var _this =
// Call the inherited constructor // Call the inherited constructor
_super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_calendar_view._attributes, _child || {})) || this; super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_calendar_view._attributes, _child || {}));
_this.dataStorePrefix = 'calendar'; this.dataStorePrefix = 'calendar';
_this.update_timer = null; this.update_timer = null;
_this.now_timer = null; this.now_timer = null;
// Used for its date calculations // Used for its date calculations
_this._date_helper = et2_createWidget('date-time', {}, null); this._date_helper = et2_createWidget('date-time', {}, null);
_this._date_helper.loadingFinished(); this._date_helper.loadingFinished();
_this.loader = jQuery('<div class="egw-loading-prompt-container ui-front loading"></div>'); this.loader = jQuery('<div class="egw-loading-prompt-container ui-front loading"></div>');
_this.now_div = jQuery('<div class="calendar_now"/>'); this.now_div = jQuery('<div class="calendar_now"/>');
_this.update_timer = null; this.update_timer = null;
_this.now_timer = null; this.now_timer = null;
// Used to support dragging on empty space to create an event // Used to support dragging on empty space to create an event
_this.drag_create = { this.drag_create = {
start: null, start: null,
end: null, end: null,
parent: null, parent: null,
event: null event: null
}; };
return _this;
} }
et2_calendar_view.prototype.destroy = function () { destroy() {
_super.prototype.destroy.call(this); super.destroy();
// date_helper has no parent, so we must explicitly remove it // date_helper has no parent, so we must explicitly remove it
this._date_helper.destroy(); this._date_helper.destroy();
this._date_helper = null; this._date_helper = null;
@ -76,9 +63,9 @@ var et2_calendar_view = /** @class */ (function (_super) {
if (this.now_timer) { if (this.now_timer) {
window.clearInterval(this.now_timer); window.clearInterval(this.now_timer);
} }
}; }
et2_calendar_view.prototype.doLoadingFinished = function () { doLoadingFinished() {
_super.prototype.doLoadingFinished.call(this); super.doLoadingFinished();
this.loader.hide(0).prependTo(this.div); this.loader.hide(0).prependTo(this.div);
this.div.append(this.now_div); this.div.append(this.now_div);
if (this.options.owner) if (this.options.owner)
@ -86,7 +73,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
// Start moving 'now' line // Start moving 'now' line
this.now_timer = window.setInterval(this._updateNow.bind(this), 60000); this.now_timer = window.setInterval(this._updateNow.bind(this), 60000);
return true; return true;
}; }
/** /**
* Something changed, and the view need to be re-drawn. We wait a bit to * Something changed, and the view need to be re-drawn. We wait a bit to
* avoid re-drawing twice if start and end date both changed, then recreate * avoid re-drawing twice if start and end date both changed, then recreate
@ -98,9 +85,9 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.invalidate = function (trigger_event) { invalidate(trigger_event) {
// If this wasn't a stub, we'd set this.update_timer // If this wasn't a stub, we'd set this.update_timer
}; }
/** /**
* Returns the current start date * Returns the current start date
* *
@ -108,9 +95,9 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.get_start_date = function () { get_start_date() {
return new Date(this.options.start_date); return new Date(this.options.start_date);
}; }
/** /**
* Returns the current start date * Returns the current start date
* *
@ -118,9 +105,9 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.get_end_date = function () { get_end_date() {
return new Date(this.options.end_date); return new Date(this.options.end_date);
}; }
/** /**
* Change the start date * Change the start date
* *
@ -133,7 +120,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.set_start_date = function (new_date) { set_start_date(new_date) {
if (!new_date || new_date === null) { if (!new_date || new_date === null) {
new_date = new Date(); new_date = new Date();
} }
@ -153,7 +140,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
if (old_date !== this.options.start_date && this.isAttached()) { if (old_date !== this.options.start_date && this.isAttached()) {
this.invalidate(true); this.invalidate(true);
} }
}; }
/** /**
* Change the end date * Change the end date
* *
@ -166,7 +153,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.set_end_date = function (new_date) { set_end_date(new_date) {
if (!new_date || new_date === null) { if (!new_date || new_date === null) {
new_date = new Date(); new_date = new Date();
} }
@ -186,7 +173,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
if (old_date !== this.options.end_date && this.isAttached()) { if (old_date !== this.options.end_date && this.isAttached()) {
this.invalidate(true); this.invalidate(true);
} }
}; }
/** /**
* Set which users to display * Set which users to display
* *
@ -200,7 +187,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype.set_owner = function (_owner) { set_owner(_owner) {
var old = this.options.owner; var old = this.options.owner;
// 0 means current user, but that causes problems for comparison, // 0 means current user, but that causes problems for comparison,
// so we'll just switch to the actual ID // so we'll just switch to the actual ID
@ -226,7 +213,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
typeof old === 'string' && '' + old !== '' + this.options.owner)) { typeof old === 'string' && '' + old !== '' + this.options.owner)) {
this.invalidate(true); this.invalidate(true);
} }
}; }
/** /**
* Provide specific data to be displayed. * Provide specific data to be displayed.
* This is a way to set start and end dates, owner and event data in one call. * This is a way to set start and end dates, owner and event data in one call.
@ -245,7 +232,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* necessarily an entry from the resource app), or a list containing a * necessarily an entry from the resource app), or a list containing a
* combination of both. * combination of both.
*/ */
et2_calendar_view.prototype.set_value = function (events) { set_value(events) {
if (typeof events !== 'object') if (typeof events !== 'object')
return false; return false;
if (events.length && events.length > 0 || !jQuery.isEmptyObject(events)) { if (events.length && events.length > 0 || !jQuery.isEmptyObject(events)) {
@ -274,17 +261,13 @@ var et2_calendar_view = /** @class */ (function (_super) {
if (!this.update_timer) { if (!this.update_timer) {
window.setTimeout(jQuery.proxy(function () { this.loader.hide(); }, this), 200); window.setTimeout(jQuery.proxy(function () { this.loader.hide(); }, this), 200);
} }
}; }
Object.defineProperty(et2_calendar_view.prototype, "date_helper", { get date_helper() {
get: function () { return this._date_helper;
return this._date_helper; }
}, _createNamespace() {
enumerable: false,
configurable: true
});
et2_calendar_view.prototype._createNamespace = function () {
return true; return true;
}; }
/** /**
* Update the 'now' line * Update the 'now' line
* *
@ -293,7 +276,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @private * @private
*/ */
et2_calendar_view.prototype._updateNow = function () { _updateNow() {
var tempDate = new Date(); var tempDate = new Date();
var now = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(), tempDate.getHours(), tempDate.getMinutes() - tempDate.getTimezoneOffset(), 0); var now = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(), tempDate.getHours(), tempDate.getMinutes() - tempDate.getTimezoneOffset(), 0);
// Use date widget's existing functions to deal // Use date widget's existing functions to deal
@ -304,7 +287,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
} }
this.now_div.hide(); this.now_div.hide();
return false; return false;
}; }
/** /**
* Calendar supports many different owner types, including users & resources. * Calendar supports many different owner types, including users & resources.
* This translates an ID to a user-friendly name. * This translates an ID to a user-friendly name.
@ -314,7 +297,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @memberOf et2_calendar_view * @memberOf et2_calendar_view
*/ */
et2_calendar_view.prototype._get_owner_name = function (user) { _get_owner_name(user) {
var label = undefined; var label = undefined;
if (parseInt(user) === 0) { if (parseInt(user) === 0) {
// 0 means current user // 0 means current user
@ -335,7 +318,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
} }
if (typeof label === 'undefined') { if (typeof label === 'undefined') {
// Not found? Ask the sidebox owner widget (it gets updated) or the original arrayMgr // Not found? Ask the sidebox owner widget (it gets updated) or the original arrayMgr
var options = false; let options = false;
if (app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) { if (app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) {
options = app.calendar.sidebox_et2.getWidgetById('owner').taglist.getSelection(); options = app.calendar.sidebox_et2.getWidgetById('owner').taglist.getSelection();
} }
@ -365,14 +348,14 @@ var et2_calendar_view = /** @class */ (function (_super) {
et2_calendar_view.owner_name_cache[user] = label; et2_calendar_view.owner_name_cache[user] = label;
} }
return label; return label;
}; }
/** /**
* Find the event information linked to a given DOM node * Find the event information linked to a given DOM node
* *
* @param {HTMLElement} dom_node - It should have something to do with an event * @param {HTMLElement} dom_node - It should have something to do with an event
* @returns {Object} * @returns {Object}
*/ */
et2_calendar_view.prototype._get_event_info = function (dom_node) { _get_event_info(dom_node) {
// Determine as much relevant info as can be found // Determine as much relevant info as can be found
var event_node = jQuery(dom_node).closest('[data-id]', this.div)[0]; var event_node = jQuery(dom_node).closest('[data-id]', this.div)[0];
var day_node = jQuery(event_node).closest('[data-date]', this.div)[0]; var day_node = jQuery(event_node).closest('[data-date]', this.div)[0];
@ -388,7 +371,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
result.widget_id = 'event_' + widget_id.join(''); result.widget_id = 'event_' + widget_id.join('');
} }
return result; return result;
}; }
/** /**
* Starting (mousedown) handler to support drag to create * Starting (mousedown) handler to support drag to create
* *
@ -398,7 +381,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* *
* @param {String} start Date string (JSON format) * @param {String} start Date string (JSON format)
*/ */
et2_calendar_view.prototype._drag_create_start = function (start) { _drag_create_start(start) {
this.drag_create.start = jQuery.extend({}, start); this.drag_create.start = jQuery.extend({}, start);
if (!this.drag_create.start.date) { if (!this.drag_create.start.date) {
this.drag_create.start = null; this.drag_create.start = null;
@ -416,12 +399,12 @@ var et2_calendar_view = /** @class */ (function (_super) {
// Create event // Create event
this._drag_create_event(); this._drag_create_event();
}, this), 250); }, this), 250);
}; }
/** /**
* Create or update an event used for feedback while dragging on empty space, * Create or update an event used for feedback while dragging on empty space,
* so user can see something is happening * so user can see something is happening
*/ */
et2_calendar_view.prototype._drag_create_event = function () { _drag_create_event() {
if (!this.drag_create.parent || !this.drag_create.start) { if (!this.drag_create.parent || !this.drag_create.start) {
return; return;
} }
@ -447,8 +430,8 @@ var et2_calendar_view = /** @class */ (function (_super) {
this.drag_create.event._values_check(value); this.drag_create.event._values_check(value);
this.drag_create.event.doLoadingFinished(); this.drag_create.event.doLoadingFinished();
} }
}; }
et2_calendar_view.prototype._drag_update_event = function () { _drag_update_event() {
if (!this.drag_create.event || !this.drag_create.start || !this.drag_create.end if (!this.drag_create.event || !this.drag_create.start || !this.drag_create.end
|| !this.drag_create.parent || !this.drag_create.event._type) { || !this.drag_create.parent || !this.drag_create.event._type) {
return; return;
@ -459,13 +442,13 @@ var et2_calendar_view = /** @class */ (function (_super) {
} }
this.drag_create.event._update(); this.drag_create.event._update();
this.drag_create.parent.position_event(this.drag_create.event); this.drag_create.parent.position_event(this.drag_create.event);
}; }
/** /**
* Ending (mouseup) handler to support drag to create * Ending (mouseup) handler to support drag to create
* *
* @param {String} end Date string (JSON format) * @param {String} end Date string (JSON format)
*/ */
et2_calendar_view.prototype._drag_create_end = function (end) { _drag_create_end(end) {
this.div.css('cursor', ''); this.div.css('cursor', '');
if (typeof end === 'undefined') { if (typeof end === 'undefined') {
end = {}; end = {};
@ -492,7 +475,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
jQuery.extend(options, this.drag_create.start, end); jQuery.extend(options, this.drag_create.start, end);
delete (options.date); delete (options.date);
// Make sure parent is set, if needed // Make sure parent is set, if needed
var app_calendar = this.getInstanceManager().app_obj.calendar || app.calendar; 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) { 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; options.owner = this.drag_create.parent.options.owner;
} }
@ -526,7 +509,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
this.drag_create.event = null; this.drag_create.event = null;
} }
return true; return true;
}; }
/** /**
* Check if the view should be consolidated into one, or listed seperately * Check if the view should be consolidated into one, or listed seperately
* based on the user's preferences * based on the user's preferences
@ -536,12 +519,12 @@ var et2_calendar_view = /** @class */ (function (_super) {
* @returns {boolean} True of only one is needed, false if each owner needs * @returns {boolean} True of only one is needed, false if each owner needs
* to be listed seperately. * to be listed seperately.
*/ */
et2_calendar_view.is_consolidated = function (owners, view) { static is_consolidated(owners, view) {
// Seperate owners, or consolidated? // Seperate owners, or consolidated?
return !(owners.length > 1 && return !(owners.length > 1 &&
(view === 'day' && owners.length < parseInt('' + egw.preference('day_consolidate', 'calendar')) || (view === 'day' && owners.length < parseInt('' + egw.preference('day_consolidate', 'calendar')) ||
view === 'week' && owners.length < parseInt('' + egw.preference('week_consolidate', 'calendar')))); view === 'week' && owners.length < parseInt('' + egw.preference('week_consolidate', 'calendar'))));
}; }
/** /**
* Fetch and cache a list of the year's holidays * Fetch and cache a list of the year's holidays
* *
@ -549,7 +532,7 @@ var et2_calendar_view = /** @class */ (function (_super) {
* @param {string|numeric} year * @param {string|numeric} year
* @returns {Array} * @returns {Array}
*/ */
et2_calendar_view.get_holidays = function (widget, year) { static get_holidays(widget, year) {
// Loaded in an iframe or something // Loaded in an iframe or something
var view = egw.window.et2_calendar_view ? egw.window.et2_calendar_view : this; var view = egw.window.et2_calendar_view ? egw.window.et2_calendar_view : this;
// No country selected causes error, so skip if it's missing // No country selected causes error, so skip if it's missing
@ -582,29 +565,27 @@ var et2_calendar_view = /** @class */ (function (_super) {
else { else {
return cache; return cache;
} }
}; }
et2_calendar_view._attributes = { }
owner: { et2_calendar_view._attributes = {
name: "Owner", owner: {
type: "any", name: "Owner",
default: [egw.user('account_id')], type: "any",
description: "Account ID number of the calendar owner, if not the current user" default: [egw.user('account_id')],
}, description: "Account ID number of the calendar owner, if not the current user"
start_date: { },
name: "Start date", start_date: {
type: "any" name: "Start date",
}, type: "any"
end_date: { },
name: "End date", end_date: {
type: "any" name: "End date",
} type: "any"
}; }
/** };
* Cache to map owner & resource IDs to names, helps cut down on server requests /**
*/ * Cache to map owner & resource IDs to names, helps cut down on server requests
et2_calendar_view.owner_name_cache = {}; */
et2_calendar_view.holiday_cache = {}; et2_calendar_view.owner_name_cache = {};
return et2_calendar_view; et2_calendar_view.holiday_cache = {};
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_calendar_view = et2_calendar_view;
//# sourceMappingURL=et2_widget_view.js.map //# sourceMappingURL=et2_widget_view.js.map

View File

@ -1,22 +1,23 @@
/* /*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License *
* @package * @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @subpackage * @package calendar
* @link http://www.egroupware.org * @subpackage etemplate
* @link https://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$
*/ */
/*egw:uses /*egw:uses
/etemplate/js/et2_core_valueWidget; /etemplate/js/et2_core_valueWidget;
*/ */
import {et2_widget, WidgetConfig} from "../../api/js/etemplate/et2_core_widget"; import {et2_createWidget, et2_widget, WidgetConfig} from "../../api/js/etemplate/et2_core_widget";
import {et2_valueWidget} from "../../api/js/etemplate/et2_core_valueWidget"; import {et2_valueWidget} from "../../api/js/etemplate/et2_core_valueWidget";
import {ClassWithAttributes} from "../../api/js/etemplate/et2_core_inheritance"; import {ClassWithAttributes} from "../../api/js/etemplate/et2_core_inheritance";
import {et2_date} from "../../api/js/etemplate/et2_widget_date"; import {et2_date} from "../../api/js/etemplate/et2_widget_date";
import {et2_calendar_event} from "./et2_widget_event"; import {et2_calendar_event} from "./et2_widget_event";
import {sprintf} from "../../api/js/egw_action/egw_action_common.js";
/** /**
* Parent class for the various calendar views to reduce copied code * Parent class for the various calendar views to reduce copied code
@ -69,7 +70,7 @@ export class et2_calendar_view extends et2_valueWidget
// Used for its date calculations // Used for its date calculations
this._date_helper = et2_createWidget('date-time', {}, null); this._date_helper = <et2_date>et2_createWidget('date-time', {}, null);
this._date_helper.loadingFinished(); this._date_helper.loadingFinished();
this.loader = jQuery('<div class="egw-loading-prompt-container ui-front loading"></div>'); this.loader = jQuery('<div class="egw-loading-prompt-container ui-front loading"></div>');
@ -552,7 +553,7 @@ export class et2_calendar_view extends et2_valueWidget
whole_day_on_top: this.drag_create.start.whole_day whole_day_on_top: this.drag_create.start.whole_day
} }
); );
this.drag_create.event = et2_createWidget('calendar-event',{ this.drag_create.event = <et2_calendar_event>et2_createWidget('calendar-event',{
id:'event_drag', id:'event_drag',
value: value value: value
},this.drag_create.parent); },this.drag_create.parent);