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 { mapState } from 'vuex'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'AlarmList',
components: {
@ -60,7 +63,8 @@ export default {
},
},
computed: {
...mapState({
...mapStores(useCalendarObjectInstanceStore),
...mapState({
forceEventAlarmType: (state) => state.settings.forceEventAlarmType,
}),
alarms() {
@ -74,7 +78,7 @@ export default {
* @param {number} totalSeconds Amount of seconds for the alarm
*/
addAlarm(totalSeconds) {
this.$store.commit('addAlarmToCalendarObjectInstance', {
this.calendarObjectInstanceStore.addAlarmToCalendarObjectInstance({
calendarObjectInstance: this.calendarObjectInstance,
type: this.forceEventAlarmType || 'DISPLAY',
totalSeconds,
@ -86,7 +90,7 @@ export default {
* @param {object} alarm The alarm object
*/
removeAlarm(alarm) {
this.$store.commit('removeAlarmFromCalendarObjectInstance', {
this.calendarObjectInstanceStore.removeAlarmFromCalendarObjectInstance({
calendarObjectInstance: this.calendarObjectInstance,
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 Pencil from 'vue-material-design-icons/Pencil.vue'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'AlarmListItem',
components: {
@ -217,6 +220,7 @@ export default {
}
},
computed: {
...mapStores(useCalendarObjectInstanceStore),
...mapState({
locale: (state) => state.settings.momentLocale,
forceEventAlarmType: (state) => state.settings.forceEventAlarmType,
@ -337,8 +341,7 @@ export default {
* @param {string} type The new type of the notification
*/
changeType(type) {
this.$store.commit('changeAlarmType', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeAlarmType({
alarm: this.alarm,
type,
})
@ -457,8 +460,7 @@ export default {
* @param {Date} date The new date of the alarm
*/
changeAbsoluteDate(date) {
this.$store.commit('changeAlarmAbsoluteDate', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeAlarmAbsoluteDate({
alarm: this.alarm,
date,
})
@ -469,8 +471,7 @@ export default {
* @param {string} timezoneId The new time zone id of the alarm
*/
changeAbsoluteTimezoneId(timezoneId) {
this.$store.commit('changeAlarmAbsoluteTimezoneId', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeAlarmAbsoluteTimezoneId({
alarm: this.alarm,
timezoneId,
})

View File

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

View File

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

View File

@ -115,10 +115,10 @@ import {
import { removeMailtoPrefix } from '../../../utils/attendee.js'
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import { mapStores } from 'pinia'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'InviteesListItem',
@ -220,13 +220,9 @@ export default {
* Toggles the RSVP flag of the attendee
*/
toggleRSVP() {
const oldRSVP = this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri)
.attendeeProperty.rsvp
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
this.calendarObjectInstanceStore.toggleAttendeeRSVP({
attendee: this.attendee,
})
},
/**
* Updates the role of the attendee
@ -234,10 +230,10 @@ export default {
* @param {string} role The new role of the attendee
*/
changeRole(role) {
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri)
.attendeeProperty.role = role
this.calendarObjectInstanceStore.calendarObjectInstance.attendees.where((attendee) => attendee.uri === this.attendee.uri)
.role = role
this.calendarObjectInstanceStore.changeAttendeesRole({
attendee: this.attendee,
role,
})
},
/**
* 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 { NcActions as Actions, NcActionButton as ActionButton } from '@nextcloud/vue'
import useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'Repeat',
components: {
@ -164,6 +167,7 @@ export default {
}
},
computed: {
...mapStores(useCalendarObjectInstanceStore),
/**
* Whether or not this event is recurring
*
@ -226,8 +230,7 @@ export default {
* @param {number} interval Any positive integer
*/
changeInterval(interval) {
this.$store.commit('changeRecurrenceInterval', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeRecurrenceInterval({
recurrenceRule: this.recurrenceRule,
interval,
})
@ -239,8 +242,7 @@ export default {
* @param {string} frequency Allowed values: NONE, DAILY, WEEKLY, MONTHLY, YEARLY
*/
changeFrequency(frequency) {
this.$store.dispatch('changeRecurrenceFrequency', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeRecurrenceFrequencyMutation({
recurrenceRule: this.recurrenceRule,
frequency,
})
@ -252,8 +254,7 @@ export default {
* @param {string} byDay Day to add
*/
addByDay(byDay) {
this.$store.commit('addByDayToRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.addByDayToRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byDay,
})
@ -265,8 +266,7 @@ export default {
* @param {string} byDay Day to remove
*/
removeByDay(byDay) {
this.$store.commit('removeByDayFromRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.removeByDayFromRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byDay,
})
@ -278,8 +278,7 @@ export default {
* @param {string} byMonthDay Month-day to add
*/
addByMonthDay(byMonthDay) {
this.$store.commit('addByMonthDayToRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.addByMonthDayToRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byMonthDay,
})
@ -291,8 +290,7 @@ export default {
* @param {string} byMonthDay Month-day to remove
*/
removeByMonthDay(byMonthDay) {
this.$store.commit('removeByMonthDayFromRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.removeByMonthDayFromRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byMonthDay,
})
@ -304,8 +302,7 @@ export default {
* @param {string} byMonth Month to add
*/
addByMonth(byMonth) {
this.$store.commit('addByMonthToRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.addByMonthToRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byMonth,
})
@ -317,8 +314,7 @@ export default {
* @param {string} byMonth Month to remove
*/
removeByMonth(byMonth) {
this.$store.commit('removeByMonthFromRecurrenceRule', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.removeByMonthFromRecurrenceRule({
recurrenceRule: this.recurrenceRule,
byMonth,
})
@ -330,8 +326,7 @@ export default {
* @param {string[]} byDay The new by-day-list to use
*/
setByDay(byDay) {
this.$store.commit('changeRecurrenceByDay', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeRecurrenceByDay({
recurrenceRule: this.recurrenceRule,
byDay,
})
@ -345,8 +340,7 @@ export default {
* @param {number} bySetPosition The new By-set-position part to set
*/
setBySetPosition(bySetPosition) {
this.$store.commit('changeRecurrenceBySetPosition', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.changeRecurrenceBySetPosition({
recurrenceRule: this.recurrenceRule,
bySetPosition,
})
@ -422,8 +416,7 @@ export default {
* @param {Date} until Date to set as new end of recurrence-set
*/
setUntil(until) {
this.$store.commit('changeRecurrenceUntil', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstance.changeRecurrenceUntil({
recurrenceRule: this.recurrenceRule,
until,
})
@ -445,8 +438,7 @@ export default {
* @param {number} count New number of recurrences to set
*/
setCount(count) {
this.$store.commit('changeRecurrenceCount', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstance.changeRecurrenceCount({
recurrenceRule: this.recurrenceRule,
count,
})
@ -457,8 +449,7 @@ export default {
*/
modified() {
if (this.recurrenceRule.isUnsupported) {
this.$store.commit('markRecurrenceRuleAsSupported', {
calendarObjectInstance: this.calendarObjectInstance,
this.calendarObjectInstanceStore.markRecurrenceRuleAsSupported({
recurrenceRule: this.recurrenceRule,
})
}

View File

@ -719,7 +719,9 @@ export default {
// Probably not though, because it's async
try {
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 })
vm.$router.replace({ name: vm.$route.name, params })
} catch (error) {
@ -803,7 +805,9 @@ export default {
if (recurrenceId === 'next') {
const closeToDate = dateFactory()
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 })
next({ name: this.$route.name, params })
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
*/
addCategory(category) {
this.$store.commit('addCategory', {
calendarObjectInstance: this.calendarObjectInstance,
category,
})
this.calendarObjectInstance.eventComponent.addCategory(category)
this.calendarObjectInstance.categories.push(category)
},
/**
* Removes a category from the event
@ -488,10 +486,12 @@ export default {
* @param {string} category Category to remove
*/
removeCategory(category) {
this.$store.commit('removeCategory', {
calendarObjectInstance: this.calendarObjectInstance,
category,
})
this.calendarObjectInstance.eventComponent.removeCategory(category)
const index = this.calendarObjectInstance.categories.indexOf(category)
if (index !== -1) {
this.calendarObjectInstance.categories.splice(index, 1)
}
},
/**
* Updates the color of the event