Loading src/components/AppNavigation/AppointmentConfigList.vue +1 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ export default { defaultConfig() { return AppointmentConfig.createDefault( this.calendarUrlToUri(this.$store.getters.sortedCalendars[0].url), this.$store.getters.scheduleInbox, this.$store.getters.getResolvedTimezone, ) }, Loading src/components/AppointmentConfigModal.vue +1 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ export default { defaultConfig() { return AppointmentConfig.createDefault( this.calendarUrlToUri(this.$store.getters.sortedCalendars[0].url), this.$store.getters.scheduleInbox, this.$store.getters.getResolvedTimezone, ) }, Loading src/models/appointmentConfig.js +20 −11 Original line number Diff line number Diff line Loading @@ -21,7 +21,10 @@ */ import { generateUrl } from '@nextcloud/router' import { getEmptySlots } from '@nextcloud/calendar-availability-vue' import { getEmptySlots, vavailabilityToSlots, } from '@nextcloud/calendar-availability-vue' /** @class */ export default class AppointmentConfig { Loading Loading @@ -114,18 +117,24 @@ export default class AppointmentConfig { * Create a default appointment config instance * * @param {string} targetCalendarUri * @param {string} timezoneId * @param {ScheduleInbox} scheduleInbox * @param {string} timezoneId fallback time zone when no schedule inbox availability is set * @return {AppointmentConfig} Default appointment config instance */ static createDefault(targetCalendarUri, timezoneId) { static createDefault(targetCalendarUri, scheduleInbox, timezoneId) { let slots = getEmptySlots() if (scheduleInbox && scheduleInbox.availability) { const converted = vavailabilityToSlots(scheduleInbox.availability) slots = converted.slots timezoneId = slots.timezoneId } else { // Set default availability to Mo-Fr 9-5 // TODO: fetch user's working hours if possible const tsAtTime = (hours, minutes) => Math.round((new Date()).setHours(hours, minutes, 0, 0) / 1000) const slots = getEmptySlots(); const tsAtTime = (hours, minutes) => Math.round((new Date()).setHours(hours, minutes, 0, 0) / 1000); ['MO', 'TU', 'WE', 'TH', 'FR'].forEach(day => slots[day].push({ start: tsAtTime(9, 0), end: tsAtTime(17, 0), })) } return new AppointmentConfig({ name: '', Loading src/store/calendars.js +13 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import { const state = { calendars: [], trashBin: undefined, scheduleInbox: undefined, deletedCalendars: [], deletedCalendarObjects: [], calendarsById: {}, Loading Loading @@ -80,6 +81,10 @@ const mutations = { state.trashBin = trashBin }, addScheduleInbox(state, { scheduleInbox }) { state.scheduleInbox = scheduleInbox }, /** * Adds deleted calendar into state * Loading Loading @@ -412,6 +417,10 @@ const getters = { return state.trashBin }, scheduleInbox: (state) => { return state.scheduleInbox }, /** * List of deleted sorted calendars * Loading Loading @@ -546,7 +555,7 @@ const actions = { * @return {Promise<object>} the results */ async loadCollections({ commit, state, getters }) { const { calendars, trashBins } = await findAll() const { calendars, trashBins, scheduleInboxes } = await findAll() console.info('calendar home scanned', calendars, trashBins) calendars.map((calendar) => mapDavCollectionToCalendar(calendar, getters.getCurrentUserPrincipal)).forEach(calendar => { commit('addCalendar', { calendar }) Loading @@ -554,6 +563,9 @@ const actions = { if (trashBins.length) { commit('addTrashBin', { trashBin: trashBins[0] }) } if (scheduleInboxes.length) { commit('addScheduleInbox', { scheduleInbox: scheduleInboxes[0] }) } commit('initialCalendarsLoaded') return { Loading Loading
src/components/AppNavigation/AppointmentConfigList.vue +1 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ export default { defaultConfig() { return AppointmentConfig.createDefault( this.calendarUrlToUri(this.$store.getters.sortedCalendars[0].url), this.$store.getters.scheduleInbox, this.$store.getters.getResolvedTimezone, ) }, Loading
src/components/AppointmentConfigModal.vue +1 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ export default { defaultConfig() { return AppointmentConfig.createDefault( this.calendarUrlToUri(this.$store.getters.sortedCalendars[0].url), this.$store.getters.scheduleInbox, this.$store.getters.getResolvedTimezone, ) }, Loading
src/models/appointmentConfig.js +20 −11 Original line number Diff line number Diff line Loading @@ -21,7 +21,10 @@ */ import { generateUrl } from '@nextcloud/router' import { getEmptySlots } from '@nextcloud/calendar-availability-vue' import { getEmptySlots, vavailabilityToSlots, } from '@nextcloud/calendar-availability-vue' /** @class */ export default class AppointmentConfig { Loading Loading @@ -114,18 +117,24 @@ export default class AppointmentConfig { * Create a default appointment config instance * * @param {string} targetCalendarUri * @param {string} timezoneId * @param {ScheduleInbox} scheduleInbox * @param {string} timezoneId fallback time zone when no schedule inbox availability is set * @return {AppointmentConfig} Default appointment config instance */ static createDefault(targetCalendarUri, timezoneId) { static createDefault(targetCalendarUri, scheduleInbox, timezoneId) { let slots = getEmptySlots() if (scheduleInbox && scheduleInbox.availability) { const converted = vavailabilityToSlots(scheduleInbox.availability) slots = converted.slots timezoneId = slots.timezoneId } else { // Set default availability to Mo-Fr 9-5 // TODO: fetch user's working hours if possible const tsAtTime = (hours, minutes) => Math.round((new Date()).setHours(hours, minutes, 0, 0) / 1000) const slots = getEmptySlots(); const tsAtTime = (hours, minutes) => Math.round((new Date()).setHours(hours, minutes, 0, 0) / 1000); ['MO', 'TU', 'WE', 'TH', 'FR'].forEach(day => slots[day].push({ start: tsAtTime(9, 0), end: tsAtTime(17, 0), })) } return new AppointmentConfig({ name: '', Loading
src/store/calendars.js +13 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import { const state = { calendars: [], trashBin: undefined, scheduleInbox: undefined, deletedCalendars: [], deletedCalendarObjects: [], calendarsById: {}, Loading Loading @@ -80,6 +81,10 @@ const mutations = { state.trashBin = trashBin }, addScheduleInbox(state, { scheduleInbox }) { state.scheduleInbox = scheduleInbox }, /** * Adds deleted calendar into state * Loading Loading @@ -412,6 +417,10 @@ const getters = { return state.trashBin }, scheduleInbox: (state) => { return state.scheduleInbox }, /** * List of deleted sorted calendars * Loading Loading @@ -546,7 +555,7 @@ const actions = { * @return {Promise<object>} the results */ async loadCollections({ commit, state, getters }) { const { calendars, trashBins } = await findAll() const { calendars, trashBins, scheduleInboxes } = await findAll() console.info('calendar home scanned', calendars, trashBins) calendars.map((calendar) => mapDavCollectionToCalendar(calendar, getters.getCurrentUserPrincipal)).forEach(calendar => { commit('addCalendar', { calendar }) Loading @@ -554,6 +563,9 @@ const actions = { if (trashBins.length) { commit('addTrashBin', { trashBin: trashBins[0] }) } if (scheduleInboxes.length) { commit('addScheduleInbox', { scheduleInbox: scheduleInboxes[0] }) } commit('initialCalendarsLoaded') return { Loading