Add vuex mutation and commit
This commit is contained in:
parent
7e763197f1
commit
2c6314e7cc
|
@ -125,12 +125,15 @@ export default {
|
|||
},
|
||||
changeFrequency(value) {
|
||||
this.frequency = value
|
||||
// this.newValue = this.value.copy(interval = value)
|
||||
// TODO: There should be a better way than using structuredClone
|
||||
this.newValue = structuredClone(this.value)
|
||||
this.newValue.frequency = value
|
||||
},
|
||||
changeInterval(value) {
|
||||
logger.info('change Interval to ' + value)
|
||||
this.interval = value
|
||||
// this.newValue = this.value.copy(interval = value)
|
||||
this.newValue = structuredClone(this.value)
|
||||
this.newValue.interval = value
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
type="number"
|
||||
min="1"
|
||||
max="366"
|
||||
@input="$emit('update:interval', $event.target.value)">
|
||||
@input="$emit('change-interval', $event.target.value)">
|
||||
<RepeatFreqSelect :freq="frequency"
|
||||
:count="interval"
|
||||
@change="changeFrequency" />
|
||||
|
@ -53,7 +53,7 @@ export default {
|
|||
required: true,
|
||||
},
|
||||
},
|
||||
emits: ['update:frequency', 'update:interval'],
|
||||
emits: ['change-frequency', 'change-interval'],
|
||||
computed: {
|
||||
repeatEveryLabel() {
|
||||
if (this.frequency === 'NONE') {
|
||||
|
@ -67,7 +67,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
changeFrequency(value) {
|
||||
this.$emit('update:frequency', value)
|
||||
this.$emit('change-frequency', value)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ export default class Task {
|
|||
this.vtodo = new ICAL.Component('vtodo')
|
||||
this.vCalendar.addSubcomponent(this.vtodo)
|
||||
}
|
||||
|
||||
// From NC calendar-js
|
||||
this.todoComponent = ToDoComponent.fromICALJs(this.vtodo)
|
||||
|
||||
if (!this.vtodo.hasProperty('uid')) {
|
||||
|
@ -333,18 +335,36 @@ export default class Task {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the recurrence
|
||||
* Get the recurrence
|
||||
*
|
||||
* @readonly
|
||||
* @memberof Task
|
||||
*/
|
||||
get recurrenceRule() {
|
||||
get recurrenceRuleObject() {
|
||||
if (this._recurrence === undefined || this._recurrence === null) {
|
||||
return getDefaultRecurrenceRuleObject()
|
||||
}
|
||||
return mapRecurrenceRuleValueToRecurrenceRuleObject(this._recurrence.getFirstValue(), this._start)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the recurrence
|
||||
*
|
||||
* @readonly
|
||||
* @memberof Task
|
||||
*/
|
||||
set recurrenceRuleObject(rruleObject) {
|
||||
if (rruleObject === null) {
|
||||
this.vtodo.removeProperty('rrule')
|
||||
} else {
|
||||
// FIXME: rruleObject.recurrenceRuleValue should not be null
|
||||
this.vtodo.updatePropertyWithValue('rrule', rruleObject.recurrenceRuleValue)
|
||||
}
|
||||
this.todoComponent = ToDoComponent.fromICALJs(this.vtodo)
|
||||
this._recurrence = this.todoComponent.getPropertyIterator('RRULE').next().value
|
||||
this.updateLastModified()
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this task repeats
|
||||
*
|
||||
|
@ -754,7 +774,7 @@ export default class Task {
|
|||
*/
|
||||
completeRecurring() {
|
||||
// Get recurrence iterator, starting at start date
|
||||
const iter = this.recurrenceRule.iterator(this.start)
|
||||
const iter = this.recurrenceRuleObject.iterator(this.start)
|
||||
// Skip the start date itself
|
||||
iter.next()
|
||||
// If there is a next recurrence, update the start date to next recurrence date
|
||||
|
|
|
@ -495,6 +495,18 @@ const mutations = {
|
|||
task.location = location
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the recurrence rule of a task
|
||||
*
|
||||
* @param {object} state The store data
|
||||
* @param {object} data Destructuring object
|
||||
* @param {Task} data.task The task
|
||||
* @param {string} data.rruleObject The recurrence rule object from NC calendar-js
|
||||
*/
|
||||
setRecurrence(state, { task, rruleObject }) {
|
||||
task.recurrenceRuleObject = rruleObject
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the url of a task
|
||||
*
|
||||
|
@ -1232,6 +1244,20 @@ const actions = {
|
|||
context.dispatch('updateTask', task)
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the location of a task
|
||||
*
|
||||
* @param {object} context The store context
|
||||
* @param {Task} task The task to update
|
||||
*/
|
||||
async setRecurrence(context, { task, rruleObject }) {
|
||||
if (rruleObject === task.recurrenceRuleObject) {
|
||||
return
|
||||
}
|
||||
context.commit('setRecurrence', { task, rruleObject })
|
||||
context.dispatch('updateTask', task)
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the URL of a task
|
||||
*
|
||||
|
|
|
@ -261,12 +261,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
<template #icon>
|
||||
<Repeat :size="20" />
|
||||
</template>
|
||||
<RepeatItem :value="task.recurrenceRule"
|
||||
<RepeatItem :value="task.recurrenceRuleObject"
|
||||
:disabled="readOnly"
|
||||
:read-only="readOnly"
|
||||
:placeholder="t('tasks', 'No recurrence')"
|
||||
:task="task"
|
||||
icon="IconRepeat" />
|
||||
icon="IconRepeat"
|
||||
@set-value="({task, value}) => setRecurrence({ task, rruleObject: value })" />
|
||||
</NcAppSidebarTab>
|
||||
</NcAppSidebar>
|
||||
</template>
|
||||
|
@ -724,6 +725,7 @@ export default {
|
|||
'setNote',
|
||||
'setPriority',
|
||||
'setLocation',
|
||||
'setRecurrence',
|
||||
'setUrl',
|
||||
'setPercentComplete',
|
||||
'setTags',
|
||||
|
|
Loading…
Reference in New Issue