From abf2b1f4863a16f716c8033d993e215be8db60b4 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 21 May 2026 09:32:43 +0200 Subject: [PATCH] =?UTF-8?q?feat(mail)=20:=20cr=C3=A9ation=20de=20t=C3=A2ch?= =?UTF-8?q?e=20depuis=20mail=20=E2=80=94=20s=C3=A9lecteur=20user=20+=20sta?= =?UTF-8?q?tut=20(workflow),=20modale=20agrandie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- .../components/mail/MailCreateTaskModal.vue | 223 +++++------------- frontend/i18n/locales/fr.json | 5 +- frontend/services/dto/mail.ts | 3 +- 3 files changed, 63 insertions(+), 168 deletions(-) diff --git a/frontend/components/mail/MailCreateTaskModal.vue b/frontend/components/mail/MailCreateTaskModal.vue index 46c96fa..bc7f44c 100644 --- a/frontend/components/mail/MailCreateTaskModal.vue +++ b/frontend/components/mail/MailCreateTaskModal.vue @@ -3,74 +3,63 @@ import type { MailMessageDetailDto } from '~/services/dto/mail' import type { Task } from '~/services/dto/task' import type { Project } from '~/services/dto/project' import type { TaskGroup } from '~/services/dto/task-group' -import type { TaskPriority } from '~/services/dto/task-priority' +import type { UserData } from '~/services/dto/user-data' import { useMailService } from '~/services/mail' import { useProjectService } from '~/services/projects' import { useTaskGroupService } from '~/services/task-groups' -import { useTaskPriorityService } from '~/services/task-priorities' +import { useUserService } from '~/services/users' +import { useAuthStore } from '~/stores/auth' const props = defineProps<{ - /** v-model: true = modal ouvert */ modelValue: boolean - /** ID BDD du message source */ messageId: number - /** Détail du message (pour afficher sujet/expéditeur en lecture seule) */ messageDetail: MailMessageDetailDto | null }>() - const emit = defineEmits<{ 'update:modelValue': [value: boolean] - /** Émis après création réussie — payload = tâche créée */ created: [task: Task] }>() const { t } = useI18n() +const auth = useAuthStore() const mailService = useMailService() const projectService = useProjectService() const taskGroupService = useTaskGroupService() -const priorityService = useTaskPriorityService() - -// ─── État formulaire ────────────────────────────────────────────────────── +const userService = useUserService() const projectId = ref(null) const taskGroupId = ref(null) -const priorityId = ref(null) +const assigneeId = ref(null) +const statusId = ref(null) const isSubmitting = ref(false) const touchedProject = ref(false) -// ─── Données de référence ───────────────────────────────────────────────── - const projects = ref([]) const groups = ref([]) -const priorities = ref([]) +const users = ref([]) const loadingGroups = ref(false) -const projectOptions = computed(() => - projects.value.map(p => ({ label: p.name, value: p.id })), -) +const projectOptions = computed(() => projects.value.map(p => ({ label: p.name, value: p.id }))) +const groupOptions = computed(() => groups.value.filter(g => !g.archived).map(g => ({ label: g.title, value: g.id }))) +const userOptions = computed(() => users.value.map(u => ({ label: u.username, value: u.id }))) -const groupOptions = computed(() => - groups.value.filter(g => !g.archived).map(g => ({ label: g.title, value: g.id })), +const selectedProject = computed(() => projects.value.find(p => p.id === projectId.value) ?? null) +const statusOptions = computed(() => + (selectedProject.value?.workflow?.statuses ?? []).map(s => ({ label: s.label, value: s.id })), ) -const priorityOptions = computed(() => - priorities.value.map(p => ({ label: p.label, value: p.id })), -) - -// ─── Chargement initial ─────────────────────────────────────────────────── - onMounted(async () => { - const [projs, prios] = await Promise.all([ + const [projs, us] = await Promise.all([ projectService.getAll({ archived: false }), - priorityService.getAll(), + userService.getAll(), ]) projects.value = projs - priorities.value = prios + users.value = us }) -// Recharger les groupes quand le projet change watch(projectId, async (pid) => { taskGroupId.value = null + statusId.value = selectedProject.value?.workflow?.statuses?.[0]?.id ?? null groups.value = [] if (!pid) return loadingGroups.value = true @@ -81,18 +70,16 @@ watch(projectId, async (pid) => { } }) -// Reset formulaire à l'ouverture watch(() => props.modelValue, (open) => { if (open) { projectId.value = null taskGroupId.value = null - priorityId.value = null + statusId.value = null + assigneeId.value = auth.user?.id ?? null touchedProject.value = false } }) -// ─── Actions ────────────────────────────────────────────────────────────── - function close(): void { emit('update:modelValue', false) } @@ -100,13 +87,13 @@ function close(): void { async function handleSubmit(): Promise { touchedProject.value = true if (!projectId.value) return - isSubmitting.value = true try { const task = await mailService.createTaskFromMail(props.messageId, { projectId: projectId.value, taskGroupId: taskGroupId.value ?? undefined, - priority: priorityId.value ? `/api/task_priorities/${priorityId.value}` : undefined, + assigneeId: assigneeId.value ?? undefined, + statusId: statusId.value ?? undefined, }) emit('created', task) close() @@ -117,135 +104,41 @@ async function handleSubmit(): Promise { - - diff --git a/frontend/i18n/locales/fr.json b/frontend/i18n/locales/fr.json index c38f0d6..4b14566 100644 --- a/frontend/i18n/locales/fr.json +++ b/frontend/i18n/locales/fr.json @@ -571,8 +571,9 @@ "projectPlaceholder": "Sélectionner un projet", "groupLabel": "Groupe (optionnel)", "groupPlaceholder": "Aucun groupe", - "priorityLabel": "Priorité (optionnelle)", - "priorityPlaceholder": "Aucune priorité", + "statusLabel": "Statut", + "assigneeLabel": "Assigné à", + "assigneePlaceholder": "Aucun", "titleHint": "Le titre sera rempli depuis le sujet du mail.", "descriptionHint": "La description sera remplie depuis le corps du mail." }, diff --git a/frontend/services/dto/mail.ts b/frontend/services/dto/mail.ts index 818b138..79c3db0 100644 --- a/frontend/services/dto/mail.ts +++ b/frontend/services/dto/mail.ts @@ -107,7 +107,8 @@ export type MailMessageFlagInput = { export type MailCreateTaskInput = { projectId: number taskGroupId?: number | null - priority?: string | null + assigneeId?: number + statusId?: number } // Input : lier une tâche existante à un mail