maj via codex
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="text-text text-sm">{{ t.titre }}</div>
|
||||
<div v-if="t.echeance" class="text-text-muted text-xs">📅 {{ fmtDate(t.echeance) }}</div>
|
||||
<div v-if="t.frequence_jours != null && t.frequence_jours > 0" class="text-text-muted text-xs">
|
||||
🔁 Tous les {{ t.frequence_jours }} jours
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-1 items-center shrink-0">
|
||||
<button v-if="t.statut === 'a_faire'" class="text-xs text-blue hover:underline"
|
||||
@@ -69,6 +72,25 @@
|
||||
<input v-model="form.echeance" type="date"
|
||||
class="w-full bg-bg border border-bg-hard rounded px-3 py-2 text-text text-sm focus:border-green outline-none" />
|
||||
</div>
|
||||
<div class="bg-bg rounded border border-bg-hard p-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-text">
|
||||
<input v-model="form.repetition" type="checkbox" class="accent-green" />
|
||||
Répétition
|
||||
</label>
|
||||
<p class="text-text-muted text-[11px] mt-1">Active une tâche récurrente.</p>
|
||||
</div>
|
||||
<div v-if="form.repetition">
|
||||
<label class="text-text-muted text-xs block mb-1">Fréquence (jours)</label>
|
||||
<input
|
||||
v-model.number="form.frequence_jours"
|
||||
type="number"
|
||||
min="1"
|
||||
step="1"
|
||||
required
|
||||
placeholder="Ex: 7"
|
||||
class="w-full bg-bg border border-bg-hard rounded px-3 py-2 text-text text-sm focus:border-green outline-none"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex gap-2 mt-2">
|
||||
<button type="submit" class="bg-green text-bg px-4 py-2 rounded text-sm font-semibold">
|
||||
{{ editId ? 'Enregistrer' : 'Créer' }}
|
||||
@@ -89,7 +111,15 @@ import type { Task } from '@/api/tasks'
|
||||
const store = useTasksStore()
|
||||
const showForm = ref(false)
|
||||
const editId = ref<number | null>(null)
|
||||
const form = reactive({ titre: '', description: '', priorite: 'normale', statut: 'a_faire', echeance: '' })
|
||||
const form = reactive({
|
||||
titre: '',
|
||||
description: '',
|
||||
priorite: 'normale',
|
||||
statut: 'a_faire',
|
||||
echeance: '',
|
||||
repetition: false,
|
||||
frequence_jours: undefined as number | undefined,
|
||||
})
|
||||
|
||||
const groupes: [string, string][] = [
|
||||
['a_faire', 'À faire'],
|
||||
@@ -105,7 +135,15 @@ function fmtDate(s: string) {
|
||||
|
||||
function openCreate() {
|
||||
editId.value = null
|
||||
Object.assign(form, { titre: '', description: '', priorite: 'normale', statut: 'a_faire', echeance: '' })
|
||||
Object.assign(form, {
|
||||
titre: '',
|
||||
description: '',
|
||||
priorite: 'normale',
|
||||
statut: 'a_faire',
|
||||
echeance: '',
|
||||
repetition: false,
|
||||
frequence_jours: undefined,
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
@@ -115,6 +153,8 @@ function startEdit(t: Task) {
|
||||
titre: t.titre, description: (t as any).description || '',
|
||||
priorite: t.priorite, statut: t.statut,
|
||||
echeance: t.echeance ? t.echeance.slice(0, 10) : '',
|
||||
repetition: Boolean((t as any).recurrence || (t as any).frequence_jours),
|
||||
frequence_jours: (t as any).frequence_jours ?? undefined,
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
@@ -124,10 +164,19 @@ function closeForm() { showForm.value = false; editId.value = null }
|
||||
onMounted(() => store.fetchAll())
|
||||
|
||||
async function submit() {
|
||||
const payload = {
|
||||
titre: form.titre,
|
||||
description: form.description,
|
||||
priorite: form.priorite,
|
||||
statut: form.statut,
|
||||
echeance: form.echeance || undefined,
|
||||
recurrence: form.repetition ? 'jours' : null,
|
||||
frequence_jours: form.repetition ? (form.frequence_jours ?? 7) : null,
|
||||
}
|
||||
if (editId.value) {
|
||||
await store.update(editId.value, { ...form })
|
||||
await store.update(editId.value, payload)
|
||||
} else {
|
||||
await store.create({ ...form })
|
||||
await store.create(payload)
|
||||
}
|
||||
closeForm()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user