fix(repeat): prevent disappearing repeat mode settings when modes other than default repeat mode were selected
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Resolves #3585
This commit is contained in:
parent
77bedbd1cf
commit
bd7d09c17c
|
@ -70,6 +70,7 @@ import {error} from '@/message'
|
||||||
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
|
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
|
||||||
import type {IRepeatAfter} from '@/types/IRepeatAfter'
|
import type {IRepeatAfter} from '@/types/IRepeatAfter'
|
||||||
import type {ITask} from '@/modelTypes/ITask'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
|
import TaskModel from '@/models/task'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -87,7 +88,7 @@ const {t} = useI18n({useScope: 'global'})
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
const task = ref<ITask>()
|
const task = ref<ITask>(new TaskModel())
|
||||||
const repeatAfter = reactive({
|
const repeatAfter = reactive({
|
||||||
amount: 0,
|
amount: 0,
|
||||||
type: '',
|
type: '',
|
||||||
|
@ -95,7 +96,7 @@ const repeatAfter = reactive({
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(value) => {
|
(value: ITask) => {
|
||||||
task.value = value
|
task.value = value
|
||||||
if (typeof value.repeatAfter !== 'undefined') {
|
if (typeof value.repeatAfter !== 'undefined') {
|
||||||
Object.assign(repeatAfter, value.repeatAfter)
|
Object.assign(repeatAfter, value.repeatAfter)
|
||||||
|
@ -105,11 +106,14 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
function updateData() {
|
function updateData() {
|
||||||
if (!task.value || task.value.repeatMode !== TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT && repeatAfter.amount === 0) {
|
if (!task.value ||
|
||||||
|
(task.value.repeatMode === TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT && repeatAfter.amount === 0) ||
|
||||||
|
(task.value.repeatMode === TASK_REPEAT_MODES.REPEAT_MODE_FROM_CURRENT_DATE && repeatAfter.amount === 0)
|
||||||
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repeatAfter.amount < 0) {
|
if (task.value.repeatMode === TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT && repeatAfter.amount < 0) {
|
||||||
error({message: t('task.repeat.invalidAmount')})
|
error({message: t('task.repeat.invalidAmount')})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@
|
||||||
{{ $t('task.attributes.repeat') }}
|
{{ $t('task.attributes.repeat') }}
|
||||||
</div>
|
</div>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@click="() => {task.repeatAfter.amount = 0;saveTask()}"
|
@click="removeRepeatAfter"
|
||||||
v-if="canWrite"
|
v-if="canWrite"
|
||||||
class="remove">
|
class="remove">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
|
@ -501,6 +501,7 @@ import {useTitle} from '@/composables/useTitle'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
import type {Action as MessageAction} from '@/message'
|
import type {Action as MessageAction} from '@/message'
|
||||||
import {useProjectStore} from '@/stores/projects'
|
import {useProjectStore} from '@/stores/projects'
|
||||||
|
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
taskId: {
|
taskId: {
|
||||||
|
@ -640,7 +641,7 @@ function setActiveFields() {
|
||||||
activeFields.priority = task.priority !== PRIORITIES.UNSET
|
activeFields.priority = task.priority !== PRIORITIES.UNSET
|
||||||
activeFields.relatedTasks = Object.keys(task.relatedTasks).length > 0
|
activeFields.relatedTasks = Object.keys(task.relatedTasks).length > 0
|
||||||
activeFields.reminders = task.reminders.length > 0
|
activeFields.reminders = task.reminders.length > 0
|
||||||
activeFields.repeatAfter = task.repeatAfter.amount > 0
|
activeFields.repeatAfter = task.repeatAfter?.amount > 0 || task.repeatMode !== TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT
|
||||||
activeFields.startDate = task.startDate !== null
|
activeFields.startDate = task.startDate !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,6 +780,12 @@ async function setPercentDone(percentDone: number) {
|
||||||
task: newTask,
|
task: newTask,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeRepeatAfter() {
|
||||||
|
task.repeatAfter.amount = 0
|
||||||
|
task.repeatMode = TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT
|
||||||
|
await saveTask()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Reference in New Issue
Block a user