"use strict"; (self["webpackChunkcalendar"] = self["webpackChunkcalendar"] || []).push([["src_store_index_js"],{ /***/ "./src/models/alarm.js": /*!*****************************!*\ !*** ./src/models/alarm.js ***! \*****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultAlarmObject: () => (/* binding */ getDefaultAlarmObject), /* harmony export */ mapAlarmComponentToAlarmObject: () => (/* binding */ mapAlarmComponentToAlarmObject) /* harmony export */ }); /* harmony import */ var _utils_alarms_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/alarms.js */ "./src/utils/alarms.js"); /* harmony import */ var _utils_date_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/date.js */ "./src/utils/date.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete alarm object based on given props * * @param {object} props The alarm properties already provided * @return {object} */ const getDefaultAlarmObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // The calendar-js alarm component alarmComponent: null, // Type of alarm: DISPLAY, EMAIL, AUDIO type: null, // Whether or not the alarm is relative isRelative: false, // Date object of an absolute alarm (if it's absolute, it must be DATE-TIME) absoluteDate: null, // The time zone id of for absolute alarms absoluteTimezoneId: null, // Whether or not the relative alarm is before the event, relativeIsBefore: null, // Whether or not the alarm is relative to the event's start relativeIsRelatedToStart: null, // TIMED EVENTS: // Unit (seconds, minutes, hours, ...) if this alarm is inside a timed event relativeUnitTimed: null, // The amount of unit if this alarm is inside a timed event relativeAmountTimed: null, // ALL-DAY EVENTS: // Unit (seconds, minutes, hours, ...) if this alarm is inside an all-day event relativeUnitAllDay: null, // The amount of unit if this alarm is inside a all-day event relativeAmountAllDay: null, // The hours to display alarm for in an all-day event (e.g. 1 day before at 9:00 am) relativeHoursAllDay: null, // The minutes to display alarm for in an all-day event (e.g. 1 day before at 9:30 am) relativeMinutesAllDay: null, // The total amount of seconds for a relative alarm relativeTrigger: null }, props); }; /** * Map an alarm component to our alarm object * * @param {AlarmComponent} alarmComponent The calendar-js alarm-component to turn into an alarm object * @return {object} */ const mapAlarmComponentToAlarmObject = alarmComponent => { if (alarmComponent.trigger.isRelative()) { const relativeIsBefore = alarmComponent.trigger.value.isNegative; const relativeIsRelatedToStart = alarmComponent.trigger.related === 'START'; const { amount: relativeAmountTimed, unit: relativeUnitTimed } = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_0__.getAmountAndUnitForTimedEvents)(alarmComponent.trigger.value.totalSeconds); const { unit: relativeUnitAllDay, amount: relativeAmountAllDay, hours: relativeHoursAllDay, minutes: relativeMinutesAllDay } = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_0__.getAmountHoursMinutesAndUnitForAllDayEvents)(alarmComponent.trigger.value.totalSeconds); const relativeTrigger = alarmComponent.trigger.value.totalSeconds; return getDefaultAlarmObject({ alarmComponent, type: alarmComponent.action, isRelative: alarmComponent.trigger.isRelative(), relativeIsBefore, relativeIsRelatedToStart, relativeUnitTimed, relativeAmountTimed, relativeUnitAllDay, relativeAmountAllDay, relativeHoursAllDay, relativeMinutesAllDay, relativeTrigger }); } else { const absoluteDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(alarmComponent.trigger.value); return getDefaultAlarmObject({ alarmComponent, type: alarmComponent.action, isRelative: alarmComponent.trigger.isRelative(), absoluteDate, absoluteTimezoneId: alarmComponent.trigger.value.timezoneId }); } }; /***/ }), /***/ "./src/models/attachment.js": /*!**********************************!*\ !*** ./src/models/attachment.js ***! \**********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultAttachmentObject: () => (/* binding */ getDefaultAttachmentObject), /* harmony export */ mapAttachmentPropertyToAttchmentObject: () => (/* binding */ mapAttachmentPropertyToAttchmentObject) /* harmony export */ }); /** * @copyright Copyright (c) 2022 Mikhail Sazanov * * @author Mikhail Sazanov * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete attachment object based on given props * * @param {object} props The attachment properties already provided * @return {object} */ const getDefaultAttachmentObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // The calendar-js attachment property attachmentProperty: null, // The file name of the attachment fileName: null, // The attachment mime type formatType: null, // The uri of the attachment uri: null, // The value from calendar object value: null, // Preview of file xNcHasPreview: null, // File id in NC xNcFileId: null }, props); }; /** * Maps a calendar-js attachment property to our attachment object * * @param {attachmentProperty} attachmentProperty The calendar-js attachmentProperty to turn into a attachment object * @return {object} */ const mapAttachmentPropertyToAttchmentObject = attachmentProperty => { return getDefaultAttachmentObject({ attachmentProperty, fileName: attachmentProperty.getParameterFirstValue('FILENAME'), formatType: attachmentProperty.formatType, uri: attachmentProperty.uri, value: attachmentProperty.value, xNcHasPreview: attachmentProperty.getParameterFirstValue('X-NC-HAS-PREVIEW') === 'true', xNcFileId: attachmentProperty.getParameterFirstValue('X-NC-FILE-ID') }); }; /***/ }), /***/ "./src/models/attendee.js": /*!********************************!*\ !*** ./src/models/attendee.js ***! \********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultAttendeeObject: () => (/* binding */ getDefaultAttendeeObject), /* harmony export */ mapAttendeePropertyToAttendeeObject: () => (/* binding */ mapAttendeePropertyToAttendeeObject) /* harmony export */ }); /** * @copyright Copyright (c) 2020 Georg Ehrke * @copyright Copyright (c) 2023 Jonas Heinrich * * @author Georg Ehrke * @author Jonas Heinrich * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete attendee object based on given props * * TODO: * - we should eventually support delegatedFrom and delegatedTo * * @param {object} props The attendee properties already provided * @return {object} */ const getDefaultAttendeeObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // The calendar-js attendee property attendeeProperty: null, // The display-name of the attendee commonName: null, // The calendar-user-type of the attendee calendarUserType: 'INDIVIDUAL', // The participation status of the attendee participationStatus: 'NEEDS-ACTION', // The role of the attendee role: 'REQ-PARTICIPANT', // The RSVP for the attendee rsvp: false, // The uri of the attendee uri: null, // Member address of the attendee member: null }, props); }; /** * Maps a calendar-js attendee property to our attendee object * * @param {AttendeeProperty} attendeeProperty The calendar-js attendeeProperty to turn into a attendee object * @return {object} */ const mapAttendeePropertyToAttendeeObject = attendeeProperty => { return getDefaultAttendeeObject({ attendeeProperty, commonName: attendeeProperty.commonName, calendarUserType: attendeeProperty.userType, participationStatus: attendeeProperty.participationStatus, role: attendeeProperty.role, rsvp: attendeeProperty.rsvp, uri: attendeeProperty.email, member: attendeeProperty.member }); }; /***/ }), /***/ "./src/models/calendar.js": /*!********************************!*\ !*** ./src/models/calendar.js ***! \********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultCalendarObject: () => (/* binding */ getDefaultCalendarObject), /* harmony export */ mapDavCollectionToCalendar: () => (/* binding */ mapDavCollectionToCalendar) /* harmony export */ }); /* harmony import */ var _utils_color_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/color.js */ "./src/utils/color.js"); /* harmony import */ var _calendarShare_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./calendarShare.js */ "./src/models/calendarShare.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete calendar-object based on given props * * @param {object} props Calendar-props already provided * @return {object} */ const getDefaultCalendarObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // Id of the calendar id: '', // Visible display name displayName: '', // Color of the calendar color: (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_0__.uidToHexColor)(''), // Whether or not the calendar is visible in the grid enabled: true, // Whether or not the calendar is loading events at the moment loading: false, // Whether this calendar supports VEvents supportsEvents: true, // Whether this calendar supports VJournals supportsJournals: false, // Whether this calendar supports VTodos supportsTasks: false, // The principal uri of the owner owner: '', // Timezone set for this calendar timezone: null, // List of shares shares: [], // Published url publishURL: null, // Internal CalDAV url of this calendar url: '', // Whether this calendar is read-only readOnly: false, // The order of this calendar in the calendar-list order: 0, // Whether or not the calendar is shared with me isSharedWithMe: false, // Whether or not the calendar can be shared by me canBeShared: false, // Whether or not the calendar can be published by me canBePublished: false, // Reference to cdav-lib object dav: false, // All calendar-objects from this calendar that have already been fetched calendarObjects: [], // Time-ranges that have already been fetched for this calendar fetchedTimeRanges: [] }, props); }; /** * Map a dav collection to our calendar object model * * @param {object} calendar The calendar object from the cdav library * @param {object=} currentUserPrincipal The principal model of the current user principal * @return {object} */ const mapDavCollectionToCalendar = (calendar, currentUserPrincipal) => { const id = btoa(calendar.url); const displayName = calendar.displayname || getCalendarUriFromUrl(calendar.url); // calendar.color can be set to anything on the server, // so make sure it's something that remotely looks like a color let color = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_0__.detectColor)(calendar.color); if (!color) { // As fallback if we don't know what color that is supposed to be color = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_0__.uidToHexColor)(displayName); } const supportsEvents = calendar.components.includes('VEVENT'); const supportsJournals = calendar.components.includes('VJOURNAL'); const supportsTasks = calendar.components.includes('VTODO'); const owner = calendar.owner; const readOnly = !calendar.isWriteable(); const canBeShared = calendar.isShareable(); const canBePublished = calendar.isPublishable(); const order = calendar.order || 0; const url = calendar.url; const publishURL = calendar.publishURL || null; const timezone = calendar.timezone || null; let isSharedWithMe = false; if (!currentUserPrincipal) { // If the user is not authenticated, the calendar // will always be marked as shared with them isSharedWithMe = true; } else { isSharedWithMe = owner !== currentUserPrincipal.url; } let enabled; if (!currentUserPrincipal) { // If the user is not authenticated, // always enable the calendar enabled = true; } else if (typeof calendar.enabled === 'boolean') { // If calendar-enabled is set, we will just take that enabled = calendar.enabled; } else { // If there is no calendar-enabled, // we will display the calendar by default and set enabled enabled = true; calendar.enabled = true; } const shares = []; if (!!currentUserPrincipal && Array.isArray(calendar.shares)) { for (const share of calendar.shares) { if (share.href === currentUserPrincipal.principalScheme) { continue; } shares.push((0,_calendarShare_js__WEBPACK_IMPORTED_MODULE_1__.mapDavShareeToCalendarShareObject)(share)); } } return getDefaultCalendarObject({ id, displayName, color, order, url, enabled, supportsEvents, supportsJournals, supportsTasks, isSharedWithMe, owner, readOnly, publishURL, canBeShared, canBePublished, shares, timezone, dav: calendar }); }; /** * Gets the calendar uri from the url * * @param {string} url The url to get calendar uri from * @return {string} */ function getCalendarUriFromUrl(url) { if (url.endsWith('/')) { url = url.substring(0, url.length - 1); } return url.substring(url.lastIndexOf('/') + 1); } /***/ }), /***/ "./src/models/calendarObject.js": /*!**************************************!*\ !*** ./src/models/calendarObject.js ***! \**************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultCalendarObjectObject: () => (/* binding */ getDefaultCalendarObjectObject), /* harmony export */ getKeyValueIcsProperty: () => (/* binding */ getKeyValueIcsProperty), /* harmony export */ mapCDavObjectToCalendarObject: () => (/* binding */ mapCDavObjectToCalendarObject), /* harmony export */ mapCalendarJsToCalendarObject: () => (/* binding */ mapCalendarJsToCalendarObject), /* harmony export */ setCustomKeyValueToIcsAndReturnIcs: () => (/* binding */ setCustomKeyValueToIcsAndReturnIcs), /* harmony export */ setCustomKeyValuesArrayToIcsAndReturnIcs: () => (/* binding */ setCustomKeyValuesArrayToIcsAndReturnIcs) /* harmony export */ }); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts.js */ "./src/models/consts.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete calendar-object-object based on given props * * @param {object} props Calendar-object-props already provided * @return {object} */ const getDefaultCalendarObjectObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // Id of this calendar-object id: null, // Id of the associated calendar calendarId: null, // The cdav-library object storing the calendar-object dav: null, // The parsed calendar-js object calendarComponent: null, // The uid of the calendar-object uid: null, // The uri of the calendar-object uri: null, // The type of calendar-object objectType: null, // Whether or not the calendar-object is an event isEvent: false, // Whether or not the calendar-object is a journal isJournal: false, // Whether or not the calendar-object is a task isTodo: false, // Whether or not the calendar-object exists on the server existsOnServer: false }, props); }; /** * Maps a calendar-object from c-dav to our calendar-object object * * @param {VObject} dav The c-dav VObject * @param {string} calendarId The calendar-id this object is associated with * @return {object} */ const mapCDavObjectToCalendarObject = (dav, calendarId) => { const parserManager = (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__.getParserManager)(); const parser = parserManager.getParserForFileType('text/calendar'); // This should not be the case, but let's just be on the safe side if (typeof dav.data !== 'string' || dav.data.trim() === '') { throw new Error('Empty calendar object'); } parser.parse(dav.data); const calendarComponentIterator = parser.getItemIterator(); const calendarComponent = calendarComponentIterator.next().value; if (!calendarComponent) { throw new Error('Empty calendar object'); } const vObjectIterator = calendarComponent.getVObjectIterator(); const firstVObject = vObjectIterator.next().value; return getDefaultCalendarObjectObject({ id: btoa(dav.url), calendarId, dav, calendarComponent, uid: firstVObject.uid, uri: dav.url, objectType: firstVObject.name, isEvent: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_EVENT, isJournal: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_JOURNAL, isTodo: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_VTODO, existsOnServer: true }); }; /** * Maps a calendar-component from calendar-js to our calendar-object object * * @param {CalendarComponent} calendarComponent The calendarComponent to create the calendarObject from * @param {string=} calendarId The associated calendar if applicable * @return {object} */ const mapCalendarJsToCalendarObject = function (calendarComponent) { let calendarId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const vObjectIterator = calendarComponent.getVObjectIterator(); const firstVObject = vObjectIterator.next().value; if (!firstVObject) { throw new Error('Calendar object without vobjects'); } return getDefaultCalendarObjectObject({ calendarId, calendarComponent, uid: firstVObject.uid, objectType: firstVObject.name, isEvent: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_EVENT, isJournal: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_JOURNAL, isTodo: firstVObject.name === _consts_js__WEBPACK_IMPORTED_MODULE_1__.COMPONENT_NAME_VTODO }); }; const getKeyValueIcsProperty = (key, value) => { return "".concat(key, ":").concat(value, "\r\n"); }; const setCustomKeyValueToIcsAndReturnIcs = (ics, key, value) => { const property = getKeyValueIcsProperty(key, value); ics = ics.replace('END:VEVENT', "".concat(property, "END:VEVENT")); return ics; }; const setCustomKeyValuesArrayToIcsAndReturnIcs = (ics, keyValueArray) => { for (var key in keyValueArray) { const value = keyValueArray[key] ? keyValueArray[key] : ''; ics = setCustomKeyValueToIcsAndReturnIcs(ics, key, value); } return ics; }; /***/ }), /***/ "./src/models/calendarShare.js": /*!*************************************!*\ !*** ./src/models/calendarShare.js ***! \*************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultCalendarShareObject: () => (/* binding */ getDefaultCalendarShareObject), /* harmony export */ mapDavShareeToCalendarShareObject: () => (/* binding */ mapDavShareeToCalendarShareObject) /* harmony export */ }); /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ "./src/models/consts.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete calendar-share-object based on given props * * @param {object} props Calendar-share-props already provided * @return {object} */ const getDefaultCalendarShareObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // Unique identifier id: null, // Displayname of the sharee displayName: null, // Whether or not share is writable writeable: false, // Whether or not sharee is an individual user isUser: false, // Whether or not sharee is an admin-defined group isGroup: false, // Whether or not sharee is a user-defined group isCircle: false, // Uri necessary for deleting / updating share uri: null }, props); }; /** * Map a dav collection to our calendar object model * * @param {object} sharee The sharee object from the cdav library shares * @return {object} */ const mapDavShareeToCalendarShareObject = sharee => { // sharee.href might contain non-latin characters, so let's uri encode it first const id = btoa(encodeURI(sharee.href)); let displayName; if (sharee['common-name'] && sharee['common-name'].trim() !== '') { displayName = sharee['common-name']; } else if (sharee.href.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_GROUP)) { displayName = decodeURIComponent(sharee.href.slice(28)); } else if (sharee.href.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_USER)) { displayName = decodeURIComponent(sharee.href.slice(27)); } else { displayName = sharee.href; } const writeable = sharee.access[0].endsWith('read-write'); const isUser = sharee.href.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_USER); const isGroup = sharee.href.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_GROUP); const isCircle = sharee.href.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CIRCLE); const uri = sharee.href; return getDefaultCalendarShareObject({ id, displayName, writeable, isUser, isGroup, isCircle, uri }); }; /***/ }), /***/ "./src/models/event.js": /*!*****************************!*\ !*** ./src/models/event.js ***! \*****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ copyCalendarObjectInstanceIntoEventComponent: () => (/* binding */ copyCalendarObjectInstanceIntoEventComponent), /* harmony export */ getDefaultEventObject: () => (/* binding */ getDefaultEventObject), /* harmony export */ mapEventComponentToEventObject: () => (/* binding */ mapEventComponentToEventObject) /* harmony export */ }); /* harmony import */ var _utils_date_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/date.js */ "./src/utils/date.js"); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _utils_color_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/color.js */ "./src/utils/color.js"); /* harmony import */ var _alarm_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./alarm.js */ "./src/models/alarm.js"); /* harmony import */ var _attendee_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./attendee.js */ "./src/models/attendee.js"); /* harmony import */ var _attachment_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./attachment.js */ "./src/models/attachment.js"); /* harmony import */ var _recurrenceRule_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./recurrenceRule.js */ "./src/models/recurrenceRule.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete calendar-object-instance-object based on given props * * @param {object} props The props already provided * @return {object} */ const getDefaultEventObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // The real event-component coming from calendar-js eventComponent: null, // Title of the event title: null, // Start date of the event startDate: null, // Timezone of the start date startTimezoneId: null, // End date of the event endDate: null, // Timezone of the end date endTimezoneId: null, // Indicator whether or not event is all-day isAllDay: false, // Whether or not the user is allowed to toggle the all-day checkbox canModifyAllDay: true, // Location that the event takes places in location: null, //client of the event client: null, //embalmer(Thanato) of the event embalmer: null, //absenceType absenceType: null, //Private isPrivate: false, // Whether or not the event is return to siege returnToSiege: false, //comment of the event comment: null, // description of the event description: null, // Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL) accessClass: null, // Status of the event (CONFIRMED, TENTATIVE, CANCELLED) status: null, // Whether or not to block this event in Free-Busy reports (TRANSPARENT, OPAQUE) timeTransparency: null, // The recurrence rule of this event. We only support one recurrence-rule recurrenceRule: (0,_recurrenceRule_js__WEBPACK_IMPORTED_MODULE_6__.getDefaultRecurrenceRuleObject)(), // Whether or not this event has multiple recurrence-rules hasMultipleRRules: false, // Whether or not this is the master item isMasterItem: false, // Whether or not this is a recurrence-exception isRecurrenceException: false, // Whether or not the applied modifications require to update this and all future forceThisAndAllFuture: false, // Whether or not it's possible to create a recurrence-exception for this event canCreateRecurrenceException: false, // Attendees of this event attendees: [], // Organizer of the event organizer: null, // Alarm of the event alarms: [], // Custom color of the event customColor: null, // Categories categories: [], // The event's UID emailId: null, // Attachments of this event attachments: [] }, props); }; /** * * @param {EventComponent} eventComponent The calendar-js eventComponent * @return {object} */ const mapEventComponentToEventObject = eventComponent => { const eventObject = getDefaultEventObject({ eventComponent, title: eventComponent.title, isAllDay: eventComponent.isAllDay(), isPrivate: false, returnToSiege: false, canModifyAllDay: eventComponent.canModifyAllDay(), location: eventComponent.location, client: "CLIENT", embalmer: "TEST", comment: "", absenceType: "", emailId: null, description: eventComponent.description, accessClass: eventComponent.accessClass, status: eventComponent.status, timeTransparency: eventComponent.timeTransparency, categories: Array.from(eventComponent.getCategoryIterator()), isMasterItem: eventComponent.isMasterItem(), isRecurrenceException: eventComponent.isRecurrenceException(), canCreateRecurrenceException: eventComponent.canCreateRecurrenceExceptions() }); /** * According to RFC5545, DTEND is exclusive. This is rather intuitive for timed-events * but rather unintuitive for all-day events * * That's why, when an event is all-day from 2019-10-03 to 2019-10-04, * it will be displayed as 2019-10-03 to 2019-10-03 in the editor. */ eventObject.startDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_0__.getDateFromDateTimeValue)(eventComponent.startDate); eventObject.startTimezoneId = eventComponent.startDate.timezoneId; if (eventComponent.isAllDay()) { const endDate = eventComponent.endDate.clone(); endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_1__.DurationValue.fromSeconds(-1 * 60 * 60 * 24)); eventObject.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_0__.getDateFromDateTimeValue)(endDate); } else { eventObject.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_0__.getDateFromDateTimeValue)(eventComponent.endDate); } eventObject.endTimezoneId = eventComponent.endDate.timezoneId; /** * Extract organizer if there is any */ if (eventComponent.organizer) { const organizerProperty = eventComponent.getFirstProperty('ORGANIZER'); eventObject.organizer = { commonName: organizerProperty.commonName, uri: organizerProperty.email, attendeeProperty: organizerProperty }; } /** * Extract alarms */ for (const alarm of eventComponent.getAlarmIterator()) { eventObject.alarms.push((0,_alarm_js__WEBPACK_IMPORTED_MODULE_3__.mapAlarmComponentToAlarmObject)(alarm)); } /** * Extract attendees */ for (const attendee of eventComponent.getAttendeeIterator()) { eventObject.attendees.push((0,_attendee_js__WEBPACK_IMPORTED_MODULE_4__.mapAttendeePropertyToAttendeeObject)(attendee)); } /** * Extract attachments */ for (const attachment of eventComponent.getPropertyIterator('ATTACH')) { eventObject.attachments.push((0,_attachment_js__WEBPACK_IMPORTED_MODULE_5__.mapAttachmentPropertyToAttchmentObject)(attachment)); } /** * Extract recurrence-rule */ const recurrenceRuleIterator = eventComponent.getPropertyIterator('RRULE'); const recurrenceRuleFirstIteration = recurrenceRuleIterator.next(); const firstRecurrenceRule = recurrenceRuleFirstIteration.value; if (firstRecurrenceRule) { eventObject.recurrenceRule = (0,_recurrenceRule_js__WEBPACK_IMPORTED_MODULE_6__.mapRecurrenceRuleValueToRecurrenceRuleObject)(firstRecurrenceRule.getFirstValue(), eventComponent.startDate); eventObject.hasMultipleRRules = !recurrenceRuleIterator.next().done; } /** * Convert the CSS 3 color name to a hex color */ if (eventComponent.hasProperty('COLOR')) { const hexColor = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_2__.getHexForColorName)(eventComponent.getFirstPropertyFirstValue('COLOR')); if (hexColor !== null) { eventObject.customColor = hexColor; } } if (eventComponent.hasProperty('CLIENT')) { eventObject.client = eventComponent.getFirstPropertyFirstValue('CLIENT'); } if (eventComponent.hasProperty('ISPRIVATE')) { eventObject.isPrivate = eventComponent.getFirstPropertyFirstValue('ISPRIVATE') === '1' ? true : false; } if (eventComponent.hasProperty('RETURNTOSIEGE')) { eventObject.returnToSiege = eventComponent.getFirstPropertyFirstValue('RETURNTOSIEGE') === '1' ? true : false; } if (eventComponent.hasProperty('EMBALMER')) { eventObject.embalmer = eventComponent.getFirstPropertyFirstValue('EMBALMER'); } if (eventComponent.hasProperty('COMMENT')) { eventObject.comment = eventComponent.getFirstPropertyFirstValue('COMMENT'); } if (eventComponent.hasProperty('ABSENCETYPE')) { eventObject.absenceType = eventComponent.getFirstPropertyFirstValue('ABSENCETYPE'); } if (eventComponent.hasProperty('EMAILID')) { eventObject.emailId = eventComponent.getFirstPropertyFirstValue('EMAILID'); } return eventObject; }; /** * Copy data from a calendar-object-instance into a calendar-js event-component * * @param {object} eventObject The calendar-object-instance object * @param {EventComponent} eventComponent The calendar-js EventComponent object */ const copyCalendarObjectInstanceIntoEventComponent = (eventObject, eventComponent) => { eventComponent.title = eventObject.title; eventComponent.location = eventObject.location; eventComponent.client = eventObject.client; eventComponent.embalmer = eventObject.embalmer; eventComponent.isPrivate = eventObject.isPrivate; eventComponent.returnToSiege = eventObject.returnToSiege; eventComponent.comment = eventObject.comment; eventComponent.emailId = eventObject.emailId; eventComponent.description = eventObject.description; eventComponent.accessClass = eventObject.accessClass; eventComponent.status = eventObject.status; eventComponent.timeTransparency = eventObject.timeTransparency; for (const category of eventObject.categories) { eventComponent.addCategory(category); } if (eventObject.organizer) { eventComponent.setOrganizerFromNameAndEMail(eventObject.organizer.commonName, eventObject.organizer.uri); } for (const alarm of eventObject.alarms) { if (alarm.isRelative) { const duration = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_1__.DurationValue.fromSeconds(alarm.relativeTrigger); eventComponent.addRelativeAlarm(alarm.type, duration, alarm.relativeIsRelatedToStart); } else { const date = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_1__.DateTimeValue.fromJSDate(alarm.absoluteDate); eventComponent.addAbsoluteAlarm(alarm.type, date); } } for (const attendee of eventObject.attendees) { eventComponent.addProperty(attendee.attendeeProperty); } for (const rule of eventObject.eventComponent.getPropertyIterator('RRULE')) { eventComponent.addProperty(rule); } if (eventObject.customColor) { eventComponent.color = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_2__.getClosestCSS3ColorNameForHex)(eventObject.customColor); } }; /***/ }), /***/ "./src/models/principal.js": /*!*********************************!*\ !*** ./src/models/principal.js ***! \*********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultPrincipalObject: () => (/* binding */ getDefaultPrincipalObject), /* harmony export */ mapDavToPrincipal: () => (/* binding */ mapDavToPrincipal) /* harmony export */ }); /* harmony import */ var _consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts.js */ "./src/models/consts.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete principal-object based on given props * * @param {object} props Principal-props already provided * @return {any} */ const getDefaultPrincipalObject = props => Object.assign({}, { // Id of the principal id: null, // Calendar-user-type. This can be INDIVIDUAL, GROUP, RESOURCE or ROOM calendarUserType: 'INDIVIDUAL', // E-Mail address of principal used for scheduling emailAddress: null, // The principals display-name // TODO: this should be renamed to displayName displayname: null, // principalScheme principalScheme: null, // The internal user-id in case it is of type INDIVIDUAL and a user // TODO: userId is deprecrated, use principalId instead userId: null, // url to the DAV-principal-resource url: null, // The cdav-library object dav: null, // Whether or not this principal represents a circle isCircle: false, // Whether or not this principal represents a user isUser: false, // Whether or not this principal represents a group isGroup: false, // Whether or not this principal represents a calendar-resource isCalendarResource: false, // Whether or not this principal represents a calendar-room isCalendarRoom: false, // The id of the principal without prefix. e.g. userId / groupId / etc. principalId: null, // The url of the default calendar for invitations scheduleDefaultCalendarUrl: null }, props); /** * converts a dav principal into a vuex object * * @param {object} dav cdav-library Principal object * @return {object} */ const mapDavToPrincipal = dav => { const id = btoa(encodeURI(dav.url)); const calendarUserType = dav.calendarUserType; const principalScheme = dav.principalScheme; const emailAddress = dav.email; const displayname = dav.displayname; const scheduleDefaultCalendarUrl = dav.scheduleDefaultCalendarUrl; const isUser = dav.principalScheme.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_USER); const isGroup = dav.principalScheme.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_GROUP); const isCircle = dav.principalScheme.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CIRCLE); const isCalendarResource = dav.principalScheme.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CALENDAR_RESOURCE); const isCalendarRoom = dav.principalScheme.startsWith(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CALENDAR_ROOM); let principalId = null; if (isUser) { principalId = dav.principalScheme.substring(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_USER.length); } else if (isGroup) { principalId = dav.principalScheme.substring(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_GROUP.length); } else if (isCircle) { principalId = dav.principalScheme.substring(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CIRCLE.length); } else if (isCalendarResource) { principalId = dav.principalScheme.substring(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CALENDAR_RESOURCE.length); } else if (isCalendarRoom) { principalId = dav.principalScheme.substring(_consts_js__WEBPACK_IMPORTED_MODULE_0__.PRINCIPAL_PREFIX_CALENDAR_ROOM.length); } const url = dav.principalUrl; const userId = dav.userId; return getDefaultPrincipalObject({ id, calendarUserType, principalScheme, emailAddress, displayname, url, dav, isUser, isGroup, isCircle, isCalendarResource, isCalendarRoom, principalId, userId, scheduleDefaultCalendarUrl }); }; /***/ }), /***/ "./src/models/recurrenceRule.js": /*!**************************************!*\ !*** ./src/models/recurrenceRule.js ***! \**************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getDefaultRecurrenceRuleObject: () => (/* binding */ getDefaultRecurrenceRuleObject), /* harmony export */ mapRecurrenceRuleValueToRecurrenceRuleObject: () => (/* binding */ mapRecurrenceRuleValueToRecurrenceRuleObject) /* harmony export */ }); /* harmony import */ var _utils_recurrence_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/recurrence.js */ "./src/utils/recurrence.js"); /* harmony import */ var _utils_date_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/date.js */ "./src/utils/date.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Creates a complete recurrence-rule-object based on given props * * @param {object} props Recurrence-rule-object-props already provided * @return {object} */ const getDefaultRecurrenceRuleObject = function () { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign({}, { // The calendar-js recurrence-rule value recurrenceRuleValue: null, // The frequency of the recurrence-rule (DAILY, WEEKLY, ...) frequency: 'NONE', // The interval of the recurrence-rule, must be a positive integer interval: 1, // Positive integer if recurrence-rule limited by count, null otherwise count: null, // Date if recurrence-rule limited by date, null otherwise // We do not store a timezone here, since we only care about the date part until: null, // List of byDay components to limit/expand the recurrence-rule byDay: [], // List of byMonth components to limit/expand the recurrence-rule byMonth: [], // List of byMonthDay components to limit/expand the recurrence-rule byMonthDay: [], // A position to limit the recurrence-rule (e.g. -1 for last Friday) bySetPosition: null, // Whether or not the rule is not supported for editing isUnsupported: false }, props); }; /** * Maps a calendar-js recurrence-rule-value to an recurrence-rule-object * * @param {RecurValue} recurrenceRuleValue The calendar-js recurrence rule value * @param {DateTimeValue} baseDate The base-date used to fill unset values * @return {object} */ const mapRecurrenceRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate) => { switch (recurrenceRuleValue.frequency) { case 'DAILY': return mapDailyRuleValueToRecurrenceRuleObject(recurrenceRuleValue); case 'WEEKLY': return mapWeeklyRuleValueToRecurrenceRuleObject(recurrenceRuleValue, baseDate); case 'MONTHLY': return mapMonthlyRuleValueToRecurrenceRuleObject(recurrenceRuleValue, baseDate); case 'YEARLY': return mapYearlyRuleValueToRecurrenceRuleObject(recurrenceRuleValue, baseDate); default: // SECONDLY, MINUTELY, HOURLY return getDefaultRecurrenceRuleObjectForRecurrenceValue(recurrenceRuleValue, { isUnsupported: true }); } }; const FORBIDDEN_BY_PARTS_DAILY = ['BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYDAY', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH', 'BYSETPOS']; const FORBIDDEN_BY_PARTS_WEEKLY = ['BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH', 'BYSETPOS']; const FORBIDDEN_BY_PARTS_MONTHLY = ['BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH']; const FORBIDDEN_BY_PARTS_YEARLY = ['BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO']; const SUPPORTED_BY_DAY_WEEKLY = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']; /** * Get all numbers between start and end as strings * * @param {number} start Lower end of range * @param {number} end Upper end of range * @return {string[]} */ const getRangeAsStrings = (start, end) => { return Array.apply(null, Array(end - start + 1)).map((_, n) => n + start).map(s => s.toString()); }; const SUPPORTED_BY_MONTHDAY_MONTHLY = getRangeAsStrings(1, 31); const SUPPORTED_BY_MONTH_YEARLY = getRangeAsStrings(1, 12); /** * Maps a daily calendar-js recurrence-rule-value to an recurrence-rule-object * * @param {RecurValue} recurrenceRuleValue The calendar-js recurrence rule value * @return {object} */ const mapDailyRuleValueToRecurrenceRuleObject = recurrenceRuleValue => { /** * We only support DAILY rules without any by-parts in the editor. * If the recurrence-rule contains any by-parts, mark it as unsupported. */ const isUnsupported = containsRecurrenceComponent(recurrenceRuleValue, FORBIDDEN_BY_PARTS_DAILY); return getDefaultRecurrenceRuleObjectForRecurrenceValue(recurrenceRuleValue, { isUnsupported }); }; /** * Maps a weekly calendar-js recurrence-rule-value to an recurrence-rule-object * * @param {RecurValue} recurrenceRuleValue The calendar-js recurrence rule value * @param {DateTimeValue} baseDate The base-date used to fill unset values * @return {object} */ const mapWeeklyRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate) => { /** * For WEEKLY recurrences, our editor only allows BYDAY * * As defined in RFC5545 3.3.10. Recurrence Rule: * > Each BYDAY value can also be preceded by a positive (+n) or * > negative (-n) integer. If present, this indicates the nth * > occurrence of a specific day within the MONTHLY or YEARLY "RRULE". * * RFC 5545 specifies other components, which can be used along WEEKLY. * Among them are BYMONTH and BYSETPOS. We don't support those. */ const containsUnsupportedByParts = containsRecurrenceComponent(recurrenceRuleValue, FORBIDDEN_BY_PARTS_WEEKLY); const containsInvalidByDayPart = recurrenceRuleValue.getComponent('BYDAY').some(weekday => !SUPPORTED_BY_DAY_WEEKLY.includes(weekday)); const isUnsupported = containsUnsupportedByParts || containsInvalidByDayPart; const byDay = recurrenceRuleValue.getComponent('BYDAY').filter(weekday => SUPPORTED_BY_DAY_WEEKLY.includes(weekday)); // If the BYDAY is empty, add the day that the event occurs in // E.g. if the event is on a Wednesday, automatically set BYDAY:WE if (byDay.length === 0) { byDay.push((0,_utils_recurrence_js__WEBPACK_IMPORTED_MODULE_0__.getWeekDayFromDate)(baseDate.jsDate)); } return getDefaultRecurrenceRuleObjectForRecurrenceValue(recurrenceRuleValue, { byDay, isUnsupported }); }; /** * Maps a monthly calendar-js recurrence-rule-value to an recurrence-rule-object * * @param {RecurValue} recurrenceRuleValue The calendar-js recurrence rule value * @param {DateTimeValue} baseDate The base-date used to fill unset values * @return {object} */ const mapMonthlyRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate) => { /** * We only supports BYMONTHDAY, BYDAY, BYSETPOS in order to expand the monthly rule. * It supports either BYMONTHDAY or the combination of BYDAY and BYSETPOS. They have to be used exclusively * and cannot be combined. * * We do not support other BY-parts like BYMONTH * * For monthly recurrence-rules, BYDAY components are allowed to be preceded by positive or negative integers. * The Nextcloud-editor supports at most one BYDAY component with an integer. * If it's presented with such a BYDAY component, it will internally be converted to BYDAY without integer and BYSETPOS. * e.g. * BYDAY=3WE => BYDAY=WE,BYSETPOS=3 * * BYSETPOS is limited to -2, -1, 1, 2, 3, 4, 5 * Other values are not supported * * BYDAY is limited to "MO", "TU", "WE", "TH", "FR", "SA", "SU", * "MO,TU,WE,TH,FR,SA,SU", "MO,TU,WE,TH,FR", "SA,SU" * * BYMONTHDAY is limited to "1", "2", ..., "31" */ let isUnsupported = containsRecurrenceComponent(recurrenceRuleValue, FORBIDDEN_BY_PARTS_MONTHLY); let byDay = []; let bySetPosition = null; let byMonthDay = []; // This handles the first case, where we have a BYMONTHDAY rule if (containsRecurrenceComponent(recurrenceRuleValue, ['BYMONTHDAY'])) { // verify there is no BYDAY or BYSETPOS at the same time if (containsRecurrenceComponent(recurrenceRuleValue, ['BYDAY', 'BYSETPOS'])) { isUnsupported = true; } const containsInvalidByMonthDay = recurrenceRuleValue.getComponent('BYMONTHDAY').some(monthDay => !SUPPORTED_BY_MONTHDAY_MONTHLY.includes(monthDay.toString())); isUnsupported = isUnsupported || containsInvalidByMonthDay; byMonthDay = recurrenceRuleValue.getComponent('BYMONTHDAY').filter(monthDay => SUPPORTED_BY_MONTHDAY_MONTHLY.includes(monthDay.toString())).map(monthDay => monthDay.toString()); // This handles cases where we have both BYDAY and BYSETPOS } else if (containsRecurrenceComponent(recurrenceRuleValue, ['BYDAY']) && containsRecurrenceComponent(recurrenceRuleValue, ['BYSETPOS'])) { if (isAllowedByDay(recurrenceRuleValue.getComponent('BYDAY'))) { byDay = recurrenceRuleValue.getComponent('BYDAY'); } else { byDay = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']; isUnsupported = true; } const setPositionArray = recurrenceRuleValue.getComponent('BYSETPOS'); if (setPositionArray.length === 1 && isAllowedBySetPos(setPositionArray[0])) { bySetPosition = setPositionArray[0]; } else { bySetPosition = 1; isUnsupported = true; } // This handles cases where we only have a BYDAY } else if (containsRecurrenceComponent(recurrenceRuleValue, ['BYDAY'])) { const byDayArray = recurrenceRuleValue.getComponent('BYDAY'); if (byDayArray.length > 1) { byMonthDay.push(baseDate.day.toString()); isUnsupported = true; } else { const firstElement = byDayArray[0]; const match = /^(-?\d)([A-Z]{2})$/.exec(firstElement); if (match) { const matchedBySetPosition = match[1]; const matchedByDay = match[2]; if (isAllowedBySetPos(matchedBySetPosition)) { byDay = [matchedByDay]; bySetPosition = parseInt(matchedBySetPosition, 10); } else { byDay = [matchedByDay]; bySetPosition = 1; isUnsupported = true; } } else { byMonthDay.push(baseDate.day.toString()); isUnsupported = true; } } // This is a fallback where we just default BYMONTHDAY to the start date of the event } else { byMonthDay.push(baseDate.day.toString()); } return getDefaultRecurrenceRuleObjectForRecurrenceValue(recurrenceRuleValue, { byDay, bySetPosition, byMonthDay, isUnsupported }); }; /** * Maps a yearly calendar-js recurrence-rule-value to an recurrence-rule-object * * @param {RecurValue} recurrenceRuleValue The calendar-js recurrence rule value * @param {DateTimeValue} baseDate The base-date used to fill unset values * @return {object} */ const mapYearlyRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate) => { /** * We only supports BYMONTH, BYDAY, BYSETPOS in order to expand the yearly rule. * It supports a combination of them. * * We do not support other BY-parts. * * For yearly recurrence-rules, BYDAY components are allowed to be preceded by positive or negative integers. * The Nextcloud-editor supports at most one BYDAY component with an integer. * If it's presented with such a BYDAY component, it will internally be converted to BYDAY without integer and BYSETPOS. * e.g. * BYDAY=3WE => BYDAY=WE,BYSETPOS=3 * * BYSETPOS is limited to -2, -1, 1, 2, 3, 4, 5 * Other values are not supported * * BYDAY is limited to "MO", "TU", "WE", "TH", "FR", "SA", "SU", * "MO,TU,WE,TH,FR,SA,SU", "MO,TU,WE,TH,FR", "SA,SU" */ let isUnsupported = containsRecurrenceComponent(recurrenceRuleValue, FORBIDDEN_BY_PARTS_YEARLY); let byDay = []; let bySetPosition = null; let byMonth = []; if (containsRecurrenceComponent(recurrenceRuleValue, ['BYMONTH'])) { const containsInvalidByMonthDay = recurrenceRuleValue.getComponent('BYMONTH').some(month => !SUPPORTED_BY_MONTH_YEARLY.includes(month.toString())); isUnsupported = isUnsupported || containsInvalidByMonthDay; byMonth = recurrenceRuleValue.getComponent('BYMONTH').filter(monthDay => SUPPORTED_BY_MONTH_YEARLY.includes(monthDay.toString())).map(month => month.toString()); } else { byMonth.push(baseDate.month.toString()); } if (containsRecurrenceComponent(recurrenceRuleValue, ['BYDAY']) && containsRecurrenceComponent(recurrenceRuleValue, ['BYSETPOS'])) { if (isAllowedByDay(recurrenceRuleValue.getComponent('BYDAY'))) { byDay = recurrenceRuleValue.getComponent('BYDAY'); } else { byDay = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']; isUnsupported = true; } const setPositionArray = recurrenceRuleValue.getComponent('BYSETPOS'); if (setPositionArray.length === 1 && isAllowedBySetPos(setPositionArray[0])) { bySetPosition = setPositionArray[0]; } else { bySetPosition = 1; isUnsupported = true; } } else if (containsRecurrenceComponent(recurrenceRuleValue, ['BYDAY'])) { const byDayArray = recurrenceRuleValue.getComponent('BYDAY'); if (byDayArray.length > 1) { isUnsupported = true; } else { const firstElement = byDayArray[0]; const match = /^(-?\d)([A-Z]{2})$/.exec(firstElement); if (match) { const matchedBySetPosition = match[1]; const matchedByDay = match[2]; if (isAllowedBySetPos(matchedBySetPosition)) { byDay = [matchedByDay]; bySetPosition = parseInt(matchedBySetPosition, 10); } else { byDay = [matchedByDay]; bySetPosition = 1; isUnsupported = true; } } else { isUnsupported = true; } } } return getDefaultRecurrenceRuleObjectForRecurrenceValue(recurrenceRuleValue, { byDay, bySetPosition, byMonth, isUnsupported }); }; /** * Checks if the given parameter is a supported BYDAY value * * @param {string[]} byDay The byDay component to check * @return {boolean} */ const isAllowedByDay = byDay => { return ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU', 'FR,MO,SA,SU,TH,TU,WE', 'FR,MO,TH,TU,WE', 'SA,SU'].includes(byDay.slice().sort().join(',')); }; /** * Checks if the given parameter is a supported BYSETPOS value * * @param {string} bySetPos The bySetPos component to check * @return {boolean} */ const isAllowedBySetPos = bySetPos => { return ['-2', '-1', '1', '2', '3', '4', '5'].includes(bySetPos.toString()); }; /** * Checks if the recurrence-rule contains any of the given components * * @param {RecurValue} recurrenceRule The recurrence-rule value to check for the given components * @param {string[]} components List of components to check for * @return {boolean} */ const containsRecurrenceComponent = (recurrenceRule, components) => { for (const component of components) { const componentValue = recurrenceRule.getComponent(component); if (componentValue.length > 0) { return true; } } return false; }; /** * Returns a full recurrence-rule-object with default values derived from recurrenceRuleValue * and additional props * * @param {RecurValue} recurrenceRuleValue The recurrence-rule value to get default values from * @param {object} props The properties to provide on top of default one * @return {object} */ const getDefaultRecurrenceRuleObjectForRecurrenceValue = (recurrenceRuleValue, props) => { const isUnsupported = recurrenceRuleValue.count !== null && recurrenceRuleValue.until !== null; let isUnsupportedProps = {}; if (isUnsupported) { isUnsupportedProps = { isUnsupported }; } return getDefaultRecurrenceRuleObject(Object.assign({}, { recurrenceRuleValue, frequency: recurrenceRuleValue.frequency, interval: parseInt(recurrenceRuleValue.interval, 10) || 1, count: recurrenceRuleValue.count, until: recurrenceRuleValue.until ? (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(recurrenceRuleValue.until) : null }, props, isUnsupportedProps)); }; /***/ }), /***/ "./src/services/attachmentService.js": /*!*******************************************!*\ !*** ./src/services/attachmentService.js ***! \*******************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ createFolder: () => (/* binding */ createFolder), /* harmony export */ getFileInfo: () => (/* binding */ getFileInfo), /* harmony export */ shareFile: () => (/* binding */ shareFile), /* harmony export */ shareFileWith: () => (/* binding */ shareFileWith), /* harmony export */ uploadLocalAttachment: () => (/* binding */ uploadLocalAttachment), /* harmony export */ uploadRemoteFile: () => (/* binding */ uploadRemoteFile) /* harmony export */ }); /* harmony import */ var _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/axios */ "./node_modules/@nextcloud/axios/dist/index.es.mjs"); /* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs"); /* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.mjs"); /* harmony import */ var _nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nextcloud/l10n */ "./node_modules/@nextcloud/l10n/dist/index.mjs"); /* harmony import */ var webdav__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! webdav */ "./node_modules/webdav/dist/web/index.js"); /** * @copyright 2022 Mikhail Sazanov * * @author 2022 Mikhail Sazanov * @author Richard Steinmetz * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Makes a share link for a given file or directory. * * @param {string} path The file path from the user's root directory. e.g. `/myfile.txt` * @return {string} url share link */ const shareFile = async function (path) { try { const res = await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].post((0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateOcsUrl)('apps/files_sharing/api/v1/', 2) + 'shares', { shareType: OC.Share.SHARE_TYPE_LINK, path }); return res.data.ocs.data; } catch (error) { var _error$response; if (error !== null && error !== void 0 && (_error$response = error.response) !== null && _error$response !== void 0 && (_error$response = _error$response.data) !== null && _error$response !== void 0 && (_error$response = _error$response.ocs) !== null && _error$response !== void 0 && (_error$response = _error$response.meta) !== null && _error$response !== void 0 && _error$response.message) { console.error("Error while sharing file: ".concat(error.response.data.ocs.meta.message)); (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)(error.response.data.ocs.meta.message); throw error; } else { console.error('Error while sharing file: Unknown error'); (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Error while sharing file')); throw error; } } }; /** * Share file with a user with permissions * * @param path * @param sharedWith * @param permissions * @return {Promise<[{path: string, permissions, scope: string, name: string, backend: string, type: string},{path: string, permissions: *, scope: string, name: string, backend: string, type: string}]>} */ const shareFileWith = async function (path, sharedWith) { let permissions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 17; try { const url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateOcsUrl)('apps/files_sharing/api/v1/', 2); const res = await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].post("".concat(url, "shares"), { password: null, shareType: OC.Share.SHARE_TYPE_USER, // WITH USERS, permissions, // 14 - edit, 17 - view path, shareWith: sharedWith }); return res.data.ocs.data; } catch (error) { var _error$response2; if (error !== null && error !== void 0 && (_error$response2 = error.response) !== null && _error$response2 !== void 0 && (_error$response2 = _error$response2.data) !== null && _error$response2 !== void 0 && (_error$response2 = _error$response2.ocs) !== null && _error$response2 !== void 0 && (_error$response2 = _error$response2.meta) !== null && _error$response2 !== void 0 && _error$response2.message) { console.error("Error while sharing file with user: ".concat(error.response.data.ocs.meta.message)); (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)(error.response.data.ocs.meta.message); throw error; } else { console.error('Error while sharing file with user: Unknown error'); (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Error while sharing file with user')); throw error; } } }; const createFolder = async function (folderName, userId) { const url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateRemoteUrl)("dav/files/".concat(userId, "/").concat(folderName)); try { await (0,_nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"])({ method: 'MKCOL', url }); } catch (e) { var _e$response; if ((e === null || e === void 0 || (_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.status) !== 405) { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Error creating a folder {folder}', { folder: folderName })); // Maybe the actual upload succeeds -> keep going return folderName; } // Folder already exists if (folderName !== '/') { folderName = await findFirstOwnedFolder(folderName, userId); } } return folderName; }; const findFirstOwnedFolder = async function (path, userId) { var _info$multistatus; const infoXml = await getFileInfo(path, userId); const info = await (0,webdav__WEBPACK_IMPORTED_MODULE_4__.parseXML)(infoXml); const mountType = info === null || info === void 0 || (_info$multistatus = info.multistatus) === null || _info$multistatus === void 0 || (_info$multistatus = _info$multistatus.response[0]) === null || _info$multistatus === void 0 || (_info$multistatus = _info$multistatus.propstat) === null || _info$multistatus === void 0 || (_info$multistatus = _info$multistatus.prop) === null || _info$multistatus === void 0 ? void 0 : _info$multistatus['mount-type']; if (mountType !== 'shared') { return path; } const hierarchy = path.split('/'); hierarchy.pop(); if (hierarchy.length === 1) { return '/'; } return findFirstOwnedFolder(hierarchy.join('/'), userId); }; const uploadLocalAttachment = async function (folder, files, dav, componentAttachments) { const attachments = []; const promises = []; files.forEach(file => { // temp fix, until we decide where to save the attachments if (componentAttachments.map(attachment => attachment.fileName.split('/').pop()).indexOf(file.name) !== -1) { // TODO may be show user confirmation dialog to create a file named Existing_File_(2) ? (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Attachment {fileName} already exists!', { fileName: file.name })); } else { const url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateRemoteUrl)("dav/files/".concat(dav.userId, "/").concat(folder, "/").concat(file.name)); const res = _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].put(url, file).then(resp => { const data = { fileName: file.name, formatType: file.type, uri: url, value: url, path: "/".concat(file.name) }; if (resp.status === 204 || resp.status === 201) { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showSuccess)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Attachment {fileName} added!', { fileName: file.name })); attachments.push(data); } }).catch(() => { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'An error occurred during uploading file {fileName}', { fileName: file.name })); }); promises.push(res); } }); await Promise.all(promises); return attachments; }; const uploadRemoteFile = async function (folder, fileUrl, fileName, dav) { try { // Télécharger le fichier distant const response = await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].get(fileUrl, { responseType: 'blob' }); // Envoyer le fichier récupéré en PUT vers WebDAV const url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateRemoteUrl)("dav/files/".concat(dav.userId, "/").concat(folder, "/").concat(fileName)); const uploadResponse = await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].put(url, response.data, { headers: { 'Content-Type': response.data.type // Utilise le type MIME du fichier } }); if (uploadResponse.status === 204 || uploadResponse.status === 201) { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showSuccess)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'Attachment {fileName} added!', { fileName: fileName })); return { fileName: fileName, formatType: response.data.type, uri: url, value: url, path: "/".concat(fileName) }; } } catch (error) { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'An error occurred during uploading file {fileName}', { fileName: fileName })); return null; } }; // TODO is shared or not @share-types@ const getFileInfo = async function (path, userId) { const url = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateRemoteUrl)("dav/files/".concat(userId, "/").concat(path)); const res = await (0,_nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"])({ method: 'PROPFIND', url, data: "\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t" }).catch(() => { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_2__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_3__.translate)('calendar', 'An error occurred during getting file information')); }); return res.data; }; /***/ }), /***/ "./src/services/roleService.js": /*!*************************************!*\ !*** ./src/services/roleService.js ***! \*************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/axios */ "./node_modules/@nextcloud/axios/dist/index.es.mjs"); /* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs"); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ async fetchAndCommitRoles(commit) { try { var url = '/apps/gestion/getUserConnectedGroups'; const ajaxUrl = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.generateUrl)(url); _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].get(ajaxUrl).then(response => { let roles = JSON.parse(response.data); commit("setUserRole", roles); }).catch(error => {}); } catch (error) {} } }); /***/ }), /***/ "./src/services/settings.js": /*!**********************************!*\ !*** ./src/services/settings.js ***! \**********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ setConfig: () => (/* binding */ setConfig) /* harmony export */ }); /* harmony import */ var _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/axios */ "./node_modules/@nextcloud/axios/dist/index.es.mjs"); /* harmony import */ var _utils_settings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/settings.js */ "./src/utils/settings.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * * @param {string} key Config-key to set * @param {string | number | boolean} value Config-value to set * @return {Promise} */ const setConfig = async (key, value) => { await _nextcloud_axios__WEBPACK_IMPORTED_MODULE_0__["default"].post((0,_utils_settings_js__WEBPACK_IMPORTED_MODULE_1__.getLinkToConfig)(key), { value }); }; /***/ }), /***/ "./src/store/calendarObjectInstance.js": /*!*********************************************!*\ !*** ./src/store/calendarObjectInstance.js ***! \*********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /* harmony import */ var _services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/timezoneDataProviderService.js */ "./src/services/timezoneDataProviderService.js"); /* harmony import */ var _utils_date_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/date.js */ "./src/utils/date.js"); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _utils_recurrence_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/recurrence.js */ "./src/utils/recurrence.js"); /* harmony import */ var _models_event_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../models/event.js */ "./src/models/event.js"); /* harmony import */ var _utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/alarms.js */ "./src/utils/alarms.js"); /* harmony import */ var _utils_color_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/color.js */ "./src/utils/color.js"); /* harmony import */ var _models_alarm_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../models/alarm.js */ "./src/models/alarm.js"); /* harmony import */ var _utils_calendarObject_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/calendarObject.js */ "./src/utils/calendarObject.js"); /* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/logger.js */ "./src/utils/logger.js"); /* harmony import */ var _settings_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./settings.js */ "./src/store/settings.js"); /* harmony import */ var _models_rfcProps_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../models/rfcProps.js */ "./src/models/rfcProps.js"); /* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs"); /* harmony import */ var _services_talkService_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../services/talkService.js */ "./src/services/talkService.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * @copyright Copyright (c) 2023 Jonas Heinrich * * @author Georg Ehrke * @author Jonas Heinrich * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { isNew: null, calendarObject: null, calendarObjectInstance: null, existingEvent: { objectId: null, recurrenceId: null } }; const mutations = { /** * Set a calendar-object-instance that will be opened in the editor (existing event) * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObject The calendar-object currently being edited * @param {object} data.calendarObjectInstance The calendar-object-instance currently being edited * @param {string} data.objectId The objectId of the calendar-object * @param {number} data.recurrenceId The recurrence-id of the calendar-object-instance */ setCalendarObjectInstanceForExistingEvent(state, _ref) { let { calendarObject, calendarObjectInstance, objectId, recurrenceId } = _ref; state.isNew = false; state.calendarObject = calendarObject; state.calendarObjectInstance = calendarObjectInstance; state.existingEvent.objectId = objectId; state.existingEvent.recurrenceId = recurrenceId; }, /** * Set a calendar-object-instance that will be opened in the editor (new event) * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObject The calendar-object currently being created * @param {object} data.calendarObjectInstance The calendar-object-instance currently being crated */ setCalendarObjectInstanceForNewEvent(state, _ref2) { let { calendarObject, calendarObjectInstance } = _ref2; state.isNew = true; state.calendarObject = calendarObject; state.calendarObjectInstance = calendarObjectInstance; state.existingEvent.objectId = null; state.existingEvent.recurrenceId = null; }, /** * * @param {object} state The Vuex state */ resetCalendarObjectInstanceObjectIdAndRecurrenceId(state) { state.isNew = false; state.calendarObject = null; state.calendarObjectInstance = null; state.existingEvent.objectId = null; state.existingEvent.recurrenceId = null; }, /** * Change the title of the event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.title The new Title */ changeTitle(state, _ref3) { let { calendarObjectInstance, title } = _ref3; calendarObjectInstance.eventComponent.title = title; calendarObjectInstance.title = title; }, /** * Change the event's start * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {Date} data.startDate New start date to set */ changeStartDate(state, _ref4) { let { calendarObjectInstance, startDate } = _ref4; calendarObjectInstance.eventComponent.startDate.year = startDate.getFullYear(); calendarObjectInstance.eventComponent.startDate.month = startDate.getMonth() + 1; calendarObjectInstance.eventComponent.startDate.day = startDate.getDate(); calendarObjectInstance.eventComponent.startDate.hour = startDate.getHours(); calendarObjectInstance.eventComponent.startDate.minute = startDate.getMinutes(); calendarObjectInstance.eventComponent.startDate.second = 0; const isAllDay = calendarObjectInstance.eventComponent.isAllDay(); const endDateObj = calendarObjectInstance.eventComponent.endDate.clone(); const startDateObj = calendarObjectInstance.eventComponent.startDate.clone(); if (isAllDay) { endDateObj.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(-1 * 60 * 60 * 24)); if (endDateObj.compare(startDateObj) === -1) { const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(endDateObj.timezoneId); calendarObjectInstance.eventComponent.endDate = calendarObjectInstance.eventComponent.startDate.getInTimezone(timezone); calendarObjectInstance.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(calendarObjectInstance.eventComponent.endDate); calendarObjectInstance.eventComponent.endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(60 * 60 * 24)); } } else { if (endDateObj.compare(startDateObj) === -1) { const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(endDateObj.timezoneId); calendarObjectInstance.eventComponent.endDate = calendarObjectInstance.eventComponent.startDate.getInTimezone(timezone); calendarObjectInstance.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(calendarObjectInstance.eventComponent.endDate); } } calendarObjectInstance.startDate = startDate; }, /** * Change the timezone of the event's start * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.startTimezone New timezone to set for start */ changeStartTimezone(state, _ref5) { let { calendarObjectInstance, startTimezone } = _ref5; const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(startTimezone); calendarObjectInstance.eventComponent.startDate.replaceTimezone(timezone); calendarObjectInstance.startTimezoneId = startTimezone; // Either both are floating or both have a timezone, but it can't be mixed if (startTimezone === 'floating' || calendarObjectInstance.endTimezoneId === 'floating') { calendarObjectInstance.eventComponent.endDate.replaceTimezone(timezone); calendarObjectInstance.endTimezoneId = startTimezone; } }, /** * Change the event's end * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {Date} data.endDate New end date to set */ changeEndDate(state, _ref6) { let { calendarObjectInstance, endDate } = _ref6; // If the event is using DURATION, endDate is dynamically generated. // In order to alter it, we need to explicitly set DTEND const endDateObject = calendarObjectInstance.eventComponent.endDate; calendarObjectInstance.eventComponent.endDate = endDateObject; calendarObjectInstance.eventComponent.endDate.year = endDate.getFullYear(); calendarObjectInstance.eventComponent.endDate.month = endDate.getMonth() + 1; calendarObjectInstance.eventComponent.endDate.day = endDate.getDate(); calendarObjectInstance.eventComponent.endDate.hour = endDate.getHours(); calendarObjectInstance.eventComponent.endDate.minute = endDate.getMinutes(); calendarObjectInstance.eventComponent.endDate.second = 0; const isAllDay = calendarObjectInstance.eventComponent.isAllDay(); const endDateObj = calendarObjectInstance.eventComponent.endDate.clone(); const startDateObj = calendarObjectInstance.eventComponent.startDate.clone(); if (isAllDay) { if (endDateObj.compare(startDateObj) === -1) { const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(startDateObj.timezoneId); calendarObjectInstance.eventComponent.startDate = calendarObjectInstance.eventComponent.endDate.getInTimezone(timezone); calendarObjectInstance.startDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(calendarObjectInstance.eventComponent.startDate); } // endDate is inclusive, but DTEND needs to be exclusive, so always add one day calendarObjectInstance.eventComponent.endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(60 * 60 * 24)); } else { // Is end before start? if (endDateObj.compare(startDateObj) === -1) { // Is end more than one day before start? endDateObj.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(60 * 60 * 24)); if (endDateObj.compare(startDateObj) === -1) { const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(startDateObj.timezoneId); calendarObjectInstance.eventComponent.startDate = calendarObjectInstance.eventComponent.endDate.getInTimezone(timezone); calendarObjectInstance.startDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(calendarObjectInstance.eventComponent.startDate); } else { // add one day to endDate if the endDate is before the startDate which allows to easily create events that reach over or to 0:00 calendarObjectInstance.eventComponent.endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(60 * 60 * 24)); endDate = new Date(endDate.getTime() + 24 * 60 * 60 * 1000); } } } calendarObjectInstance.endDate = endDate; }, /** * Change the timezone of the event's end * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.endTimezone New timezone to set for end */ changeEndTimezone(state, _ref7) { let { calendarObjectInstance, endTimezone } = _ref7; const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(endTimezone); calendarObjectInstance.eventComponent.endDate.replaceTimezone(timezone); calendarObjectInstance.endTimezoneId = endTimezone; // Either both are floating or both have a timezone, but it can't be mixed if (endTimezone === 'floating' || calendarObjectInstance.startTimezoneId === 'floating') { calendarObjectInstance.eventComponent.startDate.replaceTimezone(timezone); calendarObjectInstance.startTimezoneId = endTimezone; } }, /** * Switch from a timed event to allday or vice versa * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ toggleAllDay(state, _ref8) { let { calendarObjectInstance } = _ref8; if (!calendarObjectInstance.eventComponent.canModifyAllDay()) { return; } const isAllDay = calendarObjectInstance.eventComponent.isAllDay(); calendarObjectInstance.eventComponent.startDate.isDate = !isAllDay; calendarObjectInstance.eventComponent.endDate.isDate = !isAllDay; calendarObjectInstance.isAllDay = calendarObjectInstance.eventComponent.isAllDay(); // isAllDay = old value if (isAllDay) { calendarObjectInstance.eventComponent.endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(-1 * 60 * 60 * 24)); } else { calendarObjectInstance.eventComponent.endDate.addDuration(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(60 * 60 * 24)); } }, /** * Is private * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ toggleIsPrivate(state, _ref9) { let { calendarObjectInstance, isPrivate } = _ref9; calendarObjectInstance.eventComponent.isPrivate = isPrivate; calendarObjectInstance.isPrivate = isPrivate; }, /** * Is private * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ toggleReturnToSiege(state, _ref10) { let { calendarObjectInstance, returnToSiege } = _ref10; calendarObjectInstance.eventComponent.returnToSiege = returnToSiege; calendarObjectInstance.returnToSiege = returnToSiege; }, /** *Email id * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ addEmailId(state, _ref11) { let { calendarObjectInstance, emailId } = _ref11; calendarObjectInstance.eventComponent.emailId = emailId; calendarObjectInstance.emailId = emailId; }, /** * Changes the time of a timed event to the default values * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ changeTimeToDefaultForTimedEvents(state, _ref12) { let { calendarObjectInstance } = _ref12; const startDate = calendarObjectInstance.eventComponent.startDate; const endDate = calendarObjectInstance.eventComponent.endDate; if (startDate.hour === 0 && startDate.minute === 0 && endDate.hour === 0 && endDate.minute === 0) { startDate.hour = 10; endDate.hour = 11; calendarObjectInstance.startDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(startDate); calendarObjectInstance.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(endDate); } }, /** * Change the location of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.location New location to set */ changeLocation(state, _ref13) { let { calendarObjectInstance, location } = _ref13; // Special case: delete Apple-specific location property to avoid inconsistencies calendarObjectInstance.eventComponent.deleteAllProperties('X-APPLE-STRUCTURED-LOCATION'); calendarObjectInstance.eventComponent.location = location; calendarObjectInstance.location = location; }, /** * Change the comment of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.comment New comment to set */ changeComment(state, _ref14) { let { calendarObjectInstance, comment } = _ref14; calendarObjectInstance.eventComponent.comment = comment; calendarObjectInstance.comment = comment; }, /** * Change the client of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.client New client to set */ changeClient(state, _ref15) { let { calendarObjectInstance, client } = _ref15; calendarObjectInstance.eventComponent.client = client; calendarObjectInstance.client = client; }, /** * Change the embalmer (Thanato) of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.embalmer New embalmer to set */ changeEmbalmer(state, _ref16) { let { calendarObjectInstance, embalmer } = _ref16; calendarObjectInstance.eventComponent.embalmer = embalmer; calendarObjectInstance.embalmer = embalmer; }, /** * Change the absence type of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.embalmer New embalmer to set */ changeAbsenceType(state, _ref17) { let { calendarObjectInstance, absenceType } = _ref17; calendarObjectInstance.eventComponent.absenceType = absenceType !== null && absenceType !== void 0 ? absenceType : null; calendarObjectInstance.absenceType = absenceType !== null && absenceType !== void 0 ? absenceType : null; if (absenceType) { const types = [{ value: 'LEAVE', label: 'Congé' }, { value: 'REST', label: 'Repos' }, { value: 'DISEASE', label: 'Arrêt maladie' }]; types.forEach(element => { if (element.value == absenceType) { calendarObjectInstance.title = element.label; calendarObjectInstance.eventComponent.title = element.label; if (absenceType == 'LEAVE') { const startDate = calendarObjectInstance.eventComponent.startDate; const endDate = calendarObjectInstance.eventComponent.endDate; startDate.hour = 8; endDate.hour = 17; calendarObjectInstance.startDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(startDate); calendarObjectInstance.endDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(endDate); } } }); } }, /** * Change the description of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.description New description to set */ changeDescription(state, _ref18) { let { calendarObjectInstance, description } = _ref18; // To avoid inconsistencies (bug #3863), remove all parameters (e.g., ALTREP) upon modification const descriptionProperty = calendarObjectInstance.eventComponent.getFirstProperty('Description'); if (descriptionProperty) { for (const parameter of descriptionProperty.getParametersIterator()) { descriptionProperty.deleteParameter(parameter.name); } } // Delete custom description properties calendarObjectInstance.eventComponent.deleteAllProperties('X-ALT-DESC'); calendarObjectInstance.eventComponent.description = description; calendarObjectInstance.description = description; }, /** * Change the access class of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.accessClass New access class to set */ changeAccessClass(state, _ref19) { let { calendarObjectInstance, accessClass } = _ref19; calendarObjectInstance.eventComponent.accessClass = accessClass; calendarObjectInstance.accessClass = accessClass; }, /** * Change the status of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.status New status to set */ changeStatus(state, _ref20) { let { calendarObjectInstance, status } = _ref20; calendarObjectInstance.eventComponent.status = status; calendarObjectInstance.status = status; }, /** * Change the time-transparency of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.timeTransparency New time-transparency to set */ changeTimeTransparency(state, _ref21) { let { calendarObjectInstance, timeTransparency } = _ref21; calendarObjectInstance.eventComponent.timeTransparency = timeTransparency; calendarObjectInstance.timeTransparency = timeTransparency; }, /** * Change the customized color of an event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string | null} data.customColor New color to set */ changeCustomColor(state, _ref22) { let { calendarObjectInstance, customColor } = _ref22; if (customColor === null) { calendarObjectInstance.eventComponent.deleteAllProperties('COLOR'); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance, 'customColor', null); return; } const cssColorName = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_6__.getClosestCSS3ColorNameForHex)(customColor); const hexColorOfCssName = (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_6__.getHexForColorName)(cssColorName); // Abort if either is undefined if (!cssColorName || !hexColorOfCssName) { console.error('Setting custom color failed'); console.error('customColor: ', customColor); console.error('cssColorName: ', cssColorName); console.error('hexColorOfCssName: ', hexColorOfCssName); return; } calendarObjectInstance.eventComponent.color = cssColorName; vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance, 'customColor', hexColorOfCssName); }, /** * Adds an attendee to the event and sets the organizer if not present already * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.commonName Displayname of attendee * @param {string} data.uri Email address of attendee * @param {string} data.calendarUserType Calendar-user-type of attendee (INDIVIDUAL, GROUP, RESOURCE, ROOM) * @param {string} data.participationStatus Participation Status of attendee * @param {string} data.role Role of Attendee * @param {boolean} data.rsvp Whether or not to request a response from the attendee * @param {string=} data.language Preferred language of the attendee * @param {string=} data.timezoneId Preferred timezone of the attendee * @param {object=} data.organizer Principal of the organizer to be set if not present * @param data.member */ addAttendee(state, _ref23) { let { calendarObjectInstance, commonName, uri, calendarUserType = null, participationStatus = null, role = null, rsvp = null, language = null, timezoneId = null, organizer = null, member = null } = _ref23; const attendee = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.AttendeeProperty.fromNameAndEMail(commonName, uri); if (calendarUserType !== null) { attendee.userType = calendarUserType; } if (participationStatus !== null) { attendee.participationStatus = participationStatus; } if (role !== null) { attendee.role = role; } if (rsvp !== null) { attendee.rsvp = rsvp; } if (language !== null) { attendee.language = language; } if (timezoneId !== null) { attendee.updateParameterIfExist('TZID', timezoneId); } if (member !== null) { attendee.updateParameterIfExist('MEMBER', member); } // TODO - use real addAttendeeFrom method calendarObjectInstance.eventComponent.addProperty(attendee); calendarObjectInstance.attendees.push({ commonName, participationStatus, role, rsvp, uri, attendeeProperty: attendee }); if (!calendarObjectInstance.organizer && organizer) { this.commit('setOrganizer', { calendarObjectInstance, commonName: organizer.displayname, email: organizer.emailAddress }); } }, /** * Removes an attendee from the event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.attendee The attendee object to remove */ removeAttendee(state, _ref24) { let { calendarObjectInstance, attendee } = _ref24; calendarObjectInstance.eventComponent.removeAttendee(attendee.attendeeProperty); // Also remove members if attendee is a group if (attendee.attendeeProperty.userType === 'GROUP') { attendee.members.forEach(function (member) { calendarObjectInstance.eventComponent.removeAttendee(member.attendeeProperty); const index = calendarObjectInstance.attendees.indexOf(member); if (index !== -1) { calendarObjectInstance.attendees.splice(index, 1); } }); } const index = calendarObjectInstance.attendees.indexOf(attendee); if (index !== -1) { calendarObjectInstance.attendees.splice(index, 1); } }, /** * Changes an attendees' participation status * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.attendee The attendee object * @param {string} data.participationStatus New Participation Status of attendee */ changeAttendeesParticipationStatus(state, _ref25) { let { attendee, participationStatus } = _ref25; attendee.attendeeProperty.participationStatus = participationStatus; attendee.participationStatus = participationStatus; }, /** * Changes an attendees' role * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.attendee The attendee object * @param {string} data.role New role of attendee */ changeAttendeesRole(state, _ref26) { let { attendee, role } = _ref26; attendee.attendeeProperty.role = role; attendee.role = role; }, /** * Changes an attendees' RVSP * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.attendee The attendee object */ toggleAttendeeRSVP(state, _ref27) { let { attendee } = _ref27; const oldRSVP = attendee.attendeeProperty.rsvp; attendee.attendeeProperty.rsvp = !oldRSVP; attendee.rsvp = !oldRSVP; }, /** * Set the event's organizer * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string=} data.commonName Displayname of organizer * @param {string} data.email Email-address of organizer */ setOrganizer(state, _ref28) { let { calendarObjectInstance, commonName = null, email } = _ref28; calendarObjectInstance.eventComponent.setOrganizerFromNameAndEMail(commonName, email); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance, 'organizer', {}); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance.organizer, 'commonName', commonName); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance.organizer, 'uri', email); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance.organizer, 'attendeeProperty', calendarObjectInstance.eventComponent.getFirstProperty('ORGANIZER')); }, /** * Adds a category to the event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.category Category to add */ addCategory(state, _ref29) { let { calendarObjectInstance, category } = _ref29; calendarObjectInstance.eventComponent.addCategory(category); calendarObjectInstance.categories.push(category); }, /** * Removes a category from the event * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.category Category to remove */ removeCategory(state, _ref30) { let { calendarObjectInstance, category } = _ref30; calendarObjectInstance.eventComponent.removeCategory(category); const index = calendarObjectInstance.categories.indexOf(category); if (index !== -1) { calendarObjectInstance.categories.splice(index, 1); } }, /** * Change the interval of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.interval The new interval to set */ changeRecurrenceInterval(state, _ref31) { let { calendarObjectInstance, recurrenceRule, interval } = _ref31; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.interval = interval; recurrenceRule.interval = interval; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the frequency of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.frequency The new frequency to set */ changeRecurrenceFrequency(state, _ref32) { let { calendarObjectInstance, recurrenceRule, frequency } = _ref32; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.frequency = frequency; recurrenceRule.frequency = frequency; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the count limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.count The new count to set */ changeRecurrenceCount(state, _ref33) { let { calendarObjectInstance, recurrenceRule, count } = _ref33; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.count = count; recurrenceRule.count = count; recurrenceRule.until = null; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {Date} data.until The new until to set */ changeRecurrenceUntil(state, _ref34) { let { calendarObjectInstance, recurrenceRule, until } = _ref34; if (recurrenceRule.recurrenceRuleValue) { // RFC 5545, setion 3.3.10: until must be in UTC if the start time is timezone-aware if (calendarObjectInstance.startTimezoneId !== 'floating') { recurrenceRule.recurrenceRuleValue.until = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DateTimeValue.fromJSDate(until, { zone: 'utc' }); } else { recurrenceRule.recurrenceRuleValue.until = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DateTimeValue.fromJSDate(until); } recurrenceRule.until = until; recurrenceRule.count = null; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Changes the recurrence-rule to never end * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ changeRecurrenceToInfinite(state, _ref35) { let { calendarObjectInstance, recurrenceRule } = _ref35; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.setToInfinite(); recurrenceRule.until = null; recurrenceRule.count = null; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Reset the By-parts of the recurrence rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ resetRecurrenceByParts(state, _ref36) { let { calendarObjectInstance, recurrenceRule } = _ref36; if (recurrenceRule.recurrenceRuleValue) { const parts = ['BYSECOND', 'BYMINUTE', 'BYHOUR', 'BYDAY', 'BYMONTHDAY', 'BYYEARDAY', 'BYWEEKNO', 'BYMONTH', 'BYSETPOS']; for (const part of parts) { recurrenceRule.recurrenceRuleValue.setComponent(part, []); } vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'byDay', []); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'byMonth', []); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'byMonthDay', []); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'bySetPosition', null); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Reset the By-parts of the recurrence rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ setDefaultRecurrenceByPartsForWeekly(state, _ref37) { let { calendarObjectInstance, recurrenceRule } = _ref37; if (recurrenceRule.recurrenceRuleValue) { const byDay = (0,_utils_recurrence_js__WEBPACK_IMPORTED_MODULE_3__.getWeekDayFromDate)(calendarObjectInstance.startDate); recurrenceRule.recurrenceRuleValue.setComponent('BYDAY', [byDay]); recurrenceRule.byDay.push(byDay); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Reset the By-parts of the recurrence rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ setDefaultRecurrenceByPartsForMonthly(state, _ref38) { let { calendarObjectInstance, recurrenceRule } = _ref38; if (recurrenceRule.recurrenceRuleValue) { const byMonthDay = calendarObjectInstance.startDate.getDate().toString(); recurrenceRule.recurrenceRuleValue.setComponent('BYMONTHDAY', [byMonthDay]); recurrenceRule.byMonthDay.push(byMonthDay); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ setDefaultRecurrenceByPartsForMonthlyBySetPosition(state, _ref39) { let { calendarObjectInstance, recurrenceRule } = _ref39; if (recurrenceRule.recurrenceRuleValue) { const { byDay, bySetPosition } = (0,_utils_recurrence_js__WEBPACK_IMPORTED_MODULE_3__.getBySetPositionAndBySetFromDate)(calendarObjectInstance.startDate); recurrenceRule.recurrenceRuleValue.setComponent('BYDAY', [byDay]); recurrenceRule.recurrenceRuleValue.setComponent('BYSETPOS', [bySetPosition]); recurrenceRule.byDay.push(byDay); recurrenceRule.bySetPosition = bySetPosition; console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Reset the By-parts of the recurrence rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ setDefaultRecurrenceByPartsForYearly(state, _ref40) { let { calendarObjectInstance, recurrenceRule } = _ref40; if (recurrenceRule.recurrenceRuleValue) { const byMonth = calendarObjectInstance.startDate.getMonth() + 1; // Javascript months are zero-based recurrenceRule.recurrenceRuleValue.setComponent('BYMONTH', [byMonth]); recurrenceRule.byMonth.push(byMonth); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byDay The new until to set */ addByDayToRecurrenceRule(state, _ref41) { let { calendarObjectInstance, recurrenceRule, byDay } = _ref41; if (recurrenceRule.recurrenceRuleValue) { const byDayList = recurrenceRule.recurrenceRuleValue.getComponent('BYDAY'); const index = byDayList.indexOf(byDay); if (index === -1) { byDayList.push(byDay); recurrenceRule.recurrenceRuleValue.setComponent('BYDAY', byDayList); } const index2 = recurrenceRule.byDay.indexOf(byDay); if (index2 === -1) { recurrenceRule.byDay.push(byDay); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byDay The new until to set */ removeByDayFromRecurrenceRule(state, _ref42) { let { calendarObjectInstance, recurrenceRule, byDay } = _ref42; if (recurrenceRule.recurrenceRuleValue) { const byDayList = recurrenceRule.recurrenceRuleValue.getComponent('BYDAY'); const index = byDayList.indexOf(byDay); if (index !== -1) { byDayList.splice(index, 1); recurrenceRule.recurrenceRuleValue.setComponent('BYDAY', byDayList); } const index2 = recurrenceRule.byDay.indexOf(byDay); if (index2 !== -1) { recurrenceRule.byDay.splice(index2, 1); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byMonthDay The new until to set */ addByMonthDayToRecurrenceRule(state, _ref43) { let { calendarObjectInstance, recurrenceRule, byMonthDay } = _ref43; if (recurrenceRule.recurrenceRuleValue) { const byMonthDayList = recurrenceRule.recurrenceRuleValue.getComponent('BYMONTHDAY'); const index = byMonthDayList.indexOf(byMonthDay); if (index === -1) { byMonthDayList.push(byMonthDay); recurrenceRule.recurrenceRuleValue.setComponent('BYMONTHDAY', byMonthDayList); } const index2 = recurrenceRule.byMonthDay.indexOf(byMonthDay); if (index2 === -1) { recurrenceRule.byMonthDay.push(byMonthDay); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byMonthDay The new until to set */ removeByMonthDayFromRecurrenceRule(state, _ref44) { let { calendarObjectInstance, recurrenceRule, byMonthDay } = _ref44; if (recurrenceRule.recurrenceRuleValue) { const byMonthDayList = recurrenceRule.recurrenceRuleValue.getComponent('BYMONTHDAY'); const index = byMonthDayList.indexOf(byMonthDay); if (index !== -1) { byMonthDayList.splice(index, 1); recurrenceRule.recurrenceRuleValue.setComponent('BYMONTHDAY', byMonthDayList); } const index2 = recurrenceRule.byMonthDay.indexOf(byMonthDay); if (index2 !== -1) { recurrenceRule.byMonthDay.splice(index2, 1); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byMonth The new until to set */ addByMonthToRecurrenceRule(state, _ref45) { let { calendarObjectInstance, recurrenceRule, byMonth } = _ref45; if (recurrenceRule.recurrenceRuleValue) { console.debug('addByMonthToRecurrenceRule', byMonth); const byMonthList = recurrenceRule.recurrenceRuleValue.getComponent('BYMONTH'); const index = byMonthList.indexOf(byMonth); if (index === -1) { byMonthList.push(byMonth); recurrenceRule.recurrenceRuleValue.setComponent('BYMONTH', byMonthList); } const index2 = recurrenceRule.byMonth.indexOf(byMonth); if (index2 === -1) { recurrenceRule.byMonth.push(byMonth); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.byMonth The new until to set */ removeByMonthFromRecurrenceRule(state, _ref46) { let { calendarObjectInstance, recurrenceRule, byMonth } = _ref46; if (recurrenceRule.recurrenceRuleValue) { console.debug('removeByMonthFromRecurrenceRule', byMonth); const byMonthList = recurrenceRule.recurrenceRuleValue.getComponent('BYMONTH'); const index = byMonthList.indexOf(byMonth); if (index !== -1) { byMonthList.splice(index, 1); recurrenceRule.recurrenceRuleValue.setComponent('BYMONTH', byMonthList); } const index2 = recurrenceRule.byMonth.indexOf(byMonth); if (index2 !== -1) { recurrenceRule.byMonth.splice(index2, 1); } console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string[]} data.byDay The new until to set */ changeRecurrenceByDay(state, _ref47) { let { calendarObjectInstance, recurrenceRule, byDay } = _ref47; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.setComponent('BYDAY', byDay); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'byDay', byDay); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Change the until limit of the recurrence-rule * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify * @param {string} data.bySetPosition The new until to set */ changeRecurrenceBySetPosition(state, _ref48) { let { calendarObjectInstance, recurrenceRule, bySetPosition } = _ref48; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.setComponent('BYSETPOS', [bySetPosition]); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'bySetPosition', bySetPosition); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ unsetRecurrenceBySetPosition(state, _ref49) { let { calendarObjectInstance, recurrenceRule } = _ref49; if (recurrenceRule.recurrenceRuleValue) { recurrenceRule.recurrenceRuleValue.setComponent('BYSETPOS', []); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(recurrenceRule, 'bySetPosition', null); console.debug(recurrenceRule.recurrenceRuleValue._innerValue.toString()); } }, /** * Remove the recurrence-rule from the calendarObjectInstance * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ removeRecurrenceRuleFromCalendarObjectInstance(state, _ref50) { let { calendarObjectInstance, recurrenceRule } = _ref50; if (recurrenceRule.recurrenceRuleValue) { calendarObjectInstance.eventComponent.deleteAllProperties('RRULE'); vue__WEBPACK_IMPORTED_MODULE_14__["default"].set(calendarObjectInstance, 'recurrenceRule', (0,_models_event_js__WEBPACK_IMPORTED_MODULE_4__.getDefaultEventObject)().recurrenceRule); console.debug(calendarObjectInstance); console.debug(recurrenceRule); } }, /** * Add a new recurrence-rule to the calendarObjectInstance * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object */ addRecurrenceRuleFromCalendarObjectInstance(state, _ref51) { let { calendarObjectInstance } = _ref51; const recurrenceValue = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.RecurValue.fromData({}); const recurrenceProperty = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Property('RRULE', recurrenceValue); calendarObjectInstance.eventComponent.addProperty(recurrenceProperty); calendarObjectInstance.recurrenceRule.recurrenceRuleValue = recurrenceValue; }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.recurrenceRule The recurrenceRule object to modify */ markRecurrenceRuleAsSupported(state, _ref52) { let { calendarObjectInstance, recurrenceRule } = _ref52; recurrenceRule.isUnsupported = false; }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {string} data.type New type of alarm */ changeAlarmType(state, _ref53) { let { calendarObjectInstance, alarm, type } = _ref53; if (alarm.alarmComponent) { alarm.alarmComponent.action = type; alarm.type = type; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {number} data.amount New amount of timed event */ changeAlarmAmountTimed(state, _ref54) { let { calendarObjectInstance, alarm, amount } = _ref54; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.totalSeconds = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getTotalSecondsFromAmountAndUnitForTimedEvents)(amount, alarm.relativeUnitTimed, alarm.relativeIsBefore); alarm.relativeAmountTimed = amount; alarm.relativeTrigger = alarm.alarmComponent.trigger.value.totalSeconds; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {string} data.unit New unit of timed event */ changeAlarmUnitTimed(state, _ref55) { let { calendarObjectInstance, alarm, unit } = _ref55; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.totalSeconds = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getTotalSecondsFromAmountAndUnitForTimedEvents)(alarm.relativeAmountTimed, unit, alarm.relativeIsBefore); alarm.relativeUnitTimed = unit; alarm.relativeTrigger = alarm.alarmComponent.trigger.value.totalSeconds; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {number} data.amount New amount of all-day event */ changeAlarmAmountAllDay(state, _ref56) { let { calendarObjectInstance, alarm, amount } = _ref56; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.totalSeconds = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents)(amount, alarm.relativeHoursAllDay, alarm.relativeMinutesAllDay, alarm.relativeUnitAllDay); alarm.relativeAmountAllDay = amount; alarm.relativeTrigger = alarm.alarmComponent.trigger.value.totalSeconds; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {string} data.unit New Unit of all-day event */ changeAlarmUnitAllDay(state, _ref57) { let { calendarObjectInstance, alarm, unit } = _ref57; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.totalSeconds = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents)(alarm.relativeAmountAllDay, alarm.relativeHoursAllDay, alarm.relativeMinutesAllDay, unit); alarm.relativeUnitAllDay = unit; alarm.relativeTrigger = alarm.alarmComponent.trigger.value.totalSeconds; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {number} data.hours New Hour * @param {number} data.minutes New Minutes */ changeAlarmHoursMinutesAllDay(state, _ref58) { let { calendarObjectInstance, alarm, hours, minutes } = _ref58; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.totalSeconds = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents)(alarm.relativeAmountAllDay, hours, minutes, alarm.relativeUnitAllDay); alarm.relativeHoursAllDay = hours; alarm.relativeMinutesAllDay = minutes; alarm.relativeTrigger = alarm.alarmComponent.trigger.value.totalSeconds; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {Date} data.date New date object */ changeAlarmAbsoluteDate(state, _ref59) { let { calendarObjectInstance, alarm, date } = _ref59; if (alarm.alarmComponent) { alarm.alarmComponent.trigger.value.year = date.getFullYear(); alarm.alarmComponent.trigger.value.month = date.getMonth() + 1; alarm.alarmComponent.trigger.value.day = date.getDate(); alarm.alarmComponent.trigger.value.hour = date.getHours(); alarm.alarmComponent.trigger.value.minute = date.getMinutes(); alarm.alarmComponent.trigger.value.second = 0; alarm.absoluteDate = date; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object * @param {string} data.timezoneId New timezoneId */ changeAlarmAbsoluteTimezoneId(state, _ref60) { let { calendarObjectInstance, alarm, timezoneId } = _ref60; if (alarm.alarmComponent) { const timezone = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_0__["default"])().getTimezoneForId(timezoneId); alarm.alarmComponent.trigger.value.replaceTimezone(timezone); alarm.absoluteTimezoneId = timezoneId; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object */ changeAlarmFromRelativeToAbsolute(state, _ref61) { let { calendarObjectInstance, alarm } = _ref61; if (alarm.alarmComponent) { const triggerDateTime = calendarObjectInstance.eventComponent.startDate.clone(); // The trigger of an alarm must be DATE-TIME, startDate can be either. triggerDateTime.isDate = false; triggerDateTime.addDuration(alarm.alarmComponent.trigger.value); alarm.alarmComponent.setTriggerFromAbsolute(triggerDateTime); alarm.absoluteDate = (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_1__.getDateFromDateTimeValue)(alarm.alarmComponent.trigger.value); alarm.absoluteTimezoneId = alarm.alarmComponent.trigger.value.timezoneId; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object */ changeAlarmFromAbsoluteToRelative(state, _ref62) { let { calendarObjectInstance, alarm } = _ref62; if (alarm.alarmComponent) { const duration = alarm.alarmComponent.trigger.value.subtractDateWithTimezone(calendarObjectInstance.eventComponent.startDate); alarm.alarmComponent.setTriggerFromRelative(duration); alarm.relativeIsBefore = alarm.alarmComponent.trigger.value.isNegative; alarm.relativeIsRelatedToStart = true; alarm.relativeTrigger = duration.totalSeconds; } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.alarm The alarm object */ resetAlarmRelativeParts(state, _ref63) { let { alarm } = _ref63; alarm.relativeIsBefore = null; alarm.relativeIsRelatedToStart = null; alarm.relativeUnitTimed = null; alarm.relativeAmountTimed = null; alarm.relativeUnitAllDay = null; alarm.relativeAmountAllDay = null; alarm.relativeHoursAllDay = null; alarm.relativeMinutesAllDay = null; alarm.relativeTrigger = null; }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.alarm The alarm object */ resetAlarmAbsoluteParts(state, _ref64) { let { alarm } = _ref64; alarm.absoluteDate = null; alarm.absoluteTimezoneId = null; }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object */ updateAlarmAllDayParts(state, _ref65) { let { calendarObjectInstance, alarm } = _ref65; if (alarm.alarmComponent) { const totalSeconds = alarm.alarmComponent.trigger.value.totalSeconds; const allDayParts = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getAmountHoursMinutesAndUnitForAllDayEvents)(totalSeconds); alarm.relativeUnitAllDay = allDayParts.unit; alarm.relativeAmountAllDay = allDayParts.amount; alarm.relativeHoursAllDay = allDayParts.hours; alarm.relativeMinutesAllDay = allDayParts.minutes; } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object */ updateAlarmTimedParts(state, _ref66) { let { calendarObjectInstance, alarm } = _ref66; if (alarm.alarmComponent) { const totalSeconds = alarm.alarmComponent.trigger.value.totalSeconds; const timedParts = (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.getAmountAndUnitForTimedEvents)(totalSeconds); alarm.relativeUnitTimed = timedParts.unit; alarm.relativeAmountTimed = timedParts.amount; console.debug(alarm.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {string} data.type Type of alarm * @param {number} data.totalSeconds Total amount of seconds for new alarm */ addAlarmToCalendarObjectInstance(state, _ref67) { let { calendarObjectInstance, type, totalSeconds } = _ref67; if (calendarObjectInstance.eventComponent) { const eventComponent = calendarObjectInstance.eventComponent; const duration = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DurationValue.fromSeconds(totalSeconds); const alarmComponent = eventComponent.addRelativeAlarm(type, duration); const alarmObject = (0,_models_alarm_js__WEBPACK_IMPORTED_MODULE_7__.mapAlarmComponentToAlarmObject)(alarmComponent); calendarObjectInstance.alarms.push(alarmObject); console.debug(alarmObject.alarmComponent.toICALJs().toString()); } }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.alarm The alarm object */ removeAlarmFromCalendarObjectInstance(state, _ref68) { let { calendarObjectInstance, alarm } = _ref68; if (alarm.alarmComponent) { calendarObjectInstance.eventComponent.removeAlarm(alarm.alarmComponent); const index = calendarObjectInstance.alarms.indexOf(alarm); if (index !== -1) { calendarObjectInstance.alarms.splice(index, 1); } } }, /** * @deprecated * @param state * @param calendarObjectInstance.calendarObjectInstance * @param calendarObjectInstance * @param calendarObjectInstance.sharedData * @param sharedData */ addAttachmentBySharedData(state, _ref69) { let { calendarObjectInstance, sharedData } = _ref69; const attachment = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.AttachmentProperty.fromLink(sharedData.url); const fileName = sharedData.fileName; // hot-fix needed temporary, becase calendar-js has no fileName get-setter const parameterFileName = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('FILENAME', fileName); // custom has-preview parameter from dav file const xNcHasPreview = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-HAS-PREVIEW', sharedData['has-preview'].toString()); // custom file id parameter from dav file const xNcFileId = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-FILE-ID', sharedData.fileid.toString()); // custom share-types parameter from dav file const xNcSharedTypes = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-SHARED-TYPES', sharedData['share-types']['share-type'] ? sharedData['share-types']['share-type'].join(',') : ''); attachment.setParameter(parameterFileName); attachment.setParameter(xNcFileId); attachment.setParameter(xNcHasPreview); attachment.setParameter(xNcSharedTypes); attachment.isNew = true; attachment.shareTypes = sharedData['share-types']['share-type'] ? sharedData['share-types']['share-type'].join(',') : ''; attachment.fileName = fileName; attachment.xNcFileId = sharedData.fileid; attachment.xNcHasPreview = sharedData['has-preview']; attachment.formatType = sharedData.getcontenttype; attachment.uri = sharedData.url ? sharedData.url : (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_12__.generateUrl)("/f/".concat(sharedData.fileid)); calendarObjectInstance.eventComponent.addProperty(attachment); calendarObjectInstance.attachments.push(attachment); // console.log(attachment) }, addAttachmentWithProperty(state, _ref70) { var _ref71, _sharedData$shareTyp, _sharedData$shareTyp2, _sharedData$shareTyp3; let { calendarObjectInstance, sharedData } = _ref70; const attachment = {}; const fileName = sharedData.fileName; attachment.isNew = true; attachment.shareTypes = (_ref71 = typeof (sharedData === null || sharedData === void 0 || (_sharedData$shareTyp = sharedData['share-types']) === null || _sharedData$shareTyp === void 0 ? void 0 : _sharedData$shareTyp['share-type']) === 'number' ? sharedData === null || sharedData === void 0 || (_sharedData$shareTyp2 = sharedData['share-types']) === null || _sharedData$shareTyp2 === void 0 || (_sharedData$shareTyp2 = _sharedData$shareTyp2['share-type']) === null || _sharedData$shareTyp2 === void 0 ? void 0 : _sharedData$shareTyp2.toString() : sharedData === null || sharedData === void 0 || (_sharedData$shareTyp3 = sharedData['share-types']) === null || _sharedData$shareTyp3 === void 0 || (_sharedData$shareTyp3 = _sharedData$shareTyp3['share-type']) === null || _sharedData$shareTyp3 === void 0 ? void 0 : _sharedData$shareTyp3.join(',')) !== null && _ref71 !== void 0 ? _ref71 : null; attachment.fileName = fileName; attachment.xNcFileId = sharedData.fileid; attachment.xNcHasPreview = sharedData['has-preview']; attachment.formatType = sharedData.getcontenttype; attachment.uri = sharedData.url ? sharedData.url : (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_12__.generateUrl)("/f/".concat(sharedData.fileid)); const attachmentProperty = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.AttachmentProperty.fromLink(attachment.uri, attachment.formatType); const parameterFileName = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('FILENAME', fileName); const xNcHasPreview = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-HAS-PREVIEW', attachment.xNcHasPreview.toString()); const xNcFileId = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-FILE-ID', attachment.xNcFileId.toString()); // ADD X-NC-SHARED-TYPES only if sharet-type not empty if (attachment.shareTypes !== null) { const xNcSharedTypes = new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.Parameter('X-NC-SHARED-TYPES', attachment.shareTypes); attachmentProperty.setParameter(xNcSharedTypes); } attachmentProperty.setParameter(parameterFileName); attachmentProperty.setParameter(xNcFileId); attachmentProperty.setParameter(xNcHasPreview); attachmentProperty.uri = attachment.uri; attachment.attachmentProperty = attachmentProperty; calendarObjectInstance.eventComponent.addProperty(attachmentProperty); calendarObjectInstance.attachments.push(attachment); }, /** * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.attachment The attachment object */ deleteAttachment(state, _ref72) { let { calendarObjectInstance, attachment } = _ref72; try { const index = calendarObjectInstance.attachments.indexOf(attachment); if (index !== -1) { calendarObjectInstance.attachments.splice(index, 1); } calendarObjectInstance.eventComponent.removeAttachment(attachment.attachmentProperty); } catch {} }, setAbsenceType(state, _ref73) { let { calendarObjectInstance, absenceType } = _ref73; if (calendarObjectInstance) { calendarObjectInstance.absenceType = absenceType; } } }; const getters = {}; const actions = { /** * Returns the closest existing recurrence-id of a calendar-object * close to the given date. * This is either the next occurrence in the future or * in case there are no more future occurrences the closest * occurrence in the past * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {string} data.objectId The objectId of the calendar-object to edit * @param {Date} data.closeToDate The date to get a close occurrence to * @return {Promise} */ async resolveClosestRecurrenceIdForCalendarObject(_ref74, _ref75) { let { state, dispatch, commit } = _ref74; let { objectId, closeToDate } = _ref75; const calendarObject = await dispatch('getEventByObjectId', { objectId }); const iterator = calendarObject.calendarComponent.getVObjectIterator(); const firstVObject = iterator.next().value; const d = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DateTimeValue.fromJSDate(closeToDate, true); return firstVObject.recurrenceManager.getClosestOccurrence(d).getReferenceRecurrenceId().unixTime; }, /** * Gets the calendar-object and calendar-object-instance * for a given objectId and recurrenceId. * * If the recurrenceId does not represent a valid instance, * an error will be thrown. * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {string} data.objectId The objectId of the calendar-object to edit * @param {number} data.recurrenceId The recurrence-id to edit * @return {Promise<{calendarObject: object, calendarObjectInstance: object}>} */ async getCalendarObjectInstanceByObjectIdAndRecurrenceId(_ref76, _ref77) { let { state, dispatch, commit } = _ref76; let { objectId, recurrenceId } = _ref77; if (state.existingEvent.objectId === objectId && state.existingEvent.recurrenceId === recurrenceId) { return Promise.resolve({ calendarObject: state.calendarObject, calendarObjectInstance: state.calendarObjectInstance }); } const recurrenceIdDate = new Date(recurrenceId * 1000); const calendarObject = await dispatch('getEventByObjectId', { objectId }); const eventComponent = (0,_utils_calendarObject_js__WEBPACK_IMPORTED_MODULE_8__.getObjectAtRecurrenceId)(calendarObject, recurrenceIdDate); if (eventComponent === null) { throw new Error('Not a valid recurrence-id'); } const calendarObjectInstance = (0,_models_event_js__WEBPACK_IMPORTED_MODULE_4__.mapEventComponentToEventObject)(eventComponent); commit('setCalendarObjectInstanceForExistingEvent', { calendarObject, calendarObjectInstance, objectId, recurrenceId }); return { calendarObject, calendarObjectInstance }; }, /** * Gets the new calendar-object-instance. * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {boolean} data.isAllDay Whether or not the new event is supposed to be all-day * @param {number} data.start The start of the new event (unixtime) * @param {number} data.end The end of the new event (unixtime) * @param {string} data.timezoneId The timezoneId of the new event * @return {Promise<{calendarObject: object, calendarObjectInstance: object}>} */ async getCalendarObjectInstanceForNewEvent(_ref78, _ref79) { let { state, dispatch, commit } = _ref78; let { isAllDay, start, end, timezoneId } = _ref79; if (state.isNew === true) { return Promise.resolve({ calendarObject: state.calendarObject, calendarObjectInstance: state.calendarObjectInstance }); } const calendarObject = await dispatch('createNewEvent', { start, end, isAllDay, timezoneId }); const startDate = new Date(start * 1000); const eventComponent = (0,_utils_calendarObject_js__WEBPACK_IMPORTED_MODULE_8__.getObjectAtRecurrenceId)(calendarObject, startDate); const calendarObjectInstance = (0,_models_event_js__WEBPACK_IMPORTED_MODULE_4__.mapEventComponentToEventObject)(eventComponent); // Add an alarm if the user set a default one in the settings. If // not, defaultReminder will not be a number (rather the string "none"). const defaultReminder = parseInt(_settings_js__WEBPACK_IMPORTED_MODULE_10__["default"].state.defaultReminder); if (!isNaN(defaultReminder)) { commit('addAlarmToCalendarObjectInstance', { calendarObjectInstance, type: 'DISPLAY', totalSeconds: defaultReminder }); _utils_logger_js__WEBPACK_IMPORTED_MODULE_9__["default"].debug("Added defaultReminder (".concat(defaultReminder, "s) to newly created event")); } // Add default status const rfcProps = (0,_models_rfcProps_js__WEBPACK_IMPORTED_MODULE_11__.getRFCProperties)(); const status = rfcProps.status.defaultValue; commit('changeStatus', { calendarObjectInstance, status }); commit('setCalendarObjectInstanceForNewEvent', { calendarObject, calendarObjectInstance }); return { calendarObject, calendarObjectInstance }; }, /** * Updates the existing calendar-object-instance. * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {boolean} data.isAllDay Whether or not the new event is supposed to be all-day * @param {number} data.start The start of the new event (unixtime) * @param {number} data.end The end of the new event (unixtime) * @param {string} data.timezoneId The timezoneId of the new event * @return {Promise<{calendarObject: object, calendarObjectInstance: object}>} */ async updateCalendarObjectInstanceForNewEvent(_ref80, _ref81) { let { state, dispatch, commit } = _ref80; let { isAllDay, start, end, timezoneId } = _ref81; await dispatch('updateTimeOfNewEvent', { calendarObjectInstance: state.calendarObjectInstance, start, end, isAllDay, timezoneId }); commit('setCalendarObjectInstanceForNewEvent', { calendarObject: state.calendarObject, calendarObjectInstance: state.calendarObjectInstance }); return { calendarObject: state.calendarObject, calendarObjectInstance: state.calendarObjectInstance }; }, /** * Saves changes made to a single calendar-object-instance * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {boolean} data.thisAndAllFuture Whether or not to save changes for all future occurrences or just this one * @param {string} data.calendarId The new calendar-id to store it in * @return {Promise} */ async saveCalendarObjectInstance(_ref82, _ref83) { let { state, dispatch, commit } = _ref82; let { thisAndAllFuture, calendarId } = _ref83; const eventComponent = state.calendarObjectInstance.eventComponent; const calendarObject = state.calendarObject; (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.updateAlarms)(eventComponent); (0,_services_talkService_js__WEBPACK_IMPORTED_MODULE_13__.updateTalkParticipants)(eventComponent); let additionalFieldWasUpdated = eventComponent.client != null || eventComponent.isPrivate != null || eventComponent.returnToSiege != null || eventComponent.absenceType || eventComponent.emailId || eventComponent.comment != null; if (eventComponent.isDirty() || additionalFieldWasUpdated) { const isForkedItem = eventComponent.primaryItem !== null; let original = null; let fork = null; // We check if two things apply: // - primaryItem !== null -> Is this a fork or not? // - eventComponent.canCreateRecurrenceExceptions() - Can we create a recurrence-exception for this item if (isForkedItem && eventComponent.canCreateRecurrenceExceptions()) { [original, fork] = eventComponent.createRecurrenceException(thisAndAllFuture); } await dispatch('updateCalendarObject', { calendarObject }); if (original !== null && fork !== null && original.root !== fork.root) { await dispatch('createCalendarObjectFromFork', { eventComponent: fork, calendarId }); } } if (calendarId !== state.calendarObject.calendarId) { await dispatch('moveCalendarObject', { calendarObject, newCalendarId: calendarId }); } }, /** * Duplicate calendar-object-instance * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @return {Promise} */ async duplicateCalendarObjectInstance(_ref84) { let { state, dispatch, commit } = _ref84; const oldCalendarObjectInstance = state.calendarObjectInstance; const oldEventComponent = oldCalendarObjectInstance.eventComponent; const startDate = oldEventComponent.startDate.getInUTC(); const endDate = oldEventComponent.endDate.getInUTC(); const calendarObject = await dispatch('createNewEvent', { start: startDate.unixTime, end: endDate.unixTime, timezoneId: oldEventComponent.startDate.timezoneId, isAllDay: oldEventComponent.isAllDay() }); const eventComponent = (0,_utils_calendarObject_js__WEBPACK_IMPORTED_MODULE_8__.getObjectAtRecurrenceId)(calendarObject, startDate.jsDate); (0,_models_event_js__WEBPACK_IMPORTED_MODULE_4__.copyCalendarObjectInstanceIntoEventComponent)(oldCalendarObjectInstance, eventComponent); const calendarObjectInstance = (0,_models_event_js__WEBPACK_IMPORTED_MODULE_4__.mapEventComponentToEventObject)(eventComponent); await commit('setCalendarObjectInstanceForNewEvent', { calendarObject, calendarObjectInstance }); }, /** * Deletes a calendar-object-instance * * @param {object} vuex The vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.dispatch The Vuex dispatch function * @param {Function} vuex.commit The Vuex commit function * @param {object} data The destructuring object * @param {boolean} data.thisAndAllFuture Whether or not to delete all future occurrences or just this one * @return {Promise} */ async deleteCalendarObjectInstance(_ref85, _ref86) { let { state, dispatch, commit } = _ref85; let { thisAndAllFuture } = _ref86; const eventComponent = state.calendarObjectInstance.eventComponent; const isRecurrenceSetEmpty = eventComponent.removeThisOccurrence(thisAndAllFuture); const calendarObject = state.calendarObject; if (isRecurrenceSetEmpty) { await dispatch('deleteCalendarObject', { calendarObject }); } else { await dispatch('updateCalendarObject', { calendarObject }); } }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {Date} data2.startDate The new start-date */ changeStartDate(_ref87, _ref88) { let { commit } = _ref87; let { calendarObjectInstance, startDate } = _ref88; const difference = startDate.getTime() - calendarObjectInstance.startDate.getTime(); const endDate = new Date(calendarObjectInstance.endDate.getTime() + difference); commit('changeStartDate', { calendarObjectInstance, startDate }); commit('changeEndDate', { calendarObjectInstance, endDate }); }, /** * Change the timezone of the event's start * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {string} data2.startTimezone New timezone to set for start */ changeStartTimezone(_ref89, _ref90) { let { commit } = _ref89; let { calendarObjectInstance, startTimezone } = _ref90; commit('changeStartTimezone', { calendarObjectInstance, startTimezone }); // Simulate a change of the start time to trigger the comparison // of start and end and trigger an update of end if necessary commit('changeStartDate', { calendarObjectInstance, startDate: calendarObjectInstance.startDate }); }, /** * Change the timezone of the event's end * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {string} data2.endTimezone New timezone to set for end */ changeEndTimezone(_ref91, _ref92) { let { commit } = _ref91; let { calendarObjectInstance, endTimezone } = _ref92; commit('changeEndTimezone', { calendarObjectInstance, endTimezone }); // Simulate a change of the end time to trigger the comparison // of start and end and trigger an update of start if necessary commit('changeEndDate', { calendarObjectInstance, endDate: calendarObjectInstance.endDate }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {Function} data.dispatch The Vuex dispatch function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify * @param {string} data2.frequency The new frequency to set */ changeRecurrenceFrequency(_ref93, _ref94) { let { commit, dispatch } = _ref93; let { calendarObjectInstance, recurrenceRule, frequency } = _ref94; console.debug(calendarObjectInstance); console.debug(recurrenceRule); console.debug(frequency); if (recurrenceRule.frequency === 'NONE' && frequency !== 'NONE') { // Add a new recurrence-rule commit('addRecurrenceRuleFromCalendarObjectInstance', { calendarObjectInstance }); commit('resetRecurrenceByParts', { calendarObjectInstance, recurrenceRule }); commit('changeRecurrenceFrequency', { calendarObjectInstance, recurrenceRule: calendarObjectInstance.recurrenceRule, frequency }); commit('changeRecurrenceInterval', { calendarObjectInstance, recurrenceRule: calendarObjectInstance.recurrenceRule, interval: 1 }); commit('changeRecurrenceToInfinite', { calendarObjectInstance, recurrenceRule: calendarObjectInstance.recurrenceRule }); dispatch('setDefaultRecurrenceByParts', { calendarObjectInstance, recurrenceRule, frequency }); console.debug("changed from none to ".concat(frequency)); } else if (recurrenceRule.frequency !== 'NONE' && frequency === 'NONE') { console.debug('calling removeRecurrenceRuleFromCalendarObjectInstance'); // Remove the recurrence-rule commit('removeRecurrenceRuleFromCalendarObjectInstance', { calendarObjectInstance, recurrenceRule }); } else { // Change frequency of existing recurrence-rule commit('resetRecurrenceByParts', { calendarObjectInstance, recurrenceRule }); commit('changeRecurrenceFrequency', { calendarObjectInstance, recurrenceRule: calendarObjectInstance.recurrenceRule, frequency }); dispatch('setDefaultRecurrenceByParts', { calendarObjectInstance, recurrenceRule, frequency }); } }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify * @param {string} data2.frequency The new frequency to set */ setDefaultRecurrenceByParts(_ref95, _ref96) { let { commit } = _ref95; let { calendarObjectInstance, recurrenceRule, frequency } = _ref96; switch (frequency) { case 'WEEKLY': commit('setDefaultRecurrenceByPartsForWeekly', { calendarObjectInstance, recurrenceRule }); break; case 'MONTHLY': commit('setDefaultRecurrenceByPartsForMonthly', { calendarObjectInstance, recurrenceRule }); break; case 'YEARLY': commit('setDefaultRecurrenceByPartsForYearly', { calendarObjectInstance, recurrenceRule }); break; } }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ setRecurrenceToInfinite(_ref97, _ref98) { let { commit } = _ref97; let { calendarObjectInstance, recurrenceRule } = _ref98; commit('changeRecurrenceToInfinite', { calendarObjectInstance, recurrenceRule }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ changeMonthlyRecurrenceFromByDayToBySetPosition(_ref99, _ref100) { let { commit } = _ref99; let { calendarObjectInstance, recurrenceRule } = _ref100; console.debug('changeMonthlyRecurrenceFromByDayToBySetPosition'); commit('resetRecurrenceByParts', { calendarObjectInstance, recurrenceRule }); commit('setDefaultRecurrenceByPartsForMonthlyBySetPosition', { calendarObjectInstance, recurrenceRule }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ changeMonthlyRecurrenceFromBySetPositionToByDay(_ref101, _ref102) { let { commit } = _ref101; let { calendarObjectInstance, recurrenceRule } = _ref102; console.debug('changeMonthlyRecurrenceFromBySetPositionToByDay'); commit('resetRecurrenceByParts', { calendarObjectInstance, recurrenceRule }); commit('setDefaultRecurrenceByPartsForMonthly', { calendarObjectInstance, recurrenceRule }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ enableYearlyRecurrenceBySetPosition(_ref103, _ref104) { let { commit } = _ref103; let { calendarObjectInstance, recurrenceRule } = _ref104; commit('setDefaultRecurrenceByPartsForMonthlyBySetPosition', { calendarObjectInstance, recurrenceRule }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ disableYearlyRecurrenceBySetPosition(_ref105, _ref106) { let { commit } = _ref105; let { calendarObjectInstance, recurrenceRule } = _ref106; commit('changeRecurrenceByDay', { calendarObjectInstance, recurrenceRule, byDay: [] }); commit('unsetRecurrenceBySetPosition', { calendarObjectInstance, recurrenceRule }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ enableRecurrenceLimitByUntil(_ref107, _ref108) { let { commit } = _ref107; let { calendarObjectInstance, recurrenceRule } = _ref108; let until; switch (recurrenceRule.frequency) { // Defaults to 7 days case 'DAILY': until = new Date(calendarObjectInstance.startDate.getTime() + 7 * 24 * 60 * 60 * 1000); break; // Defaults to 4 weeks case 'WEEKLY': until = new Date(calendarObjectInstance.startDate.getTime() + 4 * 7 * 24 * 60 * 60 * 1000); break; // Defaults to 10 year case 'YEARLY': until = new Date(calendarObjectInstance.startDate.getFullYear() + 10, calendarObjectInstance.startDate.getMonth(), calendarObjectInstance.startDate.getDate(), 23, 59, 59); break; // Defaults to 12 months case 'MONTHLY': default: until = new Date(calendarObjectInstance.startDate.getFullYear() + 1, calendarObjectInstance.startDate.getMonth(), calendarObjectInstance.startDate.getDate(), 23, 59, 59); break; } commit('changeRecurrenceToInfinite', { calendarObjectInstance, recurrenceRule }); commit('changeRecurrenceUntil', { calendarObjectInstance, recurrenceRule, until }); }, /** * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {object} data2 The destructuring object for data * @param {object} data2.calendarObjectInstance The calendarObjectInstance object * @param {object} data2.recurrenceRule The recurrenceRule object to modify */ enableRecurrenceLimitByCount(_ref109, _ref110) { let { commit } = _ref109; let { calendarObjectInstance, recurrenceRule } = _ref110; commit('changeRecurrenceToInfinite', { calendarObjectInstance, recurrenceRule }); commit('changeRecurrenceCount', { calendarObjectInstance, recurrenceRule, count: 2 // Default value is two }); }, changeAlarmAmountTimed(_ref111, _ref112) { let { commit } = _ref111; let { calendarObjectInstance, alarm, amount } = _ref112; commit('changeAlarmAmountTimed', { calendarObjectInstance, alarm, amount }); commit('updateAlarmAllDayParts', { calendarObjectInstance, alarm }); }, changeAlarmUnitTimed(_ref113, _ref114) { let { commit } = _ref113; let { calendarObjectInstance, alarm, unit } = _ref114; commit('changeAlarmUnitTimed', { calendarObjectInstance, alarm, unit }); commit('updateAlarmAllDayParts', { calendarObjectInstance, alarm }); }, changeAlarmAmountAllDay(_ref115, _ref116) { let { commit } = _ref115; let { calendarObjectInstance, alarm, amount } = _ref116; commit('changeAlarmAmountAllDay', { calendarObjectInstance, alarm, amount }); commit('updateAlarmTimedParts', { calendarObjectInstance, alarm }); }, changeAlarmUnitAllDay(_ref117, _ref118) { let { commit } = _ref117; let { calendarObjectInstance, alarm, unit } = _ref118; commit('changeAlarmUnitAllDay', { calendarObjectInstance, alarm, unit }); commit('updateAlarmTimedParts', { calendarObjectInstance, alarm }); }, changeAlarmHoursMinutesAllDay(_ref119, _ref120) { let { commit } = _ref119; let { calendarObjectInstance, alarm, hours, minutes } = _ref120; commit('changeAlarmHoursMinutesAllDay', { calendarObjectInstance, alarm, hours, minutes }); commit('updateAlarmTimedParts', { calendarObjectInstance, alarm }); }, changeAlarmFromRelativeToAbsolute(_ref121, _ref122) { let { commit } = _ref121; let { calendarObjectInstance, alarm } = _ref122; commit('changeAlarmFromRelativeToAbsolute', { calendarObjectInstance, alarm }); commit('resetAlarmRelativeParts', { alarm }); }, changeAlarmFromAbsoluteToRelative(_ref123, _ref124) { let { commit } = _ref123; let { calendarObjectInstance, alarm } = _ref124; commit('changeAlarmFromAbsoluteToRelative', { calendarObjectInstance, alarm }); commit('updateAlarmAllDayParts', { calendarObjectInstance, alarm }); commit('updateAlarmTimedParts', { calendarObjectInstance, alarm }); commit('resetAlarmAbsoluteParts', { alarm }); }, toggleAllDay(_ref125, _ref126) { let { commit, getters } = _ref125; let { calendarObjectInstance } = _ref126; commit('toggleAllDay', { calendarObjectInstance }); if (!calendarObjectInstance.isAllDay) { if (calendarObjectInstance.startTimezoneId === 'floating') { const startTimezone = getters.getResolvedTimezone; commit('changeStartTimezone', { calendarObjectInstance, startTimezone }); } commit('changeTimeToDefaultForTimedEvents', { calendarObjectInstance }); } } // async changeAbsenceType({ commit }, { calendarObjectInstance, absenceType }) { // try { // commit('setAbsenceType', { calendarObjectInstance, absenceType }); // } catch (error) { // console.error('Erreur lors de la mise à jour du type d\'absence:', error); // } // }, }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/calendarObjects.js": /*!**************************************!*\ !*** ./src/store/calendarObjects.js ***! \**************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /* harmony import */ var _models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../models/calendarObject.js */ "./src/models/calendarObject.js"); /* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/logger.js */ "./src/utils/logger.js"); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @author John Molakvoæ * * @author Thomas Citharel * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { calendarObjects: {}, modificationCount: 0 }; const mutations = { /** * Adds an array of calendar-objects to the store * * @param {object} state The store data * @param {object} data The destructuring object * @param {object[]} data.calendarObjects Calendar-objects to add */ appendCalendarObjects(state, _ref) { let { calendarObjects = [] } = _ref; for (const calendarObject of calendarObjects) { if (!state.calendarObjects[calendarObject.id]) { vue__WEBPACK_IMPORTED_MODULE_3__["default"].set(state.calendarObjects, calendarObject.id, calendarObject); } } }, /** * Adds one calendar-object to the store * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.calendarObject Calendar-object to add */ appendCalendarObject(state, _ref2) { let { calendarObject } = _ref2; if (!state.calendarObjects[calendarObject.id]) { vue__WEBPACK_IMPORTED_MODULE_3__["default"].set(state.calendarObjects, calendarObject.id, calendarObject); } }, /** * Updates a calendar-object id * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.calendarObject Calendar-object to update */ updateCalendarObjectId(state, _ref3) { let { calendarObject } = _ref3; if (calendarObject.dav === null) { calendarObject.id = null; } else { calendarObject.id = btoa(calendarObject.dav.url); } }, /** * Updates a calendar-object's calendarId * * @param {object} state The store data * @param {object} data The destructuring object * @param {string} data.calendarObjectId Id of calendar-object to update * @param {string} data.calendarId New calendarId */ updateCalendarObjectIdCalendarId(state, _ref4) { let { calendarObjectId, calendarId } = _ref4; state.calendarObjects[calendarObjectId].calendarId = calendarId; }, /** * Resets a calendar-object to it's original server state * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.calendarObject Calendar-object to reset */ resetCalendarObjectToDav(state, _ref5) { let { calendarObject } = _ref5; calendarObject = state.calendarObjects[calendarObject.id]; // If this object does not exist on the server yet, there is nothing to do if (!calendarObject || !calendarObject.existsOnServer) { return; } const parserManager = (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.getParserManager)(); const parser = parserManager.getParserForFileType('text/calendar'); parser.parse(calendarObject.dav.data); const itemIterator = parser.getItemIterator(); const firstVCalendar = itemIterator.next().value; if (firstVCalendar) { calendarObject.calendarComponent = firstVCalendar; } }, /** * Removes a calendar-object from the store * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.calendarObject Calendar-object to delete */ deleteCalendarObject(state, _ref6) { let { calendarObject } = _ref6; vue__WEBPACK_IMPORTED_MODULE_3__["default"].delete(state.calendarObjects, calendarObject.id); }, /** * Increments the modification count * * @param {object} state The store data */ incrementModificationCount(state) { state.modificationCount++; } }; const getters = { /** * Gets a calendar-object based on its id * * @param {object} state The store data * @return {function({String}): CalendarObject} */ getCalendarObjectById: state => id => state.calendarObjects[id] }; const actions = { /** * Moves a calendar-object to a different calendar * * @param {object} context the store mutations * @param {object} data destructuring object * @param {CalendarObject} data.calendarObject Calendar-object to delete * @param {string} data.newCalendarId Calendar-Id of calendar to move this calendar-object to * @return {Promise} */ async moveCalendarObject(context, _ref7) { let { calendarObject, newCalendarId } = _ref7; if (!calendarObject.existsOnServer) { return; } const oldCalendarObjectId = calendarObject.id; const oldCalendarId = calendarObject.calendarId; if (oldCalendarId === newCalendarId) { _utils_logger_js__WEBPACK_IMPORTED_MODULE_1__["default"].error('Old calendar Id and new calendar Id are the same, nothing to move …'); return; } const newCalendar = context.getters.getCalendarById(newCalendarId); if (!newCalendar) { _utils_logger_js__WEBPACK_IMPORTED_MODULE_1__["default"].error('Calendar to move to not found, aborting …'); return; } await calendarObject.dav.move(newCalendar.dav); // Update calendarId in calendarObject manually as it is not stored in dav context.commit('updateCalendarObjectIdCalendarId', { calendarObjectId: calendarObject.id, calendarId: newCalendarId }); context.commit('addCalendarObjectToCalendar', { calendar: { id: newCalendarId }, calendarObjectId: calendarObject.id }); context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { calendarId: newCalendarId, calendarObjectId: calendarObject.id }); context.commit('deleteCalendarObjectFromCalendar', { calendar: { id: oldCalendarId }, calendarObjectId: oldCalendarObjectId }); context.commit('removeCalendarObjectIdFromAllTimeRangesOfCalendar', { calendarId: oldCalendarId, calendarObjectId: oldCalendarObjectId }); context.commit('incrementModificationCount'); }, /** * Updates a calendar-object * * @param {object} context the store mutations * @param {object} data destructuring object * @param {CalendarObject} data.calendarObject Calendar-object to delete * @return {Promise} */ async updateCalendarObject(context, _ref8) { let { calendarObject } = _ref8; let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT'); if (calendarObject.existsOnServer) { let icsValue = calendarObject.calendarComponent.toICS(); if (eventComponent != null) { if (eventComponent.client != null) { let newClientKeyValue = "CLIENT:" + eventComponent.client; let regexEmptyClient = /CLIENT:(?!\d)(?=\s*[\r\n])/g; if (regexEmptyClient.test(icsValue)) { icsValue = icsValue.replace(regexEmptyClient, newClientKeyValue); } let regex = /CLIENT:\d+/; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, newClientKeyValue); } else { const customKeyValue = { "CLIENT": eventComponent.client }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } if (eventComponent.comment != null) { let newCommentKeyValue = "COMMENT:" + eventComponent.comment; let regex = /^COMMENT:.*$/m; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, newCommentKeyValue); } else { const customKeyValue = { "COMMENT": eventComponent.comment }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } if (eventComponent.isPrivate != null) { let isPrivateValue = eventComponent.isPrivate ? "1" : "0"; let newIsPrivateKeyValue = "ISPRIVATE:" + isPrivateValue; let regex = /ISPRIVATE:\d+/; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, newIsPrivateKeyValue); } else { const customKeyValue = { "ISPRIVATE": isPrivateValue }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } if (eventComponent.emailId != null) { let emailIdValue = eventComponent.emailId; let emailIdValueValue = "EMAILID:" + emailIdValue; let regex = /EMAILID:\d+/; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, emailIdValueValue); } else { const customKeyValue = { "EMAILID": emailIdValue }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } if (eventComponent.absenceType != null && eventComponent.absenceType != '') { let absenceTypeValue = eventComponent.absenceType; let key = "ABSENCETYPE:" + absenceTypeValue; let regex = /^ABSENCETYPE:.*$/m; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, key); } else { const customKeyValue = { "ABSENCETYPE": absenceTypeValue }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } if (eventComponent.returnToSiege != null && eventComponent.returnToSiege != '') { let returnToSiegeValue = eventComponent.returnToSiege; let key = "RETURNTOSIEGE:" + returnToSiegeValue; let regex = /RETURNTOSIEGE:\d+/; if (regex.test(icsValue)) { icsValue = icsValue.replace(regex, key); } else { const customKeyValue = { "RETURNTOSIEGE": returnToSiegeValue }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } } } calendarObject.dav.data = icsValue; await calendarObject.dav.update(); context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { calendarId: calendarObject.calendarId, calendarObjectId: calendarObject.id }); context.commit('resetCalendarObjectToDav', { calendarObject }); context.commit('incrementModificationCount'); return; // TODO - catch conflicts } const calendar = context.getters.getCalendarById(calendarObject.calendarId); let icsValue = calendarObject.calendarComponent.toICS(); if (eventComponent != null) { var _eventComponent$absen; const customKeyValue = { "CLIENT": eventComponent.client, "EMBALMER": eventComponent.embalmer, "ISPRIVATE": eventComponent.isPrivate ? "1" : "0", "RETURNTOSIEGE": eventComponent.returnToSiege ? "1" : "0", "COMMENT": eventComponent.comment, "EMAILID": eventComponent.emailId, "ABSENCETYPE": (_eventComponent$absen = eventComponent.absenceType) !== null && _eventComponent$absen !== void 0 ? _eventComponent$absen : '' }; icsValue = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.setCustomKeyValuesArrayToIcsAndReturnIcs)(icsValue, customKeyValue); } calendarObject.dav = await calendar.dav.createVObject(icsValue); calendarObject.existsOnServer = true; context.commit('updateCalendarObjectId', { calendarObject }); context.commit('appendCalendarObject', { calendarObject }); context.commit('addCalendarObjectToCalendar', { calendar: { id: calendarObject.calendarId }, calendarObjectId: calendarObject.id }); context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { calendarId: calendarObject.calendarId, calendarObjectId: calendarObject.id }); context.commit('resetCalendarObjectToDav', { calendarObject }); context.commit('incrementModificationCount'); }, /** * Creates a new calendar-object from an recurrence-exception fork * * @param {object} context The Vuex context * @param {object} data destructuring object * @param {EventComponent} data.eventComponent EventComponent to store * @param {string} data.calendarId The calendar-id to store it in * @return {Promise} */ async createCalendarObjectFromFork(context, _ref9) { let { eventComponent, calendarId } = _ref9; const calendar = context.getters.getCalendarById(calendarId); const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.mapCalendarJsToCalendarObject)(eventComponent.root, calendar.id); calendarObject.dav = await calendar.dav.createVObject(calendarObject.calendarComponent.toICS()); calendarObject.existsOnServer = true; context.commit('updateCalendarObjectId', { calendarObject }); context.commit('appendCalendarObject', { calendarObject }); context.commit('addCalendarObjectToCalendar', { calendar: { id: calendarObject.calendarId }, calendarObjectId: calendarObject.id }); context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { calendarId: calendar.id, calendarObjectId: calendarObject.id }); context.commit('incrementModificationCount'); }, /** * Deletes a calendar-object * * @param {object} context the store mutations * @param {object} data destructuring object * @param {CalendarObject} data.calendarObject Calendar-object to delete * @return {Promise} */ async deleteCalendarObject(context, _ref10) { let { calendarObject } = _ref10; // If this calendar-object was not created on the server yet, // no need to send requests to the server if (calendarObject.existsOnServer) { await calendarObject.dav.delete(); } context.commit('deleteCalendarObject', { calendarObject }); context.commit('deleteCalendarObjectFromCalendar', { calendar: { id: calendarObject.calendarId }, calendarObjectId: calendarObject.id }); context.commit('removeCalendarObjectIdFromAnyTimeRange', { calendarObjectId: calendarObject.id }); context.commit('incrementModificationCount'); }, /** * Creates a new calendar object based on start, end, timezone and isAllDay * * @param {object} context the store mutations * @param {object} data destructuring object * @param {number} data.start Timestamp for start of new event * @param {number} data.end Timestamp for end of new event * @param {string} data.timezoneId asd * @param {boolean} data.isAllDay foo * @return {Promise} */ createNewEvent(context, _ref11) { let { start, end, timezoneId, isAllDay } = _ref11; const timezoneManager = (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.getTimezoneManager)(); const timezone = timezoneManager.getTimezoneForId(timezoneId); const startDate = new Date(start * 1000); const endDate = new Date(end * 1000); const startDateTime = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DateTimeValue.fromJSDate(startDate, true).getInTimezone(timezone); const endDateTime = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.DateTimeValue.fromJSDate(endDate, true).getInTimezone(timezone); if (isAllDay) { startDateTime.isDate = true; endDateTime.isDate = true; } const calendar = (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_2__.createEvent)(startDateTime, endDateTime); for (const vObject of calendar.getVObjectIterator()) { vObject.undirtify(); } const firstCalendar = context.getters.sortedCalendars[0].id; return Promise.resolve((0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_0__.mapCalendarJsToCalendarObject)(calendar, firstCalendar)); }, /** * Updates the time of the new calendar object * * @param {object} data The destructuring object for Vuex * @param {Function} data.commit The Vuex commit function * @param {Function} data.dispatch The Vuex dispatch function * @param {object} data2 destructuring object * @param {CalendarObject} data2.calendarObjectInstance Calendar-object to * @param {number} data2.start Timestamp for start of new event * @param {number} data2.end Timestamp for end of new event * @param {string} data2.timezoneId asd * @param {boolean} data2.isAllDay foo */ updateTimeOfNewEvent(_ref12, _ref13) { let { commit, dispatch } = _ref12; let { calendarObjectInstance, start, end, timezoneId, isAllDay } = _ref13; const isDirty = calendarObjectInstance.eventComponent.isDirty(); const startDate = new Date(start * 1000); const endDate = new Date(end * 1000); if (calendarObjectInstance.isAllDay !== isAllDay) { commit('toggleAllDay', { calendarObjectInstance }); } dispatch('changeStartTimezone', { calendarObjectInstance, startTimezone: timezoneId }); dispatch('changeEndTimezone', { calendarObjectInstance, endTimezone: timezoneId }); commit('changeStartDate', { calendarObjectInstance, startDate }); if (isAllDay) { // The full-calendar end date is exclusive, but the end-date // that changeEndDate expects is inclusive, so we have to deduct one day. commit('changeEndDate', { calendarObjectInstance, endDate: new Date(endDate.getTime() - 24 * 60 * 60 * 1000) }); } else { commit('changeEndDate', { calendarObjectInstance, endDate }); } if (!isDirty) { calendarObjectInstance.eventComponent.undirtify(); } } }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/calendars.js": /*!********************************!*\ !*** ./src/store/calendars.js ***! \********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /* harmony import */ var _services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/caldavService.js */ "./src/services/caldavService.js"); /* harmony import */ var _models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../models/calendarObject.js */ "./src/models/calendarObject.js"); /* harmony import */ var _utils_date_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/date.js */ "./src/utils/date.js"); /* harmony import */ var _models_calendar_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../models/calendar.js */ "./src/models/calendar.js"); /* harmony import */ var p_limit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! p-limit */ "./node_modules/p-limit/index.js"); /* harmony import */ var _utils_color_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/color.js */ "./src/utils/color.js"); /* harmony import */ var _nextcloud_l10n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nextcloud/l10n */ "./node_modules/@nextcloud/l10n/dist/index.mjs"); /* harmony import */ var _services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../services/timezoneDataProviderService.js */ "./src/services/timezoneDataProviderService.js"); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _models_consts_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../models/consts.js */ "./src/models/consts.js"); /* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.mjs"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @copyright Copyright (c) 2019 John Molakvoæ * * @copyright Copyright (c) 2019 Thomas Citharel * * @author Georg Ehrke * * @author John Molakvoæ * * @author Thomas Citharel * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { calendars: [], trashBin: undefined, scheduleInbox: undefined, deletedCalendars: [], deletedCalendarObjects: [], calendarsById: {}, initialCalendarsLoaded: false, editCalendarModal: undefined, widgetView: 'dayGridMonth', widgetDate: 'now', widgetEventDetailsOpen: false, widgetEventDetails: {}, widgetRef: undefined }; const mutations = { /** * Adds calendar into state * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to add */ addCalendar(state, _ref) { let { calendar } = _ref; const object = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.getDefaultCalendarObject)(calendar); if (!state.calendars.some(existing => existing.id === object.id)) { state.calendars.push(object); } vue__WEBPACK_IMPORTED_MODULE_11__["default"].set(state.calendarsById, object.id, object); }, addTrashBin(state, _ref2) { let { trashBin } = _ref2; state.trashBin = trashBin; }, setWidgetView(state, _ref3) { let { viewName } = _ref3; state.widgetView = viewName; }, setWidgetDate(state, _ref4) { let { widgetDate } = _ref4; state.widgetDate = widgetDate; }, setWidgetRef(state, _ref5) { let { widgetRef } = _ref5; state.widgetRef = widgetRef; }, setSelectedEvent(state, _ref6) { let { object, recurrenceId } = _ref6; state.widgetEventDetailsOpen = true; state.widgetEventDetails = { object, recurrenceId }; }, closeWidgetEventDetails(state) { state.widgetEventDetailsOpen = false; }, addScheduleInbox(state, _ref7) { let { scheduleInbox } = _ref7; state.scheduleInbox = scheduleInbox; }, /** * Adds deleted calendar into state * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar calendar the calendar to add */ addDeletedCalendar(state, _ref8) { let { calendar } = _ref8; if (state.deletedCalendars.some(c => c.url === calendar.url)) { // This calendar is already known return; } state.deletedCalendars.push(calendar); }, /** * Removes a deleted calendar * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the deleted calendar to remove */ removeDeletedCalendar(state, _ref9) { let { calendar } = _ref9; state.deletedCalendars = state.deletedCalendars.filter(c => c !== calendar); }, /** * Removes a deleted calendar object * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.vobject the deleted calendar object to remove */ removeDeletedCalendarObject(state, _ref10) { let { vobject } = _ref10; state.deletedCalendarObjects = state.deletedCalendarObjects.filter(vo => vo.id !== vobject.id); }, /** * Adds a deleted vobject into state * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.vobject the calendar vobject to add */ addDeletedCalendarObject(state, _ref11) { let { vobject } = _ref11; if (state.deletedCalendarObjects.some(c => c.uri === vobject.uri)) { // This vobject is already known return; } state.deletedCalendarObjects.push(vobject); }, /** * Deletes a calendar * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to delete */ deleteCalendar(state, _ref12) { let { calendar } = _ref12; state.calendars.splice(state.calendars.indexOf(calendar), 1); vue__WEBPACK_IMPORTED_MODULE_11__["default"].delete(state.calendarsById, calendar.id); }, /** * Toggles a calendar's visibility * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar the calendar to toggle */ toggleCalendarEnabled(state, _ref13) { let { calendar } = _ref13; state.calendarsById[calendar.id].enabled = !state.calendarsById[calendar.id].enabled; }, /** * Renames a calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar the calendar to rename * @param {string} data.newName the new name of the calendar */ renameCalendar(state, _ref14) { let { calendar, newName } = _ref14; state.calendarsById[calendar.id].displayName = newName; }, /** * Changes calendar's color * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar the calendar to rename * @param {string} data.newColor the new color of the calendar */ changeCalendarColor(state, _ref15) { let { calendar, newColor } = _ref15; state.calendarsById[calendar.id].color = newColor; }, /** * Changes calendar's order * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar the calendar to rename * @param {string} data.newOrder the new order of the calendar */ changeCalendarOrder(state, _ref16) { let { calendar, newOrder } = _ref16; state.calendarsById[calendar.id].order = newOrder; }, /** * Adds multiple calendar-objects to calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar The calendar to append objects to * @param {string[]} data.calendarObjectIds The calendar object ids to append */ appendCalendarObjectsToCalendar(state, _ref17) { let { calendar, calendarObjectIds } = _ref17; for (const calendarObjectId of calendarObjectIds) { if (state.calendarsById[calendar.id].calendarObjects.indexOf(calendarObjectId) === -1) { state.calendarsById[calendar.id].calendarObjects.push(calendarObjectId); } } }, /** * Adds calendar-object to calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar The calendar to append objects to * @param {string} data.calendarObjectId The calendar object id to append */ addCalendarObjectToCalendar(state, _ref18) { let { calendar, calendarObjectId } = _ref18; if (state.calendarsById[calendar.id].calendarObjects.indexOf(calendarObjectId) === -1) { state.calendarsById[calendar.id].calendarObjects.push(calendarObjectId); } }, /** * Removes calendar-object from calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar The calendar to delete objects from * @param {string} data.calendarObjectId The calendar object ids to delete */ deleteCalendarObjectFromCalendar(state, _ref19) { let { calendar, calendarObjectId } = _ref19; const index = state.calendarsById[calendar.id].calendarObjects.indexOf(calendarObjectId); if (index !== -1) { state.calendarsById[calendar.id].calendarObjects.slice(index, 1); } }, /** * Adds fetched time-range to calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar The calendar to append a time-range to * @param {number} data.fetchedTimeRangeId The time-range-id to append */ addFetchedTimeRangeToCalendar(state, _ref20) { let { calendar, fetchedTimeRangeId } = _ref20; state.calendarsById[calendar.id].fetchedTimeRanges.push(fetchedTimeRangeId); }, /** * Removes fetched time-range from calendar * * @param {object} state the store mutations * @param {object} data destructuring object * @param {object} data.calendar The calendar to remove a time-range from * @param {number} data.fetchedTimeRangeId The time-range-id to remove */ deleteFetchedTimeRangeFromCalendar(state, _ref21) { let { calendar, fetchedTimeRangeId } = _ref21; const index = state.calendarsById[calendar.id].fetchedTimeRanges.indexOf(fetchedTimeRangeId); if (index !== -1) { state.calendarsById[calendar.id].fetchedTimeRanges.slice(index, 1); } }, /** * Shares calendar with a user or group * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar * @param {string} data.user the userId * @param {string} data.displayName the displayName * @param {string} data.uri the sharing principalScheme uri * @param {boolean} data.isGroup is this a group? * @param {boolean} data.isCircle is this a circle? */ shareCalendar(state, _ref22) { let { calendar, user, displayName, uri, isGroup, isCircle } = _ref22; const newSharee = { displayName, id: user, writeable: false, isGroup, isCircle, uri }; state.calendarsById[calendar.id].shares.push(newSharee); }, /** * Removes Sharee from calendar shares list * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar * @param {string} data.uri the sharee uri */ unshareCalendar(state, _ref23) { let { calendar, uri } = _ref23; calendar = state.calendars.find(search => search.id === calendar.id); const shareIndex = calendar.shares.findIndex(sharee => sharee.uri === uri); calendar.shares.splice(shareIndex, 1); }, /** * Toggles sharee's writable permission * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar * @param {string} data.uri the sharee uri */ toggleCalendarShareWritable(state, _ref24) { let { calendar, uri } = _ref24; calendar = state.calendars.find(search => search.id === calendar.id); const sharee = calendar.shares.find(sharee => sharee.uri === uri); sharee.writeable = !sharee.writeable; }, /** * Publishes a calendar calendar * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to publish * @param {string} data.publishURL published URL of calendar */ publishCalendar(state, _ref25) { let { calendar, publishURL } = _ref25; calendar = state.calendars.find(search => search.id === calendar.id); calendar.publishURL = publishURL; }, /** * Unpublishes a calendar * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to unpublish */ unpublishCalendar(state, _ref26) { let { calendar } = _ref26; calendar = state.calendars.find(search => search.id === calendar.id); calendar.publishURL = null; }, /** * Marks initial loading of calendars as complete * * @param {object} state the store data */ initialCalendarsLoaded(state) { state.initialCalendarsLoaded = true; }, /** * Marks a calendar as loading * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to mark as loading */ markCalendarAsLoading(state, _ref27) { let { calendar } = _ref27; state.calendarsById[calendar.id].loading = true; }, /** * Marks a calendar as finished loading * * @param {object} state the store data * @param {object} data destructuring object * @param {object} data.calendar the calendar to mark as finished loading */ markCalendarAsNotLoading(state, _ref28) { let { calendar } = _ref28; state.calendarsById[calendar.id].loading = false; }, showEditCalendarModal(state, _ref29) { let { calendarId } = _ref29; state.editCalendarModal = { calendarId }; }, hideEditCalendarModal(state) { state.editCalendarModal = undefined; }, setCalendarDeleteCountdown(state, _ref30) { let { calendar, countdown } = _ref30; vue__WEBPACK_IMPORTED_MODULE_11__["default"].set(state.calendarsById[calendar.id], 'countdown', countdown); }, setCalendarDeleteHandles(state, _ref31) { let { calendar, deleteTimeout, deleteInterval } = _ref31; vue__WEBPACK_IMPORTED_MODULE_11__["default"].set(state.calendarsById[calendar.id], 'deleteTimeout', deleteTimeout); vue__WEBPACK_IMPORTED_MODULE_11__["default"].set(state.calendarsById[calendar.id], 'deleteInterval', deleteInterval); } }; const getters = { /** * List of sorted calendars and subscriptions * * @param {object} state the store data * @param {object} store the store * @param {object} rootState the rootState * @return {Array} */ sortedCalendarsSubscriptions(state, store, rootState) { return state.calendars.filter(calendar => calendar.supportsEvents || rootState.settings.showTasks && calendar.supportsTasks).sort((a, b) => a.order - b.order); }, /** * List of sorted calendars * * @param {object} state the store data * @return {Array} */ sortedCalendars(state) { return state.calendars.filter(calendar => calendar.supportsEvents).filter(calendar => !calendar.readOnly).sort((a, b) => a.order - b.order); }, /** * List of sorted calendars owned by the principal * * @param {object} state the store data * @return {Array} */ ownSortedCalendars(state) { return state.calendars.filter(calendar => calendar.supportsEvents).filter(calendar => !calendar.readOnly).filter(calendar => !calendar.isSharedWithMe).sort((a, b) => a.order - b.order); }, widgetView(state) { return state.widgetView; }, widgetDate(state) { return state.widgetDate; }, widgetEventDetailsOpen(state) { return state.widgetEventDetailsOpen; }, widgetRef(state) { return state.widgetRef; }, hasTrashBin(state) { return state.trashBin !== undefined && state.trashBin.retentionDuration !== 0; }, trashBin(state) { return state.trashBin; }, scheduleInbox: state => { return state.scheduleInbox; }, /** * List of deleted sorted calendars * * @param {object} state the store data * @return {Array} */ sortedDeletedCalendars(state) { return state.deletedCalendars.sort((a, b) => a.deletedAt - b.deletedAt); }, /** * List of deleted calendars objects * * @param {object} state the store data * @return {Array} */ deletedCalendarObjects(state) { const calendarUriMap = {}; state.calendars.forEach(calendar => { const withoutTrail = calendar.url.replace(/\/$/, ''); const uri = withoutTrail.slice(withoutTrail.lastIndexOf('/') + 1); calendarUriMap[uri] = calendar; }); return state.deletedCalendarObjects.map(obj => ({ calendar: calendarUriMap[obj.dav._props['{http://nextcloud.com/ns}calendar-uri']], ...obj })); }, /** * List of sorted subscriptions * * @param {object} state the store data * @return {Array} */ sortedSubscriptions(state) { return state.calendars.filter(calendar => calendar.supportsEvents).filter(calendar => calendar.readOnly).sort((a, b) => a.order - b.order); }, /** * List of enabled calendars and subscriptions * * @param {object} state the store data * @param {object} store the store * @param {object} rootState the rootState * @return {Array} */ enabledCalendars(state, store, rootState) { return state.calendars.filter(calendar => calendar.supportsEvents || rootState.settings.showTasks && calendar.supportsTasks).filter(calendar => calendar.enabled); }, /** * Gets a calendar by it's Id * * @param {object} state the store data * @return {function({String}): {Object}} */ getCalendarById: state => calendarId => state.calendarsById[calendarId], /** * Gets a calendar by its url * * @param {object} state the store data * @return {function({String}): {Object}} */ getCalendarByUrl: state => url => state.calendars.find(calendar => calendar.url === url), /** * Gets the contact's birthday calendar or null * * @param {object} state the store data * @return {object | null} */ getBirthdayCalendar: state => { for (const calendar of state.calendars) { const url = calendar.url.slice(0, -1); const lastSlash = url.lastIndexOf('/'); const uri = url.slice(lastSlash + 1); if (uri === _models_consts_js__WEBPACK_IMPORTED_MODULE_9__.CALDAV_BIRTHDAY_CALENDAR) { return calendar; } } return null; }, /** * Whether or not a birthday calendar exists * * @param {object} state The Vuex state * @param {object} getters the vuex getters * @return {boolean} */ hasBirthdayCalendar: (state, getters) => { return !!getters.getBirthdayCalendar; }, /** * * @param {object} state the store data * @param {object} getters the store getters * @return {function({Boolean}, {Boolean}, {Boolean}): {Object}[]} */ sortedCalendarFilteredByComponents: (state, getters) => (vevent, vjournal, vtodo) => { return getters.sortedCalendars.filter(calendar => { if (vevent && !calendar.supportsEvents) { return false; } if (vjournal && !calendar.supportsJournals) { return false; } if (vtodo && !calendar.supportsTasks) { return false; } return true; }); }, editCalendarModal: state => state.editCalendarModal }; const actions = { /** * Retrieve and commit calendars and other collections * * @param {object} context the store object * @param {object} context.commit the store mutations * @param {object} context.state the store state * @param {object} context.getters the store getters * @return {Promise} the results */ async loadCollections(_ref32) { let { commit, state, getters } = _ref32; const { calendars, trashBins, scheduleInboxes, subscriptions } = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.findAll)(); console.info('calendar home scanned', calendars, trashBins, subscriptions); calendars.map(calendar => (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.mapDavCollectionToCalendar)(calendar, getters.getCurrentUserPrincipal)).forEach(calendar => { commit('addCalendar', { calendar }); }); if (trashBins.length) { commit('addTrashBin', { trashBin: trashBins[0] }); } if (scheduleInboxes.length) { commit('addScheduleInbox', { scheduleInbox: scheduleInboxes[0] }); } commit('initialCalendarsLoaded'); return { calendars: state.calendars, trashBin: state.trashBin }; }, /** * Retrieve and commit deleted calendars * * @param {object} context the store object * @param {object} context.commit the store mutations * @return {Promise} the calendars */ async loadDeletedCalendars(_ref33) { let { commit } = _ref33; const calendars = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.findAllDeletedCalendars)(); calendars.forEach(calendar => commit('addDeletedCalendar', { calendar })); }, /** * Retrieve and commit deleted calendar objects * * @param {object} context the store object * @param {object} context.commit the store mutations * @param {object} context.state the store state */ async loadDeletedCalendarObjects(_ref34) { let { commit, state } = _ref34; const vobjects = await state.trashBin.findDeletedObjects(); console.info('vobjects loaded', { vobjects }); vobjects.forEach(vobject => { try { const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__.mapCDavObjectToCalendarObject)(vobject, undefined); commit('addDeletedCalendarObject', { vobject: calendarObject }); } catch (error) { console.error('could not convert calendar object', vobject, error); } }); }, /** * * @param {object} context the store object * @param {object} context.commit the store mutations * @param {object} data The data destructuring object * @param {string[]} data.tokens The tokens to load * @return {Promise} */ async getPublicCalendars(_ref35, _ref36) { let { commit } = _ref35; let { tokens } = _ref36; const calendars = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.findPublicCalendarsByTokens)(tokens); const calendarObjects = []; for (const davCalendar of calendars) { const calendar = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.mapDavCollectionToCalendar)(davCalendar); commit('addCalendar', { calendar }); calendarObjects.push(calendar); } commit('initialCalendarsLoaded'); return calendarObjects; }, /** * Append a new calendar to array of existing calendars * * @param {object} context the store mutations * @param {object} data destructuring object * @param {object} data.displayName The name of the new calendar * @param {object} data.color The color of the new calendar * @param {object} data.order The order of the new calendar * @param {string[]} data.components The supported components of the calendar * @param {string=} data.timezone The timezoneId * @return {Promise} */ async appendCalendar(context, _ref37) { let { displayName, color, order, components = ['VEVENT'], timezone = null } = _ref37; if (timezone === null) { timezone = context.getters.getResolvedTimezone; } let timezoneIcs = null; const timezoneObject = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_7__["default"])().getTimezoneForId(timezone); if (timezoneObject !== _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_8__.Timezone.utc && timezoneObject !== _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_8__.Timezone.floating) { const calendar = _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_8__.CalendarComponent.fromEmpty(); calendar.addComponent(_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_8__.TimezoneComponent.fromICALJs(timezoneObject.toICALJs())); timezoneIcs = calendar.toICS(false); } const response = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.createCalendar)(displayName, color, components, order, timezoneIcs); const calendar = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.mapDavCollectionToCalendar)(response, context.getters.getCurrentUserPrincipal); context.commit('addCalendar', { calendar }); }, /** * Append a new subscription to array of existing calendars * * @param {object} context the store mutations * @param {object} data destructuring object * @param {string} data.displayName Name of new subscription * @param {string} data.color Color of new subscription * @param {string} data.order Order of new subscription * @param {string} data.source Source of new subscription * @return {Promise} */ async appendSubscription(context, _ref38) { let { displayName, color, order, source } = _ref38; const response = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.createSubscription)(displayName, color, source, order); const calendar = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.mapDavCollectionToCalendar)(response, context.getters.getCurrentUserPrincipal); context.commit('addCalendar', { calendar }); }, /** * Delete a calendar * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to delete * @return {Promise} */ async deleteCalendar(context, _ref39) { let { calendar } = _ref39; await calendar.dav.delete(); context.commit('deleteCalendar', { calendar }); }, /** * Delete a calendar in the trash bin * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to delete * @return {Promise} */ async deleteCalendarPermanently(context, _ref40) { let { calendar } = _ref40; await calendar.delete({ 'X-NC-CalDAV-No-Trashbin': 1 }); context.commit('removeDeletedCalendar', { calendar }); }, deleteCalendarAfterTimeout(context, _ref41) { let { calendar, countdown = 7 } = _ref41; context.commit('setCalendarDeleteCountdown', { calendar, countdown }); const deleteInterval = setInterval(() => { countdown--; if (countdown < 0) { countdown = 0; } context.commit('setCalendarDeleteCountdown', { calendar, countdown }); }, 1000); const deleteTimeout = setTimeout(async () => { try { await context.dispatch('deleteCalendar', { calendar }); } catch (error) { (0,_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_10__.showError)((0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_6__.translate)('calendar', 'An error occurred, unable to delete the calendar.')); console.error(error); } finally { clearInterval(deleteInterval); } }, 7000); context.commit('setCalendarDeleteHandles', { calendar, deleteInterval, deleteTimeout }); }, cancelCalendarDeletion(context, _ref42) { let { calendar } = _ref42; if (calendar.deleteInterval) clearInterval(calendar.deleteInterval); if (calendar.deleteTimeout) clearTimeout(calendar.deleteTimeout); context.commit('setCalendarDeleteHandles', { calendar, deleteInterval: undefined, deleteTimeout: undefined }); }, async restoreCalendar(_ref43, _ref44) { let { commit, state } = _ref43; let { calendar } = _ref44; await state.trashBin.restore(calendar.url); commit('removeDeletedCalendar', { calendar }); }, async restoreCalendarObject(_ref45, _ref46) { var _component$startDate, _component$endDate; let { commit, state, getters } = _ref45; let { vobject } = _ref46; await state.trashBin.restore(vobject.uri); // Clean up the data locally commit('removeDeletedCalendarObject', { vobject }); // Delete cached time range that includes the restored event const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__.mapCDavObjectToCalendarObject)(vobject.dav, undefined); const component = calendarObject.calendarComponent.getFirstComponent(vobject.objectType); const timeRange = getters.getTimeRangeForCalendarCoveringRange(vobject.calendar.id, (_component$startDate = component.startDate) === null || _component$startDate === void 0 ? void 0 : _component$startDate.unixTime, (_component$endDate = component.endDate) === null || _component$endDate === void 0 ? void 0 : _component$endDate.unixTime); if (timeRange) { commit('deleteFetchedTimeRangeFromCalendar', { calendar: vobject.calendar, fetchedTimeRangeId: timeRange.id }); commit('removeTimeRange', { timeRangeId: timeRange.id }); } // Trigger calendar refresh commit('incrementModificationCount'); }, /** * Deletes a calendar-object permanently * * @param {object} context the store mutations * @param {object} data destructuring object * @param {vobject} data.vobject Calendar-object to delete * @return {Promise} */ async deleteCalendarObjectPermanently(context, _ref47) { let { vobject } = _ref47; await vobject.dav.delete({ 'X-NC-CalDAV-No-Trashbin': 1 }); context.commit('removeDeletedCalendarObject', { vobject }); }, /** * Toggle whether a calendar is enabled * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to modify * @return {Promise} */ async toggleCalendarEnabled(context, _ref48) { let { calendar } = _ref48; context.commit('markCalendarAsLoading', { calendar }); calendar.dav.enabled = !calendar.dav.enabled; try { await calendar.dav.update(); context.commit('markCalendarAsNotLoading', { calendar }); context.commit('toggleCalendarEnabled', { calendar }); } catch (error) { context.commit('markCalendarAsNotLoading', { calendar }); throw error; } }, /** * Rename a calendar * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to modify * @param {string} data.newName the new name of the calendar * @return {Promise} */ async renameCalendar(context, _ref49) { let { calendar, newName } = _ref49; calendar.dav.displayname = newName; await calendar.dav.update(); context.commit('renameCalendar', { calendar, newName }); }, /** * Change a calendar's color * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to modify * @param {string} data.newColor the new color of the calendar * @return {Promise} */ async changeCalendarColor(context, _ref50) { let { calendar, newColor } = _ref50; calendar.dav.color = newColor; await calendar.dav.update(); context.commit('changeCalendarColor', { calendar, newColor }); }, /** * Share calendar with User or Group * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to share * @param {string} data.user the userId * @param {string} data.displayName the displayName * @param {string} data.uri the sharing principalScheme uri * @param {boolean} data.isGroup is this a group? * @param {boolean} data.isCircle is this a circle? */ async shareCalendar(context, _ref51) { let { calendar, user, displayName, uri, isGroup, isCircle } = _ref51; // Share calendar with entered group or user await calendar.dav.share(uri); context.commit('shareCalendar', { calendar, user, displayName, uri, isGroup, isCircle }); }, /** * Toggle permissions of calendar Sharees writeable rights * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to change * @param {string} data.uri the sharing principalScheme uri */ async toggleCalendarShareWritable(context, _ref52) { let { calendar, uri } = _ref52; const sharee = calendar.shares.find(sharee => sharee.uri === uri); await calendar.dav.share(uri, !sharee.writeable); context.commit('toggleCalendarShareWritable', { calendar, uri }); }, /** * Remove sharee from calendar * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to change * @param {string} data.uri the sharing principalScheme uri */ async unshareCalendar(context, _ref53) { let { calendar, uri } = _ref53; await calendar.dav.unshare(uri); context.commit('unshareCalendar', { calendar, uri }); }, /** * Publish a calendar * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to change * @return {Promise} */ async publishCalendar(context, _ref54) { let { calendar } = _ref54; await calendar.dav.publish(); const publishURL = calendar.dav.publishURL; context.commit('publishCalendar', { calendar, publishURL }); }, /** * Unpublish a calendar * * @param {object} context the store mutations Current context * @param {object} data destructuring object * @param {object} data.calendar the calendar to change * @return {Promise} */ async unpublishCalendar(context, _ref55) { let { calendar } = _ref55; await calendar.dav.unpublish(); context.commit('unpublishCalendar', { calendar }); }, /** * Retrieve the events of the specified calendar * and commit the results * * @param {object} context the store mutations * @param {object} data destructuring object * @param {object} data.calendar the calendar to get events from * @param {Date} data.from the date to start querying events from * @param {Date} data.to the last date to query events from * @return {Promise} */ async getEventsFromCalendarInTimeRange(context, _ref56) { let { calendar, from, to } = _ref56; context.commit('markCalendarAsLoading', { calendar }); const response = await calendar.dav.findByTypeInTimeRange('VEVENT', from, to); let responseTodo = []; if (context.rootState.settings.showTasks) { responseTodo = await calendar.dav.findByTypeInTimeRange('VTODO', from, to); } context.commit('addTimeRange', { calendarId: calendar.id, from: (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_2__.getUnixTimestampFromDate)(from), to: (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_2__.getUnixTimestampFromDate)(to), lastFetched: (0,_utils_date_js__WEBPACK_IMPORTED_MODULE_2__.getUnixTimestampFromDate)((0,_utils_date_js__WEBPACK_IMPORTED_MODULE_2__.dateFactory)()), calendarObjectIds: [] }); const insertId = context.getters.getLastTimeRangeInsertId; context.commit('addFetchedTimeRangeToCalendar', { calendar, fetchedTimeRangeId: insertId }); const calendarObjects = []; const calendarObjectIds = []; for (const r of response.concat(responseTodo)) { try { const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__.mapCDavObjectToCalendarObject)(r, calendar.id); calendarObjects.push(calendarObject); calendarObjectIds.push(calendarObject.id); } catch (e) { console.error("could not convert calendar object of calendar ".concat(calendar.id), e, { response: r }); } } context.commit('appendCalendarObjects', { calendarObjects }); context.commit('appendCalendarObjectsToCalendar', { calendar, calendarObjectIds }); context.commit('appendCalendarObjectIdsToTimeFrame', { timeRangeId: insertId, calendarObjectIds }); context.commit('markCalendarAsNotLoading', { calendar }); return context.rootState.fetchedTimeRanges.lastTimeRangeInsertId; }, /** * Retrieve one object * * @param {object} context the store mutations * @param {object} data destructuring object * @param {string} data.objectId Id of the object to fetch * @return {Promise} */ async getEventByObjectId(context, _ref57) { let { objectId } = _ref57; // TODO - we should still check if the calendar-object is up to date // - Just send head and compare etags if (context.getters.getCalendarObjectById(objectId)) { return Promise.resolve(context.getters.getCalendarObjectById(objectId)); } // This might throw an exception, but we will leave it up to the methods // calling this action to properly handle it const objectPath = atob(objectId); const lastSlashIndex = objectPath.lastIndexOf('/'); const calendarPath = objectPath.slice(0, lastSlashIndex + 1); const objectFileName = objectPath.slice(lastSlashIndex + 1); const calendarId = btoa(calendarPath); if (!context.state.calendarsById[calendarId]) { return Promise.reject(new Error('')); } const calendar = context.state.calendarsById[calendarId]; const vObject = await calendar.dav.find(objectFileName); const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__.mapCDavObjectToCalendarObject)(vObject, calendar.id); context.commit('appendCalendarObject', { calendarObject }); context.commit('addCalendarObjectToCalendar', { calendar: { id: calendarId }, calendarObjectId: calendarObject.id }); return calendarObject; }, /** * Import events into calendar * * @param {object} context the store mutations */ async importEventsIntoCalendar(context) { context.commit('changeStage', _models_consts_js__WEBPACK_IMPORTED_MODULE_9__.IMPORT_STAGE_IMPORTING); // Create a copy const files = context.rootState.importFiles.importFiles.slice(); let totalCount = 0; for (const file of files) { totalCount += file.parser.getItemCount(); const calendarId = context.rootState.importFiles.importCalendarRelation[file.id]; if (calendarId === 'new') { const displayName = file.parser.getName() || (0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_6__.translate)('calendar', 'Imported {filename}', { filename: file.name }); const color = file.parser.getColor() || (0,_utils_color_js__WEBPACK_IMPORTED_MODULE_5__.uidToHexColor)(displayName); const components = []; if (file.parser.containsVEvents()) { components.push('VEVENT'); } if (file.parser.containsVJournals()) { components.push('VJOURNAL'); } if (file.parser.containsVTodos()) { components.push('VTODO'); } const response = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.createCalendar)(displayName, color, components, 0); const calendar = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_3__.mapDavCollectionToCalendar)(response, context.getters.getCurrentUserPrincipal); context.commit('addCalendar', { calendar }); context.commit('setCalendarForFileId', { fileId: file.id, calendarId: calendar.id }); } } context.commit('setTotal', totalCount); const limit = (0,p_limit__WEBPACK_IMPORTED_MODULE_4__["default"])(3); const requests = []; for (const file of files) { const calendarId = context.rootState.importFiles.importCalendarRelation[file.id]; const calendar = context.getters.getCalendarById(calendarId); for (const item of file.parser.getItemIterator()) { requests.push(limit(async () => { const ics = item.toICS(); let davObject; try { davObject = await calendar.dav.createVObject(ics); } catch (error) { context.commit('incrementDenied'); console.error(error); return; } const calendarObject = (0,_models_calendarObject_js__WEBPACK_IMPORTED_MODULE_1__.mapCDavObjectToCalendarObject)(davObject, calendarId); context.commit('appendCalendarObject', { calendarObject }); context.commit('addCalendarObjectToCalendar', { calendar, calendarObjectId: calendarObject.id }); context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { calendarId: calendar.id, calendarObjectId: calendarObject.id }); context.commit('incrementAccepted'); })); } } await Promise.all(requests); context.commit('changeStage', _models_consts_js__WEBPACK_IMPORTED_MODULE_9__.IMPORT_STAGE_PROCESSING); }, /** * * @param {object} context the store object * @param {object} context.commit the store mutations * @param {object} context.state the store state * @param {object} data The data destructuring object * @param {object} data.newOrder The object containing String => Number with the new order * @return {Promise} */ async updateCalendarListOrder(_ref58, _ref59) { let { state, commit } = _ref58; let { newOrder } = _ref59; // keep a record of the original order in case we need to do a rollback const limit = (0,p_limit__WEBPACK_IMPORTED_MODULE_4__["default"])(3); const requests = []; const calendarsToUpdate = []; for (const key in newOrder) { requests.push(limit(async () => { const calendar = state.calendarsById[key]; // Do not update unless necessary if (calendar.dav.order === newOrder[key]) { return; } calendar.dav.order = newOrder[key]; await calendar.dav.update(); calendarsToUpdate.push({ calendar, newOrder: newOrder[key] }); })); } await Promise.all(requests); for (const { calendar, newOrder } of calendarsToUpdate) { console.debug(calendar, newOrder); commit('changeCalendarOrder', { calendar, newOrder }); } } }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/contacts.js": /*!*******************************!*\ !*** ./src/store/contacts.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { contacts: [], contactByEMail: {} }; const mutations = { /** * Append a single contact to the store * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.contact The contact to append to the store */ appendContact(state, _ref) { let { contact } = _ref; if (state.contacts.indexOf(contact) === -1) { state.contacts.push(contact); } for (const email of contact.emails) { // In the unlikely case that multiple contacts // share the same email address, we will just follow // first come, first served. if (state.contactByEMail[email] === undefined) { vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state.contactByEMail, email, contact); } } }, /** * Removes a single contact from the store * * @param {object} state The store data * @param {object} data The destructuring object * @param {object} data.contact The contact to remove from the store */ removeContact(state, _ref2) { let { contact } = _ref2; for (const email of contact.emails) { if (state.contactByEMail[email] === contact) { vue__WEBPACK_IMPORTED_MODULE_0__["default"].delete(state.contactByEMail, email); } } const index = state.contacts.indexOf(contact); if (index !== -1) { state.contacts.splice(index, 1); } } }; const getters = {}; const actions = {}; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/davRestrictions.js": /*!**************************************!*\ !*** ./src/store/davRestrictions.js ***! \**************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /** * @copyright Copyright (c) 2020 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { minimumDate: '1970-01-01T00:00:00Z', maximumDate: '2037-12-31T23:59:59Z' }; const mutations = { /** * Initialize restrictions imposed by CalDAV server * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.minimumDate The minimum-date allowed by the CalDAV server * @param {string} data.maximumDate The maximum-date allowed by the CalDAV server */ loadDavRestrictionsFromServer(state, _ref) { let { minimumDate, maximumDate } = _ref; state.minimumDate = minimumDate; state.maximumDate = maximumDate; } }; const getters = {}; const actions = {}; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/fetchedTimeRanges.js": /*!****************************************!*\ !*** ./src/store/fetchedTimeRanges.js ***! \****************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { lastTimeRangeInsertId: -1, fetchedTimeRanges: [], fetchedTimeRangesById: {} }; const mutations = { /** * Adds a fetched time-range to the state * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {string} data.calendarId Calendar-id which objects have been fetched * @param {number} data.from timestamp of start * @param {number} data.to timestamp of end * @param {number} data.lastFetched timestamp of last-fetched * @param {string[]} data.calendarObjectIds array of calendarObjectIds */ addTimeRange(state, _ref) { let { calendarId, from, to, lastFetched, calendarObjectIds } = _ref; const fetchedTimeRange = { id: ++state.lastTimeRangeInsertId, calendarId, from, to, lastFetched, calendarObjectIds }; state.fetchedTimeRanges.push(fetchedTimeRange); vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state.fetchedTimeRangesById, fetchedTimeRange.id, fetchedTimeRange); }, /** * Removes a fetched time-range from the state * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.timeRangeId Id of time-range to remove */ removeTimeRange(state, _ref2) { let { timeRangeId } = _ref2; const obj = state.fetchedTimeRangesById[timeRangeId]; const index = state.fetchedTimeRanges.indexOf(obj); if (index !== -1) { state.fetchedTimeRanges.splice(index, 1); vue__WEBPACK_IMPORTED_MODULE_0__["default"].delete(state.fetchedTimeRangesById, timeRangeId); } }, /** * Adds a calendar-object-id to an already fetched time-range * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.timeRangeId The id of the time-range * @param {string[]} data.calendarObjectIds The array of ids of the calendar-object to add */ appendCalendarObjectIdsToTimeFrame(state, _ref3) { let { timeRangeId, calendarObjectIds } = _ref3; for (const calendarObjectId of calendarObjectIds) { if (state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.indexOf(calendarObjectId) === -1) { state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.push(calendarObjectId); } } }, /** * Adds a calendar-object-id to an already fetched time-range * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.timeRangeId The id of the time-range * @param {string} data.calendarObjectId The id of the calendar-object to add */ appendCalendarObjectIdToTimeRange(state, _ref4) { let { timeRangeId, calendarObjectId } = _ref4; state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.push(calendarObjectId); }, /** * Removes a calendar-object-id from an already fetched time-range * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.timeRangeId The id of the timerange * @param {string} data.calendarObjectId The id of the calendar-object to remove */ removeCalendarObjectIdFromTimeRange(state, _ref5) { let { timeRangeId, calendarObjectId } = _ref5; const index = state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.indexOf(calendarObjectId); if (index !== -1) { state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.splice(index, 1); } }, /** * Removes a calendar-object-id from any time-range it may occur in * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {string} data.calendarObjectId The id of the calendar-object to remove */ removeCalendarObjectIdFromAnyTimeRange(state, _ref6) { let { calendarObjectId } = _ref6; for (const timeRange of state.fetchedTimeRanges) { const index = timeRange.calendarObjectIds.indexOf(calendarObjectId); if (index !== -1) { timeRange.calendarObjectIds.splice(index, 1); } } }, /** * Updates the last-fetched timestamp of a time-range * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.timeRangeId The id of the timerange * @param {number} data.lastFetched Timestamp of last-fetched */ updateTimestampOfLastFetched(state, _ref7) { let { timeRangeId, lastFetched } = _ref7; state.fetchedTimeRangesById[timeRangeId].lastFetched = lastFetched; }, /** * Adds a calendar-object-id to all time-ranges of a given caloendar * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {string} data.calendarObjectId The id of the calendar-object * @param {string} data.calendarId The id of the calendar */ addCalendarObjectIdToAllTimeRangesOfCalendar(state, _ref8) { let { calendarObjectId, calendarId } = _ref8; for (const timerange of state.fetchedTimeRanges) { if (timerange.calendarId !== calendarId) { continue; } if (timerange.calendarObjectIds.indexOf(calendarObjectId) === -1) { timerange.calendarObjectIds.push(calendarObjectId); } } }, /** * Removes a calendar-object-id to all time-ranges of a given caloendar * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {string} data.calendarObjectId The id of the calendar-object * @param {string} data.calendarId The id of the calendar */ removeCalendarObjectIdFromAllTimeRangesOfCalendar(state, _ref9) { let { calendarObjectId, calendarId } = _ref9; for (const timerange of state.fetchedTimeRanges) { if (timerange.calendarId !== calendarId) { continue; } const index = timerange.calendarObjectIds.indexOf(calendarObjectId); if (index !== -1) { timerange.calendarObjectIds.splice(index, 1); } } }, /** * clear FetchedTimeRanges Store * * @param {object} state The vuex state */ clearFetchedTimeRanges(state) { state.lastTimeRangeInsertId = -1; state.fetchedTimeRanges = []; state.fetchedTimeRangesById = {}; } }; const getters = { /** * Get all time-ranges for a calendar * * @param {object} state The vuex state * @return {function({String}): {Object}[]} */ getAllTimeRangesForCalendar: state => calendarId => state.fetchedTimeRanges.filter(f => f.calendarId === calendarId), /** * Get time-range covering * * @param {object} state The vuex state * @return {function({Number}, {Number}, {Number}): {Object}|false} */ getTimeRangeForCalendarCoveringRange: state => (calendarId, requestedFrom, requestedTo) => { return state.fetchedTimeRanges.find(f => { return f.calendarId === calendarId && f.from <= requestedFrom && f.to >= requestedTo; }); }, /** * Get all time-ranges that have been last fetched before a given time * * @param {object} state The vuex state * @return {function({Number}): {Object}[]} */ getAllTimeRangesOlderThan: state => olderThan => state.fetchedTimeRanges.filter(f => f.lastFetched <= olderThan), /** * * @param {object} state The vuex state * @return {number} */ getLastTimeRangeInsertId: state => state.lastTimeRangeInsertId, /** * * @param {object} state The vuex state * @param {object} getters The vuex getters * @return {function({Number}): {CalendarObject}[]} */ getCalendarObjectsByTimeRangeId: (state, getters) => timeRangeId => { if (!state.fetchedTimeRangesById[timeRangeId]) { return []; } return state.fetchedTimeRangesById[timeRangeId].calendarObjectIds.map(calendarObjectId => { return getters.getCalendarObjectById(calendarObjectId); }); } }; const actions = {}; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/importFiles.js": /*!**********************************!*\ !*** ./src/store/importFiles.js ***! \**********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /** * @copyright Copyright (c) 2019 Team Popcorn * * @copyright Copyright (c) 2020 Georg Ehrke * * @author Team Popcorn * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { lastFileInsertId: -1, importFiles: [], importFilesById: {}, importCalendarRelation: {} }; const mutations = { /** * Adds a file to the state * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {string} data.contents Contents of file * @param {number} data.lastModified Timestamp of last modification * @param {string} data.name Name of file * @param {AbstractParser} data.parser The parser * @param {number} data.size Size of file * @param {string} data.type mime-type of file */ addFile(state, _ref) { let { contents, lastModified, name, parser, size, type } = _ref; const file = { id: ++state.lastFileInsertId, contents, lastModified, name, parser, size, type }; state.importFiles.push(file); vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state.importFilesById, file.id, file); }, /** * Sets a calendar for the file * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {number} data.fileId Id of file to select calendar for * @param {string} data.calendarId Id of calendar to import file into */ setCalendarForFileId(state, _ref2) { let { fileId, calendarId } = _ref2; vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state.importCalendarRelation, fileId, calendarId); }, /** * Removes all files from state * * @param {object} state The vuex state */ removeAllFiles(state) { vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state, 'importFiles', []); vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state, 'importFilesById', {}); vue__WEBPACK_IMPORTED_MODULE_0__["default"].set(state, 'importCalendarRelation', {}); } }; const getters = {}; const actions = {}; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/importState.js": /*!**********************************!*\ !*** ./src/store/importState.js ***! \**********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _models_consts_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../models/consts.js */ "./src/models/consts.js"); /** * @copyright Copyright (c) 2019 Team Popcorn * * @copyright Copyright (c) 2020 Georg Ehrke * * @author Team Popcorn * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { total: 0, accepted: 0, denied: 0, stage: _models_consts_js__WEBPACK_IMPORTED_MODULE_0__.IMPORT_STAGE_DEFAULT }; const mutations = { /** * Increment the number of calendar-objects accepted * * @param {object} state the store data */ incrementAccepted(state) { state.accepted++; }, /** * Increment the number of calendar-objects denied * * @param {object} state the store data */ incrementDenied(state) { state.denied++; }, /** * Set the total number of calendar-objects * * @param {object} state the store data * @param {number} total the total number of calendar-objects to import */ setTotal(state, total) { state.total = total; }, /** * Change stage to the indicated one * * @param {object} state the store data * @param {string} stage the name of the stage, see /src/models/consts.js */ changeStage(state, stage) { state.stage = stage; }, /** * Reset to the default state * * @param {object} state the store data */ resetState(state) { state.total = 0; state.accepted = 0; state.denied = 0; state.stage = _models_consts_js__WEBPACK_IMPORTED_MODULE_0__.IMPORT_STAGE_DEFAULT; } }; const getters = {}; const actions = {}; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/index.js": /*!****************************!*\ !*** ./src/store/index.js ***! \****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! vuex */ "./node_modules/vuex/dist/vuex.esm.js"); /* harmony import */ var _calendarObjectInstance_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./calendarObjectInstance.js */ "./src/store/calendarObjectInstance.js"); /* harmony import */ var _calendarObjects_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./calendarObjects.js */ "./src/store/calendarObjects.js"); /* harmony import */ var _calendars_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./calendars.js */ "./src/store/calendars.js"); /* harmony import */ var _contacts_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./contacts.js */ "./src/store/contacts.js"); /* harmony import */ var _davRestrictions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./davRestrictions.js */ "./src/store/davRestrictions.js"); /* harmony import */ var _fetchedTimeRanges_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fetchedTimeRanges.js */ "./src/store/fetchedTimeRanges.js"); /* harmony import */ var _importFiles_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./importFiles.js */ "./src/store/importFiles.js"); /* harmony import */ var _importState_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./importState.js */ "./src/store/importState.js"); /* harmony import */ var _principals_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./principals.js */ "./src/store/principals.js"); /* harmony import */ var _settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./settings.js */ "./src/store/settings.js"); /* harmony import */ var _userRole_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./userRole.js */ "./src/store/userRole.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @author John Molakvoæ * * @author Thomas Citharel * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ vue__WEBPACK_IMPORTED_MODULE_11__["default"].use(vuex__WEBPACK_IMPORTED_MODULE_12__["default"]); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (new vuex__WEBPACK_IMPORTED_MODULE_12__["default"].Store({ modules: { calendarObjectInstance: _calendarObjectInstance_js__WEBPACK_IMPORTED_MODULE_0__["default"], calendarObjects: _calendarObjects_js__WEBPACK_IMPORTED_MODULE_1__["default"], calendars: _calendars_js__WEBPACK_IMPORTED_MODULE_2__["default"], contacts: _contacts_js__WEBPACK_IMPORTED_MODULE_3__["default"], davRestrictions: _davRestrictions_js__WEBPACK_IMPORTED_MODULE_4__["default"], fetchedTimeRanges: _fetchedTimeRanges_js__WEBPACK_IMPORTED_MODULE_5__["default"], importFiles: _importFiles_js__WEBPACK_IMPORTED_MODULE_6__["default"], importState: _importState_js__WEBPACK_IMPORTED_MODULE_7__["default"], principals: _principals_js__WEBPACK_IMPORTED_MODULE_8__["default"], settings: _settings_js__WEBPACK_IMPORTED_MODULE_9__["default"], userRole: _userRole_js__WEBPACK_IMPORTED_MODULE_10__["default"] } // // Throw errors when the state is edited outside of mutations // strict: true })); /***/ }), /***/ "./src/store/principals.js": /*!*********************************!*\ !*** ./src/store/principals.js ***! \*********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.runtime.esm.js"); /* harmony import */ var _services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/caldavService.js */ "./src/services/caldavService.js"); /* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/logger.js */ "./src/utils/logger.js"); /* harmony import */ var _models_principal_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../models/principal.js */ "./src/models/principal.js"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { principals: [], principalsById: {}, currentUserPrincipal: null }; const mutations = { /** * Adds a principal to the state * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {object} data.principal The principal to add */ addPrincipal(state, _ref) { let { principal } = _ref; const object = (0,_models_principal_js__WEBPACK_IMPORTED_MODULE_2__.getDefaultPrincipalObject)(principal); if (state.principalsById[object.id]) { return; } state.principals.push(object); vue__WEBPACK_IMPORTED_MODULE_3__["default"].set(state.principalsById, object.id, object); }, /** * Adds the current user principal to the state * * @param {object} state The vuex state * @param {object} data destructuring object * @param {string} data.principalId principalId of the current-user-principal */ setCurrentUserPrincipal(state, _ref2) { let { principalId } = _ref2; state.currentUserPrincipal = principalId; }, /** * Changes the schedule-default-calendar-URL of a principal * * @param {object} state The vuex state * @param {object} data The destructuring object * @param {object} data.principal The principal to modify * @param {string} data.scheduleDefaultCalendarUrl The new schedule-default-calendar-URL */ changePrincipalScheduleDefaultCalendarUrl(state, _ref3) { let { principal, scheduleDefaultCalendarUrl } = _ref3; vue__WEBPACK_IMPORTED_MODULE_3__["default"].set(state.principalsById[principal.id], 'scheduleDefaultCalendarUrl', scheduleDefaultCalendarUrl); } }; const getters = { /** * Gets a principal object by its url * * @param {object} state the store data * @return {function({String}): {Object}} */ getPrincipalByUrl: state => url => state.principals.find(principal => principal.url === url), /** * Gets a principal object by its id * * @param {object} state the store data * @return {function({String}): {Object}} */ getPrincipalById: state => id => state.principalsById[id], /** * Gets the principal object of the current-user-principal * * @param {object} state the store data * @return {{Object}} */ getCurrentUserPrincipal: state => state.principalsById[state.currentUserPrincipal], /** * Gets the email-address of the current-user-principal * * @param {object} state the store data * @return {string|undefined} */ getCurrentUserPrincipalEmail: state => { var _state$principalsById; return (_state$principalsById = state.principalsById[state.currentUserPrincipal]) === null || _state$principalsById === void 0 ? void 0 : _state$principalsById.emailAddress; } }; const actions = { /** * Fetches a principal from the DAV server and commits it to the state * * @param {object} context The vuex context * @param {string} url The URL of the principal * @return {Promise} */ async fetchPrincipalByUrl(context, _ref4) { let { url } = _ref4; // Don't refetch principals we already have if (context.getters.getPrincipalByUrl(url)) { return; } const principal = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.findPrincipalByUrl)(url); if (!principal) { // TODO - handle error return; } context.commit('addPrincipal', { principal: (0,_models_principal_js__WEBPACK_IMPORTED_MODULE_2__.mapDavToPrincipal)(principal) }); }, /** * Fetches the current-user-principal * * @param {object} context The vuex context * @return {Promise} */ async fetchCurrentUserPrincipal(context) { const currentUserPrincipal = (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.getCurrentUserPrincipal)(); if (!currentUserPrincipal) { // TODO - handle error return; } const principal = (0,_models_principal_js__WEBPACK_IMPORTED_MODULE_2__.mapDavToPrincipal)(currentUserPrincipal); context.commit('addPrincipal', { principal }); context.commit('setCurrentUserPrincipal', { principalId: principal.id }); _utils_logger_js__WEBPACK_IMPORTED_MODULE_1__["default"].debug("Current user principal is ".concat(principal.url)); }, /** * Change a principal's schedule-default-calendar-URL * * @param {object} context The vuex context * @param {object} data The destructuring object * @param {object} data.principal The principal to modify * @param {string} data.scheduleDefaultCalendarUrl The new schedule-default-calendar-URL * @return {Promise} */ async changePrincipalScheduleDefaultCalendarUrl(context, _ref5) { let { principal, scheduleDefaultCalendarUrl } = _ref5; principal.dav.scheduleDefaultCalendarUrl = scheduleDefaultCalendarUrl; await principal.dav.update(); context.commit('changePrincipalScheduleDefaultCalendarUrl', { principal, scheduleDefaultCalendarUrl }); } }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/settings.js": /*!*******************************!*\ !*** ./src/store/settings.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/caldavService.js */ "./src/services/caldavService.js"); /* harmony import */ var _models_calendar_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../models/calendar.js */ "./src/models/calendar.js"); /* harmony import */ var _services_timezoneDetectionService_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../services/timezoneDetectionService.js */ "./src/services/timezoneDetectionService.js"); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _services_settings_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../services/settings.js */ "./src/services/settings.js"); /* harmony import */ var _utils_logger_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/logger.js */ "./src/utils/logger.js"); /* harmony import */ var _services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../services/timezoneDataProviderService.js */ "./src/services/timezoneDataProviderService.js"); /* harmony import */ var _services_attachmentService_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../services/attachmentService.js */ "./src/services/attachmentService.js"); /** * @copyright Copyright (c) 2020 Georg Ehrke * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author Georg Ehrke * @author Richard Steinmetz * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ const state = { // env appVersion: null, firstRun: null, talkEnabled: false, disableAppointments: false, publicCalendars: null, // user-defined calendar settings eventLimit: null, showTasks: null, showWeekends: null, showWeekNumbers: null, skipPopover: null, slotDuration: null, defaultReminder: null, tasksEnabled: false, timezone: 'automatic', hideEventExport: false, forceEventAlarmType: false, canSubscribeLink: true, showResources: true, // user-defined Nextcloud settings momentLocale: 'en', attachmentsFolder: '/Calendar', attachmentsFolderCreated: false }; const mutations = { /** * Updates the user's setting for event limit * * @param {object} state The Vuex state */ toggleEventLimitEnabled(state) { state.eventLimit = !state.eventLimit; }, /** * Updates the user's setting for visibility of event popover * * @param {object} state The Vuex state */ togglePopoverEnabled(state) { state.skipPopover = !state.skipPopover; }, /** * Updates the user's setting for visibility of weekends * * @param {object} state The Vuex state */ toggleTasksEnabled(state) { state.showTasks = !state.showTasks; }, /** * Updates the user's setting for visibility of weekends * * @param {object} state The Vuex state */ toggleWeekendsEnabled(state) { state.showWeekends = !state.showWeekends; }, /** * Updates the user's setting for visibility of week numbers * * @param {object} state The Vuex state */ toggleWeekNumberEnabled(state) { state.showWeekNumbers = !state.showWeekNumbers; }, /** * Updates the user's preferred slotDuration * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.slotDuration The new slot duration */ setSlotDuration(state, _ref) { let { slotDuration } = _ref; state.slotDuration = slotDuration; }, /** * Updates the user's preferred defaultReminder * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.defaultReminder The new default reminder length */ setDefaultReminder(state, _ref2) { let { defaultReminder } = _ref2; state.defaultReminder = defaultReminder; }, /** * Updates the user's timezone * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.timezoneId The new timezone */ setTimezone(state, _ref3) { let { timezoneId } = _ref3; state.timezone = timezoneId; }, /** * Updates the user's attachments folder * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.attachmentsFolder The new attachments folder */ setAttachmentsFolder(state, _ref4) { let { attachmentsFolder } = _ref4; state.attachmentsFolder = attachmentsFolder; state.attachmentsFolderCreated = false; }, /** * Update wheter the user's attachments folder has been created * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {boolean} data.attachmentsFolderCreated True if the folder has been created */ setAttachmentsFolderCreated(state, _ref5) { let { attachmentsFolderCreated } = _ref5; state.attachmentsFolderCreated = attachmentsFolderCreated; }, /** * Initialize settings * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.appVersion The version of the Nextcloud app * @param {boolean} data.eventLimit Whether or not to limit number of visible events in grid view * @param {boolean} data.firstRun Whether or not this is the first run * @param {boolean} data.showWeekNumbers Whether or not to show week numbers * @param {boolean} data.showTasks Whether or not to display tasks with a due-date * @param {boolean} data.showWeekends Whether or not to display weekends * @param {boolean} data.skipPopover Whether or not to skip the simple event popover * @param {string} data.slotDuration The duration of one slot in the agendaView * @param {string} data.defaultReminder The default reminder to set on newly created events * @param {boolean} data.talkEnabled Whether or not the talk app is enabled * @param {boolean} data.tasksEnabled Whether ot not the tasks app is enabled * @param {string} data.timezone The timezone to view the calendar in. Either an Olsen timezone or "automatic" * @param {boolean} data.hideEventExport * @param {string} data.forceEventAlarmType * @param {boolean} data.disableAppointments Allow to disable the appointments feature * @param {boolean} data.canSubscribeLink * @param {string} data.attachmentsFolder Default user's attachments folder * @param {boolean} data.showResources Show or hide the resources tab * @param {string} data.publicCalendars */ loadSettingsFromServer(state, _ref6) { let { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSubscribeLink, attachmentsFolder, showResources, publicCalendars } = _ref6; (0,_utils_logger_js__WEBPACK_IMPORTED_MODULE_5__.logInfo)("\nInitial settings:\n\t- AppVersion: ".concat(appVersion, "\n\t- EventLimit: ").concat(eventLimit, "\n\t- FirstRun: ").concat(firstRun, "\n\t- ShowWeekNumbers: ").concat(showWeekNumbers, "\n\t- ShowTasks: ").concat(showTasks, "\n\t- ShowWeekends: ").concat(showWeekends, "\n\t- SkipPopover: ").concat(skipPopover, "\n\t- SlotDuration: ").concat(slotDuration, "\n\t- DefaultReminder: ").concat(defaultReminder, "\n\t- TalkEnabled: ").concat(talkEnabled, "\n\t- TasksEnabled: ").concat(tasksEnabled, "\n\t- Timezone: ").concat(timezone, "\n\t- HideEventExport: ").concat(hideEventExport, "\n\t- ForceEventAlarmType: ").concat(forceEventAlarmType, "\n\t- disableAppointments: ").concat(disableAppointments, "\n\t- CanSubscribeLink: ").concat(canSubscribeLink, "\n\t- attachmentsFolder: ").concat(attachmentsFolder, "\n\t- ShowResources: ").concat(showResources, "\n\t- PublicCalendars: ").concat(publicCalendars, "\n")); state.appVersion = appVersion; state.eventLimit = eventLimit; state.firstRun = firstRun; state.showWeekNumbers = showWeekNumbers; state.showTasks = showTasks; state.showWeekends = showWeekends; state.skipPopover = skipPopover; state.slotDuration = slotDuration; state.defaultReminder = defaultReminder; state.talkEnabled = talkEnabled; state.tasksEnabled = tasksEnabled; state.timezone = timezone; state.hideEventExport = hideEventExport; state.forceEventAlarmType = forceEventAlarmType; state.disableAppointments = disableAppointments; state.canSubscribeLink = canSubscribeLink; state.attachmentsFolder = attachmentsFolder; state.showResources = showResources; state.publicCalendars = publicCalendars; }, /** * Sets the name of the moment.js locale to be used * * @param {object} state The Vuex state * @param {object} data The destructuring object * @param {string} data.locale The moment.js locale to be used */ setMomentLocale(state, _ref7) { let { locale } = _ref7; (0,_utils_logger_js__WEBPACK_IMPORTED_MODULE_5__.logInfo)("Updated moment locale: ".concat(locale)); state.momentLocale = locale; } }; const getters = { isTalkEnabled: state => state.talkEnabled, /** * Gets the resolved timezone. * If the timezone is set to automatic, it returns the user's current timezone * Otherwise, it returns the Olsen timezone stored * * @param {object} state The Vuex state * @return {string} */ getResolvedTimezone: state => state.timezone === 'automatic' ? (0,_services_timezoneDetectionService_js__WEBPACK_IMPORTED_MODULE_2__.detectTimezone)() : state.timezone, /** * Gets the resolved timezone object. * Falls back to UTC if timezone is invalid. * * @param {object} state The Vuex state * @param {object} getters The vuex getters * @return {object} The calendar-js timezone object */ getResolvedTimezoneObject: (state, getters) => { const timezone = getters.getResolvedTimezone; let timezoneObject = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_6__["default"])().getTimezoneForId(timezone); if (!timezoneObject) { timezoneObject = (0,_services_timezoneDataProviderService_js__WEBPACK_IMPORTED_MODULE_6__["default"])().getTimezoneForId('UTC'); } return timezoneObject; } }; const actions = { /** * Updates the user's setting for visibility of birthday calendar * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.getters The Vuex Getters * @param {Function} vuex.commit The Vuex commit Function * @param {Function} vuex.dispatch The Vuex dispatch Function * @return {Promise} */ async toggleBirthdayCalendarEnabled(_ref8) { let { getters, commit, dispatch } = _ref8; if (getters.hasBirthdayCalendar) { const calendar = getters.getBirthdayCalendar; await dispatch('deleteCalendar', { calendar }); } else { const davCalendar = await (0,_services_caldavService_js__WEBPACK_IMPORTED_MODULE_0__.enableBirthdayCalendar)(); const calendar = (0,_models_calendar_js__WEBPACK_IMPORTED_MODULE_1__.mapDavCollectionToCalendar)(davCalendar); commit('addCalendar', { calendar }); } }, /** * Updates the user's setting for event limit * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @return {Promise} */ async toggleEventLimitEnabled(_ref9) { let { state, commit } = _ref9; const newState = !state.eventLimit; const value = newState ? 'yes' : 'no'; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('eventLimit', value); commit('toggleEventLimitEnabled'); }, /** * Updates the user's setting for visibility of event popover * * @param {object} context The Vuex context * @param {object} context.state The store state * @param {object} context.commit The store mutations * @return {Promise} */ async togglePopoverEnabled(_ref10) { let { state, commit } = _ref10; const newState = !state.skipPopover; const value = newState ? 'yes' : 'no'; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('skipPopover', value); commit('togglePopoverEnabled'); }, /** * Updates the user's setting for visibility of weekends * * @param {object} context The Vuex context * @param {object} context.state The store state * @param {object} context.commit The store mutations * @return {Promise} */ async toggleWeekendsEnabled(_ref11) { let { state, commit } = _ref11; const newState = !state.showWeekends; const value = newState ? 'yes' : 'no'; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('showWeekends', value); commit('toggleWeekendsEnabled'); }, /** * Updates the user's setting for visibility of tasks * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @return {Promise} */ async toggleTasksEnabled(_ref12) { let { state, commit } = _ref12; const newState = !state.showTasks; const value = newState ? 'yes' : 'no'; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('showTasks', value); commit('toggleTasksEnabled'); commit('clearFetchedTimeRanges'); commit('incrementModificationCount'); }, /** * Updates the user's setting for visibility of week numbers * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @return {Promise} */ async toggleWeekNumberEnabled(_ref13) { let { state, commit } = _ref13; const newState = !state.showWeekNumbers; const value = newState ? 'yes' : 'no'; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('showWeekNr', value); commit('toggleWeekNumberEnabled'); }, /** * Updates the view to be used as initial view when opening * the calendar app again * * @param {object} context The Vuex destructuring object * @param {object} data The destructuring object * @param {string} data.initialView New view to be used as initial view * @return {Promise} */ async setInitialView(context, _ref14) { let { initialView } = _ref14; await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('view', initialView); }, /** * Updates the user's preferred slotDuration * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @param {object} data The destructuring object * @param {string} data.slotDuration The new slot duration */ async setSlotDuration(_ref15, _ref16) { let { state, commit } = _ref15; let { slotDuration } = _ref16; if (state.slotDuration === slotDuration) { return; } await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('slotDuration', slotDuration); commit('setSlotDuration', { slotDuration }); }, /** * Updates the user's preferred defaultReminder * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @param {object} data The destructuring object * @param {string} data.defaultReminder The new default reminder */ async setDefaultReminder(_ref17, _ref18) { let { state, commit } = _ref17; let { defaultReminder } = _ref18; if (state.defaultReminder === defaultReminder) { return; } await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('defaultReminder', defaultReminder); commit('setDefaultReminder', { defaultReminder }); }, /** * Updates the user's timezone * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @param {object} data The destructuring object * @param {string} data.timezoneId The new timezone * @return {Promise} */ async setTimezone(_ref19, _ref20) { let { state, commit } = _ref19; let { timezoneId } = _ref20; if (state.timezone === timezoneId) { return; } await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('timezone', timezoneId); commit('setTimezone', { timezoneId }); }, /** * Updates the user's attachments folder * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @param {object} data The destructuring object * @param {string} data.attachmentsFolder The new attachments folder * @return {Promise} */ async setAttachmentsFolder(_ref21, _ref22) { let { state, commit } = _ref21; let { attachmentsFolder } = _ref22; if (state.attachmentsFolder === attachmentsFolder) { return; } await (0,_services_settings_js__WEBPACK_IMPORTED_MODULE_4__.setConfig)('attachmentsFolder', attachmentsFolder); commit('setAttachmentsFolder', { attachmentsFolder }); }, /** * Create the user's attachment folder if it doesn't exist and return its path * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state * @param {Function} vuex.commit The Vuex commit Function * @param {Function} vuex.dispatch The Vuex commit function * @param {object} vuex.getters The Vuex getters object * @return {Promise} The path of the user's attachments folder */ async createAttachmentsFolder(_ref23) { let { state, commit, dispatch, getters } = _ref23; if (state.attachmentsFolderCreated) { return state.attachmentsFolder; } const userId = getters.getCurrentUserPrincipal.dav.userId; const path = await _services_attachmentService_js__WEBPACK_IMPORTED_MODULE_7__.createFolder(state.attachmentsFolder, userId); if (path !== state.attachmentsFolder) { await dispatch('setAttachmentsFolder', { attachmentsFolder: path }); } commit('setAttachmentsFolderCreated', { attachmentsFolderCreated: true }); return path; }, /** * Initializes the calendar-js configuration * * @param {object} vuex The Vuex destructuring object * @param {object} vuex.state The Vuex state */ initializeCalendarJsConfig(_ref24) { let { state } = _ref24; (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_3__.setConfig)('PRODID', "-//IDN nextcloud.com//Calendar app ".concat(state.appVersion, "//EN")); (0,_nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_3__.setConfig)('property-list-significant-change', ['SUMMARY', 'LOCATION', 'DESCRIPTION', 'CLIENT']); } }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ state, mutations, getters, actions }); /***/ }), /***/ "./src/store/userRole.js": /*!*******************************!*\ !*** ./src/store/userRole.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _services_roleService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../services/roleService */ "./src/services/roleService.js"); const state = { roles: [] // Store the roles here }; const mutations = { setUserRole(state, roles) { state.roles = roles; } }; const actions = { async fetchUserRoles(_ref) { let { commit } = _ref; try { // Pass commit to the service await _services_roleService__WEBPACK_IMPORTED_MODULE_0__["default"].fetchAndCommitRoles(commit); } catch (error) {} } }; const getters = { isAdmin: state => state.roles.includes("admin"), canAccessPreviousEvent: state => state.roles.includes("Ligne") == false && state.roles.includes("ligne") == false }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ namespaced: true, state, mutations, actions, getters }); /***/ }), /***/ "./src/utils/alarms.js": /*!*****************************!*\ !*** ./src/utils/alarms.js ***! \*****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getAmountAndUnitForTimedEvents: () => (/* binding */ getAmountAndUnitForTimedEvents), /* harmony export */ getAmountHoursMinutesAndUnitForAllDayEvents: () => (/* binding */ getAmountHoursMinutesAndUnitForAllDayEvents), /* harmony export */ getFactorForAlarmUnit: () => (/* binding */ getFactorForAlarmUnit), /* harmony export */ getTotalSecondsFromAmountAndUnitForTimedEvents: () => (/* binding */ getTotalSecondsFromAmountAndUnitForTimedEvents), /* harmony export */ getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents: () => (/* binding */ getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents), /* harmony export */ updateAlarms: () => (/* binding */ updateAlarms) /* harmony export */ }); /* harmony import */ var _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/calendar-js */ "./node_modules/@nextcloud/calendar-js/dist/index.es.mjs"); /* harmony import */ var _nextcloud_l10n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/l10n */ "./node_modules/@nextcloud/l10n/dist/index.mjs"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * @author Richard Steinmetz * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Get the factor for a given unit * * @param {string} unit The name of the unit to get the factor of * @return {number} */ function getFactorForAlarmUnit(unit) { switch (unit) { case 'seconds': return 1; case 'minutes': return 60; case 'hours': return 60 * 60; case 'days': return 24 * 60 * 60; case 'weeks': return 7 * 24 * 60 * 60; default: return 1; } } /** * Gets the amount of days / weeks, unit from total seconds * * @param {number} totalSeconds Total amount of seconds * @return {{amount: number, unit: string}} */ function getAmountAndUnitForTimedEvents(totalSeconds) { // Before or after the event is handled somewhere else, // so make sure totalSeconds is positive totalSeconds = Math.abs(totalSeconds); // Handle the special case of 0, so we don't show 0 weeks if (totalSeconds === 0) { return { amount: 0, unit: 'minutes' }; } if (totalSeconds % (7 * 24 * 60 * 60) === 0) { return { amount: totalSeconds / (7 * 24 * 60 * 60), unit: 'weeks' }; } if (totalSeconds % (24 * 60 * 60) === 0) { return { amount: totalSeconds / (24 * 60 * 60), unit: 'days' }; } if (totalSeconds % (60 * 60) === 0) { return { amount: totalSeconds / (60 * 60), unit: 'hours' }; } if (totalSeconds % 60 === 0) { return { amount: totalSeconds / 60, unit: 'minutes' }; } return { amount: totalSeconds, unit: 'seconds' }; } /** * Get the total amount of seconds based on amount and unit for timed events * * @param {number} amount Amount of unit * @param {string} unit Minutes/Hours/Days/Weeks * @param {boolean=} isBefore Whether the reminder is before or after the event * @return {number} */ function getTotalSecondsFromAmountAndUnitForTimedEvents(amount, unit) { let isBefore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; return amount * getFactorForAlarmUnit(unit) * (isBefore ? -1 : 1); } /** * Gets the amount of days / weeks, unit, hours and minutes from total seconds * * @param {number} totalSeconds Total amount of seconds * @return {{amount: *, unit: *, hours: *, minutes: *}} */ function getAmountHoursMinutesAndUnitForAllDayEvents(totalSeconds) { const dayFactor = getFactorForAlarmUnit('days'); const hourFactor = getFactorForAlarmUnit('hours'); const minuteFactor = getFactorForAlarmUnit('minutes'); const isNegative = totalSeconds < 0; totalSeconds = Math.abs(totalSeconds); let dayPart = Math.floor(totalSeconds / dayFactor); const hourPart = totalSeconds % dayFactor; if (hourPart !== 0) { if (isNegative) { dayPart++; } } let amount = 0; let unit = null; if (dayPart === 0) { unit = 'days'; } else if (dayPart % 7 === 0) { amount = dayPart / 7; unit = 'weeks'; } else { amount = dayPart; unit = 'days'; } let hours = Math.floor(hourPart / hourFactor); const minutePart = hourPart % hourFactor; let minutes = Math.floor(minutePart / minuteFactor); if (isNegative) { hours = 24 - hours; if (minutes !== 0) { hours--; minutes = 60 - minutes; } } return { amount, unit, hours, minutes }; } /** * Get the total amount of seconds for all-day events * * @param {number} amount amount of unit * @param {number} hours Time of reminder * @param {number} minutes Time of reminder * @param {string} unit days/weeks * @return {number} */ function getTotalSecondsFromAmountHourMinutesAndUnitForAllDayEvents(amount, hours, minutes, unit) { if (unit === 'weeks') { amount *= 7; unit = 'days'; } // 0 is on the same day of the all-day event => positive // 1 ... n before the event is negative const isNegative = amount > 0; if (isNegative) { // If it's negative, we need to subtract one day amount--; // Convert days to seconds amount *= getFactorForAlarmUnit(unit); let invertedHours = 24 - hours; let invertedMinutes = 0; if (minutes !== 0) { invertedHours--; invertedMinutes = 60 - minutes; } amount += invertedHours * getFactorForAlarmUnit('hours'); amount += invertedMinutes * getFactorForAlarmUnit('minutes'); amount *= -1; } else { // Convert days to seconds amount *= getFactorForAlarmUnit('days'); amount += hours * getFactorForAlarmUnit('hours'); amount += minutes * getFactorForAlarmUnit('minutes'); } return amount; } /** * Propagate data from an event component to all EMAIL alarm components. * An alarm component must contain a description, summary and all attendees to be notified. * We don't have a separate UI for maintaining attendees of an alarm, so we just copy them from the event. * * https://www.rfc-editor.org/rfc/rfc5545#section-3.6.6 * * @param {AbstractRecurringComponent} eventComponent */ function updateAlarms(eventComponent) { for (const alarmComponent of eventComponent.getAlarmIterator()) { if (alarmComponent.action !== 'EMAIL' && alarmComponent.action !== 'DISPLAY') { continue; } alarmComponent.deleteAllProperties('SUMMARY'); const summaryProperty = eventComponent.getFirstProperty('SUMMARY'); if (summaryProperty) { alarmComponent.addProperty(summaryProperty.clone()); } else { const defaultSummary = (0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_1__.translate)('calendar', 'Untitled event'); alarmComponent.addProperty(new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__.Property('SUMMARY', defaultSummary)); } if (!alarmComponent.hasProperty('DESCRIPTION')) { const defaultDescription = (0,_nextcloud_l10n__WEBPACK_IMPORTED_MODULE_1__.translate)('calendar', 'This is an event reminder.'); alarmComponent.addProperty(new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__.Property('DESCRIPTION', defaultDescription)); } alarmComponent.deleteAllProperties('ATTENDEE'); for (const attendee of eventComponent.getAttendeeIterator()) { if (['RESOURCE', 'ROOM'].includes(attendee.userType)) { continue; } // Only copy the email address (value) of the attendee alarmComponent.addProperty(new _nextcloud_calendar_js__WEBPACK_IMPORTED_MODULE_0__.AttendeeProperty('ATTENDEE', attendee.value)); } } } /***/ }), /***/ "./src/utils/recurrence.js": /*!*********************************!*\ !*** ./src/utils/recurrence.js ***! \*********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getBySetPositionAndBySetFromDate: () => (/* binding */ getBySetPositionAndBySetFromDate), /* harmony export */ getWeekDayFromDate: () => (/* binding */ getWeekDayFromDate) /* harmony export */ }); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Gets the ByDay and BySetPosition * * @param {Date} jsDate The date to get the weekday of * @return {object} */ function getBySetPositionAndBySetFromDate(jsDate) { const byDay = getWeekDayFromDate(jsDate); let bySetPosition = 1; let dayOfMonth = jsDate.getDate(); for (; dayOfMonth > 7; dayOfMonth -= 7) { bySetPosition++; } return { byDay, bySetPosition }; } /** * Gets the string-representation of the weekday of a given date * * @param {Date} jsDate The date to get the weekday of * @return {string} */ function getWeekDayFromDate(jsDate) { switch (jsDate.getDay()) { case 0: return 'SU'; case 1: return 'MO'; case 2: return 'TU'; case 3: return 'WE'; case 4: return 'TH'; case 5: return 'FR'; case 6: return 'SA'; default: throw TypeError('Invalid date-object given'); } } /***/ }), /***/ "./src/utils/settings.js": /*!*******************************!*\ !*** ./src/utils/settings.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ getLinkToConfig: () => (/* binding */ getLinkToConfig) /* harmony export */ }); /* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/router */ "./node_modules/@nextcloud/router/dist/index.mjs"); /** * @copyright Copyright (c) 2019 Georg Ehrke * * @author Georg Ehrke * * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /** * Get URL to modify config-key * * @param {string} key URL of config-key to modify * @return {string} */ function getLinkToConfig(key) { return [(0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_0__.linkTo)('calendar', 'index.php'), 'v1/config', key].join('/'); } /***/ }) }]); //# sourceMappingURL=calendar-src_store_index_js.js.map?v=31fefc412047bbdd4252