feat(ui) : add Planification tab to TaskModal with dates, calendar sync, and recurrence
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
|
||||
<!-- Modal -->
|
||||
<div
|
||||
class="relative z-10 flex w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl ring-1 ring-black/5"
|
||||
class="relative z-10 flex w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl ring-1 ring-black/5 dark:bg-dark-surface dark:ring-dark-border"
|
||||
style="max-height: min(90vh, 900px)"
|
||||
>
|
||||
<!-- Header -->
|
||||
<div class="border-b border-neutral-100 bg-neutral-50/80 px-4 py-4 sm:px-8 sm:py-5">
|
||||
<div class="border-b border-neutral-100 bg-neutral-50/80 px-4 py-4 sm:px-8 sm:py-5 dark:border-dark-border dark:bg-dark-surface/80">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<span
|
||||
@@ -23,13 +23,13 @@
|
||||
>
|
||||
{{ task.project.code }}-{{ task.number }}
|
||||
</span>
|
||||
<h2 class="text-lg font-bold tracking-tight text-neutral-900">
|
||||
<h2 class="text-lg font-bold tracking-tight text-neutral-900 dark:text-neutral-100">
|
||||
{{ isEditing ? $t('tasks.editTask') : $t('tasks.addTask') }}
|
||||
</h2>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-8 w-8 items-center justify-center rounded-lg text-neutral-400 transition-colors hover:bg-neutral-200/60 hover:text-neutral-600"
|
||||
class="flex h-8 w-8 items-center justify-center rounded-lg text-neutral-400 transition-colors hover:bg-neutral-200/60 hover:text-neutral-600 dark:hover:bg-dark-hover dark:hover:text-neutral-200"
|
||||
@click="close"
|
||||
>
|
||||
<Icon name="mdi:close" size="20" />
|
||||
@@ -56,6 +56,25 @@
|
||||
|
||||
<!-- Body -->
|
||||
<form @submit.prevent="handleSubmit" class="overflow-y-auto px-4 py-4 sm:px-8 sm:py-6">
|
||||
<!-- Tabs -->
|
||||
<div class="border-b border-neutral-100 -mx-4 px-4 sm:-mx-8 sm:px-8 mb-4">
|
||||
<nav class="flex gap-6">
|
||||
<button
|
||||
v-for="tab in ['details', 'planning']"
|
||||
:key="tab"
|
||||
type="button"
|
||||
class="px-1 pb-3 text-sm font-semibold transition"
|
||||
:class="activeTab === tab
|
||||
? 'border-b-2 border-primary-500 text-primary-500'
|
||||
: 'text-neutral-500 hover:text-neutral-700'"
|
||||
@click="activeTab = tab as 'details' | 'planning'"
|
||||
>
|
||||
{{ $t(`tasks.${tab}Tab`) }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 'details'">
|
||||
<!-- Title -->
|
||||
<MalioInputText
|
||||
v-model="form.title"
|
||||
@@ -128,7 +147,7 @@
|
||||
|
||||
<!-- Tags -->
|
||||
<div v-if="tags.length" class="mt-5">
|
||||
<p class="mb-2 text-sm font-medium text-neutral-700">Tags</p>
|
||||
<p class="mb-2 text-sm font-medium text-neutral-700 dark:text-neutral-300">Tags</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label
|
||||
v-for="tag in tags"
|
||||
@@ -136,7 +155,7 @@
|
||||
class="cursor-pointer rounded-full px-3 py-1 text-xs font-semibold transition-all"
|
||||
:class="form.tagIds.includes(tag.id)
|
||||
? 'text-white shadow-sm'
|
||||
: 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200'"
|
||||
: 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200 dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-600'"
|
||||
:style="form.tagIds.includes(tag.id) ? { backgroundColor: tag.color } : {}"
|
||||
>
|
||||
<input
|
||||
@@ -201,10 +220,197 @@
|
||||
v-if="hasBookStack && isEditing && task"
|
||||
:task-id="task.id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 'planning'" class="space-y-6">
|
||||
<!-- Dates section -->
|
||||
<div>
|
||||
<h3 class="mb-3 text-sm font-semibold text-neutral-700">{{ $t('tasks.planning.dates') }}</h3>
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<MalioInputText
|
||||
v-model="form.scheduledStart"
|
||||
:label="$t('tasks.planning.scheduledStart')"
|
||||
type="datetime-local"
|
||||
input-class="w-full"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="form.scheduledEnd"
|
||||
:label="$t('tasks.planning.scheduledEnd')"
|
||||
type="datetime-local"
|
||||
input-class="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<MalioInputText
|
||||
v-model="form.deadline"
|
||||
:label="$t('tasks.planning.deadline')"
|
||||
type="date"
|
||||
input-class="w-full sm:w-1/2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Calendar sync -->
|
||||
<div class="rounded-lg border border-neutral-200 p-4">
|
||||
<h3 class="mb-3 text-sm font-semibold text-neutral-700">{{ $t('tasks.planning.calendar') }}</h3>
|
||||
<label class="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
v-model="form.syncToCalendar"
|
||||
type="checkbox"
|
||||
class="rounded border-neutral-300"
|
||||
/>
|
||||
<span class="text-sm">{{ $t('tasks.planning.syncToCalendar') }}</span>
|
||||
</label>
|
||||
<div v-if="isEditing && task?.syncToCalendar" class="mt-3 flex items-center gap-2">
|
||||
<Icon
|
||||
:name="task.calendarSyncError ? 'mdi:alert-circle' : 'mdi:check-circle'"
|
||||
:class="task.calendarSyncError ? 'text-red-500' : 'text-green-500'"
|
||||
size="18"
|
||||
/>
|
||||
<span class="text-xs" :class="task.calendarSyncError ? 'text-red-600' : 'text-green-600'">
|
||||
{{ task.calendarSyncError || $t('tasks.planning.syncOk') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recurrence -->
|
||||
<div class="rounded-lg border border-neutral-200 p-4">
|
||||
<h3 class="mb-3 text-sm font-semibold text-neutral-700">{{ $t('tasks.planning.recurrence') }}</h3>
|
||||
<label class="flex items-center gap-3 cursor-pointer">
|
||||
<input
|
||||
v-model="form.isRecurring"
|
||||
type="checkbox"
|
||||
class="rounded border-neutral-300"
|
||||
/>
|
||||
<span class="text-sm">{{ $t('tasks.planning.isRecurring') }}</span>
|
||||
</label>
|
||||
|
||||
<div v-if="form.isRecurring" class="mt-4 space-y-4">
|
||||
<!-- Type -->
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">{{ $t('tasks.planning.type') }}</label>
|
||||
<select v-model="form.recurrenceType" class="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm">
|
||||
<option value="daily">{{ $t('tasks.planning.daily') }}</option>
|
||||
<option value="weekly">{{ $t('tasks.planning.weekly') }}</option>
|
||||
<option value="monthly">{{ $t('tasks.planning.monthly') }}</option>
|
||||
<option value="yearly">{{ $t('tasks.planning.yearly') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Interval -->
|
||||
<MalioInputText
|
||||
v-model="form.recurrenceInterval"
|
||||
:label="$t('tasks.planning.interval')"
|
||||
type="number"
|
||||
input-class="w-full sm:w-1/3"
|
||||
min="1"
|
||||
max="100"
|
||||
/>
|
||||
|
||||
<!-- Weekly: days of week -->
|
||||
<div v-if="form.recurrenceType === 'weekly'">
|
||||
<p class="mb-2 text-sm font-medium text-neutral-700">{{ $t('tasks.planning.daysOfWeek') }}</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label
|
||||
v-for="day in weekDays"
|
||||
:key="day.value"
|
||||
class="cursor-pointer rounded-full px-3 py-1 text-xs font-semibold transition-all"
|
||||
:class="form.recurrenceDaysOfWeek.includes(day.value)
|
||||
? 'bg-primary-500 text-white'
|
||||
: 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200'"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="hidden"
|
||||
:value="day.value"
|
||||
:checked="form.recurrenceDaysOfWeek.includes(day.value)"
|
||||
@change="toggleDay(day.value)"
|
||||
/>
|
||||
{{ day.label }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Monthly options -->
|
||||
<div v-if="form.recurrenceType === 'monthly'" class="space-y-3">
|
||||
<div class="flex gap-4">
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
<input v-model="form.monthlyMode" value="dayOfMonth" type="radio" />
|
||||
{{ $t('tasks.planning.dayOfMonth') }}
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
<input v-model="form.monthlyMode" value="weekOfMonth" type="radio" />
|
||||
{{ $t('tasks.planning.weekOfMonth') }}
|
||||
</label>
|
||||
</div>
|
||||
<MalioInputText
|
||||
v-if="form.monthlyMode === 'dayOfMonth'"
|
||||
v-model="form.recurrenceDayOfMonth"
|
||||
:label="$t('tasks.planning.dayOfMonthLabel')"
|
||||
type="number"
|
||||
input-class="w-full sm:w-1/3"
|
||||
min="1"
|
||||
max="31"
|
||||
/>
|
||||
<div v-if="form.monthlyMode === 'weekOfMonth'" class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">{{ $t('tasks.planning.weekOfMonthLabel') }}</label>
|
||||
<select v-model="form.recurrenceWeekOfMonth" class="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm">
|
||||
<option :value="1">1er</option>
|
||||
<option :value="2">2ème</option>
|
||||
<option :value="3">3ème</option>
|
||||
<option :value="4">4ème</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">{{ $t('tasks.planning.dayLabel') }}</label>
|
||||
<select v-model="form.recurrenceWeekDay" class="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm">
|
||||
<option v-for="day in weekDays" :key="day.value" :value="day.value">{{ day.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- End of recurrence -->
|
||||
<div class="space-y-3">
|
||||
<p class="text-sm font-medium text-neutral-700">{{ $t('tasks.planning.endRecurrence') }}</p>
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
<input v-model="form.recurrenceEnd" value="never" type="radio" />
|
||||
{{ $t('tasks.planning.neverEnds') }}
|
||||
</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
<input v-model="form.recurrenceEnd" value="occurrences" type="radio" />
|
||||
{{ $t('tasks.planning.afterOccurrences') }}
|
||||
</label>
|
||||
<MalioInputText
|
||||
v-if="form.recurrenceEnd === 'occurrences'"
|
||||
v-model="form.recurrenceMaxOccurrences"
|
||||
type="number"
|
||||
input-class="w-20"
|
||||
min="1"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
<input v-model="form.recurrenceEnd" value="date" type="radio" />
|
||||
{{ $t('tasks.planning.onDate') }}
|
||||
</label>
|
||||
<MalioInputText
|
||||
v-if="form.recurrenceEnd === 'date'"
|
||||
v-model="form.recurrenceEndDate"
|
||||
type="date"
|
||||
input-class="w-44"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div
|
||||
class="mt-6 flex items-center border-t border-neutral-100 pt-5"
|
||||
class="mt-6 flex items-center border-t border-neutral-100 pt-5 dark:border-dark-border"
|
||||
:class="isEditing ? 'justify-between' : 'justify-end'"
|
||||
>
|
||||
<button
|
||||
@@ -220,7 +426,7 @@
|
||||
<button
|
||||
v-if="canArchive"
|
||||
type="button"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-dark-border dark:text-neutral-300 dark:hover:bg-dark-hover"
|
||||
:disabled="isSubmitting"
|
||||
@click="handleArchive"
|
||||
>
|
||||
@@ -229,7 +435,7 @@
|
||||
<button
|
||||
v-if="canUnarchive"
|
||||
type="button"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-dark-border dark:text-neutral-300 dark:hover:bg-dark-hover"
|
||||
:disabled="isSubmitting"
|
||||
@click="handleUnarchive"
|
||||
>
|
||||
@@ -237,7 +443,7 @@
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50"
|
||||
class="rounded-lg border border-neutral-300 px-4 py-2 text-sm font-semibold text-neutral-700 transition-colors hover:bg-neutral-50 dark:border-dark-border dark:text-neutral-300 dark:hover:bg-dark-hover"
|
||||
@click="close"
|
||||
>
|
||||
Annuler
|
||||
@@ -284,6 +490,7 @@ import type { TaskTag } from '~/services/dto/task-tag'
|
||||
import type { TaskGroup } from '~/services/dto/task-group'
|
||||
import type { UserData } from '~/services/dto/user-data'
|
||||
import { useTaskService } from '~/services/tasks'
|
||||
import { useTaskRecurrenceService } from '~/services/task-recurrences'
|
||||
|
||||
import type { Project } from '~/services/dto/project'
|
||||
|
||||
@@ -318,6 +525,7 @@ function close() {
|
||||
const isEditing = computed(() => !!props.task)
|
||||
const isSubmitting = ref(false)
|
||||
const confirmDeleteOpen = ref(false)
|
||||
const activeTab = ref<'details' | 'planning'>('details')
|
||||
|
||||
const giteaUrl = ref('')
|
||||
const { getSettings: getGiteaSettings } = useGiteaService()
|
||||
@@ -341,6 +549,21 @@ const form = reactive({
|
||||
tagIds: [] as number[],
|
||||
clientTicketId: null as number | null,
|
||||
projectId: null as number | null,
|
||||
scheduledStart: '',
|
||||
scheduledEnd: '',
|
||||
deadline: '',
|
||||
syncToCalendar: false,
|
||||
isRecurring: false,
|
||||
recurrenceType: 'daily' as string,
|
||||
recurrenceInterval: '1',
|
||||
recurrenceDaysOfWeek: [] as string[],
|
||||
recurrenceDayOfMonth: '',
|
||||
monthlyMode: 'dayOfMonth' as string,
|
||||
recurrenceWeekOfMonth: 1,
|
||||
recurrenceWeekDay: 'monday' as string,
|
||||
recurrenceEnd: 'never' as string,
|
||||
recurrenceMaxOccurrences: '',
|
||||
recurrenceEndDate: '',
|
||||
})
|
||||
|
||||
const touched = reactive({
|
||||
@@ -402,6 +625,22 @@ function toggleTag(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
const weekDays = computed(() => [
|
||||
{ value: 'monday', label: t('tasks.planning.days.mon') },
|
||||
{ value: 'tuesday', label: t('tasks.planning.days.tue') },
|
||||
{ value: 'wednesday', label: t('tasks.planning.days.wed') },
|
||||
{ value: 'thursday', label: t('tasks.planning.days.thu') },
|
||||
{ value: 'friday', label: t('tasks.planning.days.fri') },
|
||||
{ value: 'saturday', label: t('tasks.planning.days.sat') },
|
||||
{ value: 'sunday', label: t('tasks.planning.days.sun') },
|
||||
])
|
||||
|
||||
function toggleDay(day: string) {
|
||||
const idx = form.recurrenceDaysOfWeek.indexOf(day)
|
||||
if (idx >= 0) form.recurrenceDaysOfWeek.splice(idx, 1)
|
||||
else form.recurrenceDaysOfWeek.push(day)
|
||||
}
|
||||
|
||||
function populateForm(task: Task | null) {
|
||||
if (task) {
|
||||
form.title = task.title ?? ''
|
||||
@@ -413,6 +652,42 @@ function populateForm(task: Task | null) {
|
||||
form.groupId = task.group?.id ?? null
|
||||
form.tagIds = task.tags.map(t => t.id)
|
||||
form.clientTicketId = task.clientTicket?.id ?? null
|
||||
form.scheduledStart = task.scheduledStart ? task.scheduledStart.slice(0, 16) : ''
|
||||
form.scheduledEnd = task.scheduledEnd ? task.scheduledEnd.slice(0, 16) : ''
|
||||
form.deadline = task.deadline ? task.deadline.slice(0, 10) : ''
|
||||
form.syncToCalendar = task.syncToCalendar ?? false
|
||||
|
||||
if (task.recurrence) {
|
||||
form.isRecurring = true
|
||||
form.recurrenceType = task.recurrence.type
|
||||
form.recurrenceInterval = String(task.recurrence.interval)
|
||||
form.recurrenceDaysOfWeek = task.recurrence.daysOfWeek ?? []
|
||||
form.recurrenceDayOfMonth = task.recurrence.dayOfMonth ? String(task.recurrence.dayOfMonth) : ''
|
||||
form.recurrenceWeekOfMonth = task.recurrence.weekOfMonth ?? 1
|
||||
form.monthlyMode = task.recurrence.weekOfMonth ? 'weekOfMonth' : 'dayOfMonth'
|
||||
form.recurrenceWeekDay = task.recurrence.daysOfWeek?.[0] ?? 'monday'
|
||||
if (task.recurrence.maxOccurrences) {
|
||||
form.recurrenceEnd = 'occurrences'
|
||||
form.recurrenceMaxOccurrences = String(task.recurrence.maxOccurrences)
|
||||
} else if (task.recurrence.endDate) {
|
||||
form.recurrenceEnd = 'date'
|
||||
form.recurrenceEndDate = task.recurrence.endDate.slice(0, 10)
|
||||
} else {
|
||||
form.recurrenceEnd = 'never'
|
||||
}
|
||||
} else {
|
||||
form.isRecurring = false
|
||||
form.recurrenceType = 'daily'
|
||||
form.recurrenceInterval = '1'
|
||||
form.recurrenceDaysOfWeek = []
|
||||
form.recurrenceDayOfMonth = ''
|
||||
form.monthlyMode = 'dayOfMonth'
|
||||
form.recurrenceWeekOfMonth = 1
|
||||
form.recurrenceWeekDay = 'monday'
|
||||
form.recurrenceEnd = 'never'
|
||||
form.recurrenceMaxOccurrences = ''
|
||||
form.recurrenceEndDate = ''
|
||||
}
|
||||
} else {
|
||||
form.title = ''
|
||||
form.description = ''
|
||||
@@ -424,6 +699,21 @@ function populateForm(task: Task | null) {
|
||||
form.tagIds = []
|
||||
form.clientTicketId = null
|
||||
form.projectId = null
|
||||
form.scheduledStart = ''
|
||||
form.scheduledEnd = ''
|
||||
form.deadline = ''
|
||||
form.syncToCalendar = false
|
||||
form.isRecurring = false
|
||||
form.recurrenceType = 'daily'
|
||||
form.recurrenceInterval = '1'
|
||||
form.recurrenceDaysOfWeek = []
|
||||
form.recurrenceDayOfMonth = ''
|
||||
form.monthlyMode = 'dayOfMonth'
|
||||
form.recurrenceWeekOfMonth = 1
|
||||
form.recurrenceWeekDay = 'monday'
|
||||
form.recurrenceEnd = 'never'
|
||||
form.recurrenceMaxOccurrences = ''
|
||||
form.recurrenceEndDate = ''
|
||||
}
|
||||
touched.title = false
|
||||
touched.project = false
|
||||
@@ -431,6 +721,7 @@ function populateForm(task: Task | null) {
|
||||
|
||||
watch(() => props.modelValue, async (open) => {
|
||||
if (open) {
|
||||
activeTab.value = 'details'
|
||||
confirmDeleteDocOpen.value = false
|
||||
documentToDelete.value = null
|
||||
populateForm(props.task)
|
||||
@@ -464,6 +755,7 @@ watch(() => props.task, (task) => {
|
||||
const { create, update, remove } = useTaskService()
|
||||
const { remove: removeDocument, getByTask: getDocumentsByTask } = useTaskDocumentService()
|
||||
const clientTicketService = useClientTicketService()
|
||||
const { create: createRecurrence, update: updateRecurrence, remove: removeRecurrence } = useTaskRecurrenceService()
|
||||
const { t } = useI18n()
|
||||
|
||||
const clientTickets = ref<ClientTicket[]>([])
|
||||
@@ -619,12 +911,42 @@ async function handleSubmit() {
|
||||
project: `/api/projects/${resolvedProjectId.value}`,
|
||||
tags: form.tagIds.map(id => `/api/task_tags/${id}`),
|
||||
clientTicket: form.clientTicketId ? `/api/client_tickets/${form.clientTicketId}` : null,
|
||||
scheduledStart: form.scheduledStart || null,
|
||||
scheduledEnd: form.scheduledEnd || null,
|
||||
deadline: form.deadline || null,
|
||||
syncToCalendar: form.syncToCalendar,
|
||||
}
|
||||
|
||||
let savedTask: Task
|
||||
if (isEditing.value && props.task) {
|
||||
await update(props.task.id, payload)
|
||||
savedTask = await update(props.task.id, payload)
|
||||
} else {
|
||||
await create(payload)
|
||||
savedTask = await create(payload)
|
||||
}
|
||||
|
||||
// Handle recurrence
|
||||
if (form.isRecurring) {
|
||||
const recPayload = {
|
||||
type: form.recurrenceType as 'daily' | 'weekly' | 'monthly' | 'yearly',
|
||||
interval: parseInt(form.recurrenceInterval) || 1,
|
||||
daysOfWeek: form.recurrenceType === 'weekly' ? form.recurrenceDaysOfWeek : null,
|
||||
dayOfMonth: form.recurrenceType === 'monthly' && form.monthlyMode === 'dayOfMonth'
|
||||
? parseInt(form.recurrenceDayOfMonth) || null : null,
|
||||
weekOfMonth: form.recurrenceType === 'monthly' && form.monthlyMode === 'weekOfMonth'
|
||||
? form.recurrenceWeekOfMonth : null,
|
||||
endDate: form.recurrenceEnd === 'date' ? form.recurrenceEndDate || null : null,
|
||||
maxOccurrences: form.recurrenceEnd === 'occurrences'
|
||||
? parseInt(form.recurrenceMaxOccurrences) || null : null,
|
||||
}
|
||||
|
||||
if (savedTask.recurrence) {
|
||||
await updateRecurrence(savedTask.recurrence.id, recPayload)
|
||||
} else {
|
||||
const recurrence = await createRecurrence(recPayload)
|
||||
await update(savedTask.id, { recurrence: recurrence['@id'] ?? `/api/task_recurrences/${recurrence.id}` })
|
||||
}
|
||||
} else if (isEditing.value && props.task?.recurrence) {
|
||||
await removeRecurrence(props.task.recurrence.id)
|
||||
}
|
||||
|
||||
emit('saved')
|
||||
|
||||
Reference in New Issue
Block a user