fixup! chore(calendarObjectsStore)!: Start migration to Pinia

This commit is contained in:
Grigory Vodyanov 2024-04-25 16:19:12 +02:00
parent 11b519bbd4
commit 777f61f7b3
8 changed files with 820 additions and 1062 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,6 +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 useCalendarObjectInstanceStore from '../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'InvitationResponseButtons',
@ -91,18 +93,18 @@ export default {
data() {
return {
loading: false,
attendeeCopy: this.attendee,
}
},
computed: {
...mapStores(useCalendarObjectInstanceStore),
isAccepted() {
return this.attendeeCopy.participationStatus === 'ACCEPTED'
return this.attendee.participationStatus === 'ACCEPTED'
},
isDeclined() {
return this.attendeeCopy.participationStatus === 'DECLINED'
return this.attendee.participationStatus === 'DECLINED'
},
isTentative() {
return this.attendeeCopy.participationStatus === 'TENTATIVE'
return this.attendee.participationStatus === 'TENTATIVE'
},
},
methods: {
@ -142,8 +144,10 @@ export default {
async setParticipationStatus(participationStatus) {
this.loading = true
try {
this.attendeeCopy.attendeeProperty.participationStatus = participationStatus
this.attendeeCopy.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,9 +115,11 @@ 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 useCalendarObjectInstanceStore from '../../../store/calendarObjectInstance.js'
import { mapStores } from 'pinia'
export default {
name: 'InviteesListItem',
components: {
@ -156,6 +158,7 @@ export default {
}
},
computed: {
...mapStores(useCalendarObjectInstanceStore),
/**
* @return {string}
*/
@ -217,7 +220,7 @@ export default {
* Toggles the RSVP flag of the attendee
*/
toggleRSVP() {
this.$store.commit('toggleAttendeeRSVP', {
this.calendarObjectInstanceStore.toggleAttendeeRSVP({
attendee: this.attendee,
})
},
@ -227,7 +230,7 @@ export default {
* @param {string} role The new role of the attendee
*/
changeRole(role) {
this.$store.commit('changeAttendeesRole', {
this.calendarObjectInstanceStore.changeAttendeesRole({
attendee: this.attendee,
role,
})

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,
})
}

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