Loading package-lock.json +1 −1 Original line number Diff line number Diff line Loading @@ -4362,7 +4362,7 @@ } }, "calendar-js": { "version": "git+https://github.com/georgehrke/calendar-js.git#04c9848de8e1bc6842dc2aca37ff75caa9eaf9c7", "version": "git+https://github.com/georgehrke/calendar-js.git#fc37c335684f6f76c6869aa9ef661d8aba42ded4", "from": "git+https://github.com/georgehrke/calendar-js.git", "requires": { "ical.js": "^1.3.0", Loading src/models/calendar.js +4 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ export const getDefaultCalendarObject = (props = {}) => Object.assign({}, { supportsTasks: false, // The principal uri of the owner owner: '', // Timezone set for this calendar timezone: null, // List of shares shares: [], // Published url Loading Loading @@ -99,6 +101,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) { const order = calendar.order || 0 const url = calendar.url const publishURL = calendar.publishURL || null const timezone = calendar.timezone || null let isSharedWithMe = false if (!currentUserPrincipal) { Loading Loading @@ -152,6 +155,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) { canBeShared, canBePublished, shares, timezone, dav: calendar } } Loading src/store/calendars.js +19 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import { getDefaultCalendarObject, mapDavCollectionToCalendar } from '../models/ import pLimit from 'p-limit' import { uidToHexColor } from '../utils/color.js' import { translate } from '@nextcloud/l10n' import getTimezoneManager from '../services/timezoneDataProviderService.js' import Timezone from 'calendar-js/src/timezones/timezone.js' import CalendarComponent from 'calendar-js/src/components/calendarComponent.js' const state = { calendars: [], Loading Loading @@ -460,10 +463,24 @@ const actions = { * @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 * @returns {Promise} */ async appendCalendar(context, { displayName, color, order }) { return client.calendarHomes[0].createCalendarCollection(displayName, color, ['VEVENT'], order) async appendCalendar(context, { displayName, color, order, components = ['VEVENT'], timezone = null }) { if (timezone === null) { timezone = context.getters.getResolvedTimezone } let timezoneIcs = null const timezoneObject = getTimezoneManager().getTimezoneForId(timezone) if (timezoneObject !== Timezone.utc && timezoneObject !== Timezone.floating) { const calendar = CalendarComponent.fromEmpty() calendar.addComponent(timezoneObject.toTimezoneComponent()) timezoneIcs = calendar.toICS(false) } return client.calendarHomes[0].createCalendarCollection(displayName, color, components, order, timezoneIcs) .then((response) => { const calendar = mapDavCollectionToCalendar(response, context.getters.getCurrentUserPrincipal) context.commit('addCalendar', { calendar }) Loading tests/javascript/unit/models/calendar.test.js +15 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ describe('models/calendar test suite', () => { owner: '', shares: [], publishURL: null, timezone: null, url: '', readOnly: false, order: 0, Loading Loading @@ -69,6 +70,7 @@ describe('models/calendar test suite', () => { owner: '', shares: [], publishURL: null, timezone: null, url: '', readOnly: false, order: 0, Loading @@ -93,7 +95,8 @@ describe('models/calendar test suite', () => { isPublishable: () => true, order: undefined, publishURL: undefined, enabled: true enabled: true, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', } expect(mapDavCollectionToCalendar(cdavObject, { Loading @@ -115,6 +118,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', url: '/foo/bar' }) }) Loading @@ -131,6 +135,7 @@ describe('models/calendar test suite', () => { isPublishable: () => true, order: undefined, publishURL: undefined, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', enabled: false } Loading @@ -153,6 +158,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', url: '/foo/bar' }) }) Loading Loading @@ -191,6 +197,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -229,6 +236,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: true, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -267,6 +275,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -305,6 +314,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -343,6 +353,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -381,6 +392,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -490,6 +502,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -568,6 +581,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: true, timezone: null, url: '/foo/bar' }) }) Loading Loading
package-lock.json +1 −1 Original line number Diff line number Diff line Loading @@ -4362,7 +4362,7 @@ } }, "calendar-js": { "version": "git+https://github.com/georgehrke/calendar-js.git#04c9848de8e1bc6842dc2aca37ff75caa9eaf9c7", "version": "git+https://github.com/georgehrke/calendar-js.git#fc37c335684f6f76c6869aa9ef661d8aba42ded4", "from": "git+https://github.com/georgehrke/calendar-js.git", "requires": { "ical.js": "^1.3.0", Loading
src/models/calendar.js +4 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ export const getDefaultCalendarObject = (props = {}) => Object.assign({}, { supportsTasks: false, // The principal uri of the owner owner: '', // Timezone set for this calendar timezone: null, // List of shares shares: [], // Published url Loading Loading @@ -99,6 +101,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) { const order = calendar.order || 0 const url = calendar.url const publishURL = calendar.publishURL || null const timezone = calendar.timezone || null let isSharedWithMe = false if (!currentUserPrincipal) { Loading Loading @@ -152,6 +155,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) { canBeShared, canBePublished, shares, timezone, dav: calendar } } Loading
src/store/calendars.js +19 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import { getDefaultCalendarObject, mapDavCollectionToCalendar } from '../models/ import pLimit from 'p-limit' import { uidToHexColor } from '../utils/color.js' import { translate } from '@nextcloud/l10n' import getTimezoneManager from '../services/timezoneDataProviderService.js' import Timezone from 'calendar-js/src/timezones/timezone.js' import CalendarComponent from 'calendar-js/src/components/calendarComponent.js' const state = { calendars: [], Loading Loading @@ -460,10 +463,24 @@ const actions = { * @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 * @returns {Promise} */ async appendCalendar(context, { displayName, color, order }) { return client.calendarHomes[0].createCalendarCollection(displayName, color, ['VEVENT'], order) async appendCalendar(context, { displayName, color, order, components = ['VEVENT'], timezone = null }) { if (timezone === null) { timezone = context.getters.getResolvedTimezone } let timezoneIcs = null const timezoneObject = getTimezoneManager().getTimezoneForId(timezone) if (timezoneObject !== Timezone.utc && timezoneObject !== Timezone.floating) { const calendar = CalendarComponent.fromEmpty() calendar.addComponent(timezoneObject.toTimezoneComponent()) timezoneIcs = calendar.toICS(false) } return client.calendarHomes[0].createCalendarCollection(displayName, color, components, order, timezoneIcs) .then((response) => { const calendar = mapDavCollectionToCalendar(response, context.getters.getCurrentUserPrincipal) context.commit('addCalendar', { calendar }) Loading
tests/javascript/unit/models/calendar.test.js +15 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ describe('models/calendar test suite', () => { owner: '', shares: [], publishURL: null, timezone: null, url: '', readOnly: false, order: 0, Loading Loading @@ -69,6 +70,7 @@ describe('models/calendar test suite', () => { owner: '', shares: [], publishURL: null, timezone: null, url: '', readOnly: false, order: 0, Loading @@ -93,7 +95,8 @@ describe('models/calendar test suite', () => { isPublishable: () => true, order: undefined, publishURL: undefined, enabled: true enabled: true, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', } expect(mapDavCollectionToCalendar(cdavObject, { Loading @@ -115,6 +118,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', url: '/foo/bar' }) }) Loading @@ -131,6 +135,7 @@ describe('models/calendar test suite', () => { isPublishable: () => true, order: undefined, publishURL: undefined, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', enabled: false } Loading @@ -153,6 +158,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: 'BEGIN:VCALENDAR...END:VCALENDAR', url: '/foo/bar' }) }) Loading Loading @@ -191,6 +197,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -229,6 +236,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: true, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -267,6 +275,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -305,6 +314,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -343,6 +353,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -381,6 +392,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -490,6 +502,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: false, timezone: null, url: '/foo/bar' }) }) Loading Loading @@ -568,6 +581,7 @@ describe('models/calendar test suite', () => { supportsJournals: false, supportsTasks: false, isSharedWithMe: true, timezone: null, url: '/foo/bar' }) }) Loading