before gemiin
This commit is contained in:
@@ -8,8 +8,7 @@ const form = reactive({
|
||||
titre: '',
|
||||
description: '',
|
||||
priorite: 'normale',
|
||||
statut: 'a_faire',
|
||||
echeance: '',
|
||||
statut: 'template',
|
||||
repetition: false,
|
||||
frequence_jours: undefined,
|
||||
});
|
||||
@@ -17,46 +16,54 @@ const groupes = [
|
||||
['a_faire', 'À faire'],
|
||||
['en_cours', 'En cours'],
|
||||
['fait', 'Terminé'],
|
||||
['template', 'Templates'],
|
||||
];
|
||||
const byStatut = (s) => store.tasks.filter(t => t.statut === s);
|
||||
function fmtDate(s) {
|
||||
return new Date(s + 'T12:00:00').toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' });
|
||||
}
|
||||
function openCreate() {
|
||||
editId.value = null;
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
titre: '',
|
||||
description: '',
|
||||
priorite: 'normale',
|
||||
statut: 'a_faire',
|
||||
echeance: '',
|
||||
statut: 'template',
|
||||
repetition: false,
|
||||
frequence_jours: undefined,
|
||||
});
|
||||
}
|
||||
function openCreateTemplate() {
|
||||
editId.value = null;
|
||||
resetForm();
|
||||
showForm.value = true;
|
||||
}
|
||||
function startEdit(t) {
|
||||
editId.value = t.id;
|
||||
Object.assign(form, {
|
||||
titre: t.titre, description: t.description || '',
|
||||
priorite: t.priorite, statut: t.statut,
|
||||
echeance: t.echeance ? t.echeance.slice(0, 10) : '',
|
||||
titre: t.titre,
|
||||
description: t.description || '',
|
||||
priorite: t.priorite,
|
||||
statut: t.statut || 'template',
|
||||
repetition: Boolean(t.recurrence || t.frequence_jours),
|
||||
frequence_jours: t.frequence_jours ?? undefined,
|
||||
});
|
||||
showForm.value = true;
|
||||
}
|
||||
function closeForm() { showForm.value = false; editId.value = null; }
|
||||
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,
|
||||
statut: 'template',
|
||||
recurrence: form.repetition ? 'jours' : null,
|
||||
frequence_jours: form.repetition ? (form.frequence_jours ?? 7) : null,
|
||||
echeance: undefined,
|
||||
planting_id: undefined,
|
||||
};
|
||||
if (editId.value) {
|
||||
await store.update(editId.value, payload);
|
||||
@@ -65,13 +72,14 @@ async function submit() {
|
||||
await store.create(payload);
|
||||
}
|
||||
closeForm();
|
||||
resetForm();
|
||||
}
|
||||
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
||||
const __VLS_ctx = {};
|
||||
let __VLS_components;
|
||||
let __VLS_directives;
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "p-4 max-w-2xl mx-auto" },
|
||||
...{ class: "p-4 max-w-5xl mx-auto" },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "flex items-center justify-between mb-6" },
|
||||
@@ -80,7 +88,7 @@ __VLS_asFunctionalElement(__VLS_intrinsicElements.h1, __VLS_intrinsicElements.h1
|
||||
...{ class: "text-2xl font-bold text-green" },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.button, __VLS_intrinsicElements.button)({
|
||||
...{ onClick: (__VLS_ctx.openCreate) },
|
||||
...{ onClick: (__VLS_ctx.openCreateTemplate) },
|
||||
...{ class: "bg-green text-bg px-4 py-2 rounded-lg text-sm font-semibold hover:opacity-90" },
|
||||
});
|
||||
for (const [[groupe, label]] of __VLS_getVForSourceType((__VLS_ctx.groupes))) {
|
||||
@@ -116,7 +124,13 @@ for (const [[groupe, label]] of __VLS_getVForSourceType((__VLS_ctx.groupes))) {
|
||||
...{ class: "text-text text-sm" },
|
||||
});
|
||||
(t.titre);
|
||||
if (t.echeance) {
|
||||
if (t.description) {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "text-text-muted text-xs" },
|
||||
});
|
||||
(t.description);
|
||||
}
|
||||
if (t.echeance && t.statut !== 'template') {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "text-text-muted text-xs" },
|
||||
});
|
||||
@@ -128,6 +142,12 @@ for (const [[groupe, label]] of __VLS_getVForSourceType((__VLS_ctx.groupes))) {
|
||||
});
|
||||
(t.frequence_jours);
|
||||
}
|
||||
if (t.planting_id && t.statut !== 'template') {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "text-text-muted text-xs" },
|
||||
});
|
||||
(t.planting_id);
|
||||
}
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "flex gap-1 items-center shrink-0" },
|
||||
});
|
||||
@@ -151,12 +171,16 @@ for (const [[groupe, label]] of __VLS_getVForSourceType((__VLS_ctx.groupes))) {
|
||||
...{ class: "text-xs text-green hover:underline" },
|
||||
});
|
||||
}
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.button, __VLS_intrinsicElements.button)({
|
||||
...{ onClick: (...[$event]) => {
|
||||
__VLS_ctx.startEdit(t);
|
||||
} },
|
||||
...{ class: "text-xs text-yellow hover:underline ml-2" },
|
||||
});
|
||||
if (t.statut === 'template') {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.button, __VLS_intrinsicElements.button)({
|
||||
...{ onClick: (...[$event]) => {
|
||||
if (!(t.statut === 'template'))
|
||||
return;
|
||||
__VLS_ctx.startEdit(t);
|
||||
} },
|
||||
...{ class: "text-xs text-yellow hover:underline ml-2" },
|
||||
});
|
||||
}
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.button, __VLS_intrinsicElements.button)({
|
||||
...{ onClick: (...[$event]) => {
|
||||
__VLS_ctx.store.remove(t.id);
|
||||
@@ -176,7 +200,7 @@ if (__VLS_ctx.showForm) {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.h2, __VLS_intrinsicElements.h2)({
|
||||
...{ class: "text-text font-bold text-lg mb-4" },
|
||||
});
|
||||
(__VLS_ctx.editId ? 'Modifier la tâche' : 'Nouvelle tâche');
|
||||
(__VLS_ctx.editId ? 'Modifier la tâche' : 'Nouveau template');
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.form, __VLS_intrinsicElements.form)({
|
||||
...{ onSubmit: (__VLS_ctx.submit) },
|
||||
...{ class: "grid gap-3" },
|
||||
@@ -223,28 +247,11 @@ if (__VLS_ctx.showForm) {
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.label, __VLS_intrinsicElements.label)({
|
||||
...{ class: "text-text-muted text-xs block mb-1" },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.select, __VLS_intrinsicElements.select)({
|
||||
value: (__VLS_ctx.form.statut),
|
||||
...{ class: "w-full bg-bg border border-bg-hard rounded px-3 py-2 text-text text-sm" },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.option, __VLS_intrinsicElements.option)({
|
||||
value: "a_faire",
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.option, __VLS_intrinsicElements.option)({
|
||||
value: "en_cours",
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.option, __VLS_intrinsicElements.option)({
|
||||
value: "fait",
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.label, __VLS_intrinsicElements.label)({
|
||||
...{ class: "text-text-muted text-xs block mb-1" },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.input)({
|
||||
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" },
|
||||
value: "Template",
|
||||
readonly: true,
|
||||
...{ class: "w-full bg-bg border border-bg-hard rounded px-3 py-2 text-text-muted text-sm" },
|
||||
});
|
||||
(__VLS_ctx.form.echeance);
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "bg-bg rounded border border-bg-hard p-3" },
|
||||
});
|
||||
@@ -281,7 +288,7 @@ if (__VLS_ctx.showForm) {
|
||||
type: "submit",
|
||||
...{ class: "bg-green text-bg px-4 py-2 rounded text-sm font-semibold" },
|
||||
});
|
||||
(__VLS_ctx.editId ? 'Enregistrer' : 'Créer');
|
||||
(__VLS_ctx.editId ? 'Enregistrer' : 'Créer le template');
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.button, __VLS_intrinsicElements.button)({
|
||||
...{ onClick: (__VLS_ctx.closeForm) },
|
||||
type: "button",
|
||||
@@ -289,7 +296,7 @@ if (__VLS_ctx.showForm) {
|
||||
});
|
||||
}
|
||||
/** @type {__VLS_StyleScopedClasses['p-4']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['max-w-2xl']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['max-w-5xl']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['mx-auto']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['items-center']} */ ;
|
||||
@@ -333,6 +340,10 @@ if (__VLS_ctx.showForm) {
|
||||
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['gap-1']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['items-center']} */ ;
|
||||
@@ -430,23 +441,8 @@ if (__VLS_ctx.showForm) {
|
||||
/** @type {__VLS_StyleScopedClasses['rounded']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['px-3']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['block']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['mb-1']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['w-full']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['bg-bg']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['border']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['border-bg-hard']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['rounded']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['px-3']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-text']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['focus:border-green']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['outline-none']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['bg-bg']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['rounded']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['border']} */ ;
|
||||
@@ -502,7 +498,7 @@ const __VLS_self = (await import('vue')).defineComponent({
|
||||
groupes: groupes,
|
||||
byStatut: byStatut,
|
||||
fmtDate: fmtDate,
|
||||
openCreate: openCreate,
|
||||
openCreateTemplate: openCreateTemplate,
|
||||
startEdit: startEdit,
|
||||
closeForm: closeForm,
|
||||
submit: submit,
|
||||
|
||||
Reference in New Issue
Block a user