Compare commits

...

3 Commits

Author SHA1 Message Date
Grigory Vodyanov fb6334d6f5 fixup! chore(calendarObjectsStore)!: Start migration to Pinia 2024-04-25 16:58:42 +02:00
Grigory Vodyanov 777f61f7b3 fixup! chore(calendarObjectsStore)!: Start migration to Pinia 2024-04-25 16:19:12 +02:00
Grigory Vodyanov 11b519bbd4 Revert "fixup! chore(calendarObjectsStore)!: Start migration to Pinia"
This reverts commit 65d9da72c3.
2024-04-25 12:58:05 +02:00
9 changed files with 844 additions and 1105 deletions

View File

@ -43,6 +43,9 @@ import AlarmListNew from './AlarmListNew.vue'
import AlarmListItem from './AlarmListItem.vue' import AlarmListItem from './AlarmListItem.vue'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default { export default {
name: 'AlarmList', name: 'AlarmList',
components: { components: {
@ -60,7 +63,8 @@ export default {
}, },
}, },
computed: { computed: {
...mapState({ ...mapStores(useCalendarObjectInstanceStore),
...mapState({
forceEventAlarmType: (state) => state.settings.forceEventAlarmType, forceEventAlarmType: (state) => state.settings.forceEventAlarmType,
}), }),
alarms() { alarms() {
@ -74,7 +78,7 @@ export default {
* @param {number} totalSeconds Amount of seconds for the alarm * @param {number} totalSeconds Amount of seconds for the alarm
*/ */
addAlarm(totalSeconds) { addAlarm(totalSeconds) {
this.$store.commit('addAlarmToCalendarObjectInstance', { this.calendarObjectInstanceStore.addAlarmToCalendarObjectInstance({
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
type: this.forceEventAlarmType || 'DISPLAY', type: this.forceEventAlarmType || 'DISPLAY',
totalSeconds, totalSeconds,
@ -86,7 +90,7 @@ export default {
* @param {object} alarm The alarm object * @param {object} alarm The alarm object
*/ */
removeAlarm(alarm) { removeAlarm(alarm) {
this.$store.commit('removeAlarmFromCalendarObjectInstance', { this.calendarObjectInstanceStore.removeAlarmFromCalendarObjectInstance({
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
alarm, alarm,
}) })

View File

@ -171,6 +171,9 @@ import Check from 'vue-material-design-icons/Check.vue'
import Delete from 'vue-material-design-icons/Delete.vue' import Delete from 'vue-material-design-icons/Delete.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue' import Pencil from 'vue-material-design-icons/Pencil.vue'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default { export default {
name: 'AlarmListItem', name: 'AlarmListItem',
components: { components: {
@ -217,6 +220,7 @@ export default {
} }
}, },
computed: { computed: {
...mapStores(useCalendarObjectInstanceStore),
...mapState({ ...mapState({
locale: (state) => state.settings.momentLocale, locale: (state) => state.settings.momentLocale,
forceEventAlarmType: (state) => state.settings.forceEventAlarmType, forceEventAlarmType: (state) => state.settings.forceEventAlarmType,
@ -337,8 +341,7 @@ export default {
* @param {string} type The new type of the notification * @param {string} type The new type of the notification
*/ */
changeType(type) { changeType(type) {
this.$store.commit('changeAlarmType', { this.calendarObjectInstanceStore.changeAlarmType({
calendarObjectInstance: this.calendarObjectInstance,
alarm: this.alarm, alarm: this.alarm,
type, type,
}) })
@ -457,8 +460,7 @@ export default {
* @param {Date} date The new date of the alarm * @param {Date} date The new date of the alarm
*/ */
changeAbsoluteDate(date) { changeAbsoluteDate(date) {
this.$store.commit('changeAlarmAbsoluteDate', { this.calendarObjectInstanceStore.changeAlarmAbsoluteDate({
calendarObjectInstance: this.calendarObjectInstance,
alarm: this.alarm, alarm: this.alarm,
date, date,
}) })
@ -469,8 +471,7 @@ export default {
* @param {string} timezoneId The new time zone id of the alarm * @param {string} timezoneId The new time zone id of the alarm
*/ */
changeAbsoluteTimezoneId(timezoneId) { changeAbsoluteTimezoneId(timezoneId) {
this.$store.commit('changeAlarmAbsoluteTimezoneId', { this.calendarObjectInstanceStore.changeAlarmAbsoluteTimezoneId({
calendarObjectInstance: this.calendarObjectInstance,
alarm: this.alarm, alarm: this.alarm,
timezoneId, timezoneId,
}) })

View File

@ -80,6 +80,7 @@ import {
} from '../../../services/attachmentService.js' } from '../../../services/attachmentService.js'
import { parseXML } from 'webdav' import { parseXML } from 'webdav'
import usePrincipalsStore from '../../../store/principals.js' import usePrincipalsStore from '../../../store/principals.js'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia' import { mapStores } from 'pinia'
export default { export default {
@ -95,7 +96,7 @@ export default {
Plus, Plus,
}, },
props: { props: {
...mapStores(usePrincipalsStore()), ...mapStores(usePrincipalsStore, useCalendarObjectInstanceStore),
calendarObjectInstance: { calendarObjectInstance: {
type: Object, type: Object,
required: true, required: true,
@ -120,13 +121,13 @@ export default {
}, },
methods: { methods: {
addAttachmentWithProperty(calendarObjectInstance, sharedData) { addAttachmentWithProperty(calendarObjectInstance, sharedData) {
this.$store.commit('addAttachmentWithProperty', { this.calendarObjectInstanceStore.addAttachmentWithProperty({
calendarObjectInstance, calendarObjectInstance,
sharedData, sharedData,
}) })
}, },
deleteAttachmentFromEvent(attachment) { deleteAttachmentFromEvent(attachment) {
this.$store.commit('deleteAttachment', { this.calendarObjectInstanceStore.deleteAttachment({
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
attachment, attachment,
}) })

View File

@ -65,8 +65,8 @@ import {
import CalendarQuestionIcon from 'vue-material-design-icons/CalendarQuestion.vue' import CalendarQuestionIcon from 'vue-material-design-icons/CalendarQuestion.vue'
import { showError, showSuccess } from '@nextcloud/dialogs' import { showError, showSuccess } from '@nextcloud/dialogs'
import logger from '../../utils/logger.js' import logger from '../../utils/logger.js'
import { mapStores } from 'pinia'
import useCalendarObjectInstanceStore from '../../store/calendarObjectInstance.js' import useCalendarObjectInstanceStore from '../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default { export default {
name: 'InvitationResponseButtons', name: 'InvitationResponseButtons',
@ -144,9 +144,10 @@ export default {
async setParticipationStatus(participationStatus) { async setParticipationStatus(participationStatus) {
this.loading = true this.loading = true
try { try {
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri).attendeeProperty.participationStatus = participationStatus this.calendarObjectInstanceStore.changeAttendeesParticipationStatus({
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri).participationStatus = participationStatus attendee: this.attendee,
participationStatus,
})
// TODO: What about recurring events? Add new buttons like "Accept this and all future"? // TODO: What about recurring events? Add new buttons like "Accept this and all future"?
// Currently, this will only accept a single occurrence. // Currently, this will only accept a single occurrence.
await this.$store.dispatch('saveCalendarObjectInstance', { await this.$store.dispatch('saveCalendarObjectInstance', {

View File

@ -115,10 +115,10 @@ import {
import { removeMailtoPrefix } from '../../../utils/attendee.js' import { removeMailtoPrefix } from '../../../utils/attendee.js'
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue' import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
import ChevronUp from 'vue-material-design-icons/ChevronUp.vue' import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import Delete from 'vue-material-design-icons/Delete.vue' import Delete from 'vue-material-design-icons/Delete.vue'
import { mapStores } from 'pinia'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js' import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default { export default {
name: 'InviteesListItem', name: 'InviteesListItem',
@ -220,13 +220,9 @@ export default {
* Toggles the RSVP flag of the attendee * Toggles the RSVP flag of the attendee
*/ */
toggleRSVP() { toggleRSVP() {
const oldRSVP = this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri) this.calendarObjectInstanceStore.toggleAttendeeRSVP({
.attendeeProperty.rsvp attendee: this.attendee,
})
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri)
.attendeeProperty.rsvp = !oldRSVP
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri)
.rsvp = !oldRSVP
}, },
/** /**
* Updates the role of the attendee * Updates the role of the attendee
@ -234,10 +230,10 @@ export default {
* @param {string} role The new role of the attendee * @param {string} role The new role of the attendee
*/ */
changeRole(role) { changeRole(role) {
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri) this.calendarObjectInstanceStore.changeAttendeesRole({
.attendeeProperty.role = role attendee: this.attendee,
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri) role,
.role = role })
}, },
/** /**
* Removes an attendee from the event * Removes an attendee from the event

View File

@ -101,6 +101,9 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import Check from 'vue-material-design-icons/Check.vue' import Check from 'vue-material-design-icons/Check.vue'
import { NcActions as Actions, NcActionButton as ActionButton } from '@nextcloud/vue' import { NcActions as Actions, NcActionButton as ActionButton } from '@nextcloud/vue'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default { export default {
name: 'Repeat', name: 'Repeat',
components: { components: {
@ -164,6 +167,7 @@ export default {
} }
}, },
computed: { computed: {
...mapStores(useCalendarObjectInstanceStore),
/** /**
* Whether or not this event is recurring * Whether or not this event is recurring
* *
@ -226,8 +230,7 @@ export default {
* @param {number} interval Any positive integer * @param {number} interval Any positive integer
*/ */
changeInterval(interval) { changeInterval(interval) {
this.$store.commit('changeRecurrenceInterval', { this.calendarObjectInstanceStore.changeRecurrenceInterval({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
interval, interval,
}) })
@ -239,8 +242,7 @@ export default {
* @param {string} frequency Allowed values: NONE, DAILY, WEEKLY, MONTHLY, YEARLY * @param {string} frequency Allowed values: NONE, DAILY, WEEKLY, MONTHLY, YEARLY
*/ */
changeFrequency(frequency) { changeFrequency(frequency) {
this.$store.dispatch('changeRecurrenceFrequency', { this.calendarObjectInstanceStore.changeRecurrenceFrequencyMutation({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
frequency, frequency,
}) })
@ -252,8 +254,7 @@ export default {
* @param {string} byDay Day to add * @param {string} byDay Day to add
*/ */
addByDay(byDay) { addByDay(byDay) {
this.$store.commit('addByDayToRecurrenceRule', { this.calendarObjectInstanceStore.addByDayToRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byDay, byDay,
}) })
@ -265,8 +266,7 @@ export default {
* @param {string} byDay Day to remove * @param {string} byDay Day to remove
*/ */
removeByDay(byDay) { removeByDay(byDay) {
this.$store.commit('removeByDayFromRecurrenceRule', { this.calendarObjectInstanceStore.removeByDayFromRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byDay, byDay,
}) })
@ -278,8 +278,7 @@ export default {
* @param {string} byMonthDay Month-day to add * @param {string} byMonthDay Month-day to add
*/ */
addByMonthDay(byMonthDay) { addByMonthDay(byMonthDay) {
this.$store.commit('addByMonthDayToRecurrenceRule', { this.calendarObjectInstanceStore.addByMonthDayToRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byMonthDay, byMonthDay,
}) })
@ -291,8 +290,7 @@ export default {
* @param {string} byMonthDay Month-day to remove * @param {string} byMonthDay Month-day to remove
*/ */
removeByMonthDay(byMonthDay) { removeByMonthDay(byMonthDay) {
this.$store.commit('removeByMonthDayFromRecurrenceRule', { this.calendarObjectInstanceStore.removeByMonthDayFromRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byMonthDay, byMonthDay,
}) })
@ -304,8 +302,7 @@ export default {
* @param {string} byMonth Month to add * @param {string} byMonth Month to add
*/ */
addByMonth(byMonth) { addByMonth(byMonth) {
this.$store.commit('addByMonthToRecurrenceRule', { this.calendarObjectInstanceStore.addByMonthToRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byMonth, byMonth,
}) })
@ -317,8 +314,7 @@ export default {
* @param {string} byMonth Month to remove * @param {string} byMonth Month to remove
*/ */
removeByMonth(byMonth) { removeByMonth(byMonth) {
this.$store.commit('removeByMonthFromRecurrenceRule', { this.calendarObjectInstanceStore.removeByMonthFromRecurrenceRule({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byMonth, byMonth,
}) })
@ -330,8 +326,7 @@ export default {
* @param {string[]} byDay The new by-day-list to use * @param {string[]} byDay The new by-day-list to use
*/ */
setByDay(byDay) { setByDay(byDay) {
this.$store.commit('changeRecurrenceByDay', { this.calendarObjectInstanceStore.changeRecurrenceByDay({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
byDay, byDay,
}) })
@ -345,8 +340,7 @@ export default {
* @param {number} bySetPosition The new By-set-position part to set * @param {number} bySetPosition The new By-set-position part to set
*/ */
setBySetPosition(bySetPosition) { setBySetPosition(bySetPosition) {
this.$store.commit('changeRecurrenceBySetPosition', { this.calendarObjectInstanceStore.changeRecurrenceBySetPosition({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
bySetPosition, bySetPosition,
}) })
@ -422,8 +416,7 @@ export default {
* @param {Date} until Date to set as new end of recurrence-set * @param {Date} until Date to set as new end of recurrence-set
*/ */
setUntil(until) { setUntil(until) {
this.$store.commit('changeRecurrenceUntil', { this.calendarObjectInstance.changeRecurrenceUntil({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
until, until,
}) })
@ -445,8 +438,7 @@ export default {
* @param {number} count New number of recurrences to set * @param {number} count New number of recurrences to set
*/ */
setCount(count) { setCount(count) {
this.$store.commit('changeRecurrenceCount', { this.calendarObjectInstance.changeRecurrenceCount({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
count, count,
}) })
@ -457,8 +449,7 @@ export default {
*/ */
modified() { modified() {
if (this.recurrenceRule.isUnsupported) { if (this.recurrenceRule.isUnsupported) {
this.$store.commit('markRecurrenceRuleAsSupported', { this.calendarObjectInstanceStore.markRecurrenceRuleAsSupported({
calendarObjectInstance: this.calendarObjectInstance,
recurrenceRule: this.recurrenceRule, recurrenceRule: this.recurrenceRule,
}) })
} }

View File

@ -719,7 +719,9 @@ export default {
// Probably not though, because it's async // Probably not though, because it's async
try { try {
await vm.loadingCalendars() await vm.loadingCalendars()
const recurrenceId = await vm.$store.dispatch('resolveClosestRecurrenceIdForCalendarObject', { objectId, closeToDate }) const recurrenceId = await this.calendarObjectInstanceStore.resolveClosestRecurrenceIdForCalendarObject({
objectId, closeToDate
})
const params = Object.assign({}, vm.$route.params, { recurrenceId }) const params = Object.assign({}, vm.$route.params, { recurrenceId })
vm.$router.replace({ name: vm.$route.name, params }) vm.$router.replace({ name: vm.$route.name, params })
} catch (error) { } catch (error) {
@ -803,7 +805,9 @@ export default {
if (recurrenceId === 'next') { if (recurrenceId === 'next') {
const closeToDate = dateFactory() const closeToDate = dateFactory()
await this.loadingCalendars() await this.loadingCalendars()
const recurrenceId = await this.$store.dispatch('resolveClosestRecurrenceIdForCalendarObject', { objectId, closeToDate }) const recurrenceId = await this.calendarObjectInstanceStore.resolveClosestRecurrenceIdForCalendarObject({
objectId, closeToDate
})
const params = Object.assign({}, this.$route.params, { recurrenceId }) const params = Object.assign({}, this.$route.params, { recurrenceId })
next({ name: this.$route.name, params }) next({ name: this.$route.name, params })
return return

File diff suppressed because it is too large Load Diff

View File

@ -477,10 +477,8 @@ export default {
* @param {string} category Category to add * @param {string} category Category to add
*/ */
addCategory(category) { addCategory(category) {
this.$store.commit('addCategory', { this.calendarObjectInstance.eventComponent.addCategory(category)
calendarObjectInstance: this.calendarObjectInstance, this.calendarObjectInstance.categories.push(category)
category,
})
}, },
/** /**
* Removes a category from the event * Removes a category from the event
@ -488,10 +486,12 @@ export default {
* @param {string} category Category to remove * @param {string} category Category to remove
*/ */
removeCategory(category) { removeCategory(category) {
this.$store.commit('removeCategory', { this.calendarObjectInstance.eventComponent.removeCategory(category)
calendarObjectInstance: this.calendarObjectInstance,
category, const index = this.calendarObjectInstance.categories.indexOf(category)
}) if (index !== -1) {
this.calendarObjectInstance.categories.splice(index, 1)
}
}, },
/** /**
* Updates the color of the event * Updates the color of the event