Deux lots regroupés sur la branche feat/absence-management. Suppression complète du portail client : - retire ROLE_CLIENT (security.yaml) ; User::getRoles() ajoute toujours ROLE_USER - supprime l'entité ClientTicket (+ repo, states, relations), User.client et User.allowedProjects, NotificationService, ProjectAllowedExtension, le bloc ROLE_CLIENT de MailAccessChecker - front : pages /portal, layout portal, composants client-ticket/, AdminClientTicketTab, services/dto/i18n/docs associés - fixtures : retire les users client-liot / client-acme - migration Version20260522110000 (drop client_ticket, user_allowed_projects, colonnes liées ; task_document.task_id -> NOT NULL) - tests : retire les cas obsolètes testant le blocage des clients sur le mail Module gestion des absences (WIP) : - entités / migrations (Version20260521160000, Version20260522090000) - pages absences.vue / team-absences.vue, composants frontend/components/absence/ - services front, AccrueLeaveCommand, PublicHolidayController Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
140 lines
3.7 KiB
Vue
140 lines
3.7 KiB
Vue
<template>
|
|
<MalioDrawer v-model="isOpen">
|
|
<template #header>
|
|
<h2 class="text-xl font-bold">{{ isEditing ? $t('clients.editClient') : $t('clients.addClient') }}</h2>
|
|
</template>
|
|
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
|
<MalioInputText
|
|
v-model="form.name"
|
|
label="Nom"
|
|
input-class="w-full"
|
|
:error="touched.name && !form.name.trim() ? 'Le nom est requis' : ''"
|
|
@blur="touched.name = true"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.email"
|
|
label="Email"
|
|
input-class="w-full"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.phone"
|
|
label="Téléphone"
|
|
input-class="w-full"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.street"
|
|
label="Rue"
|
|
input-class="w-full"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.city"
|
|
label="Ville"
|
|
input-class="w-full"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.postalCode"
|
|
label="Code Postal"
|
|
input-class="w-full"
|
|
/>
|
|
|
|
<div class="mt-6 flex justify-end">
|
|
<MalioButton
|
|
label="Enregistrer"
|
|
button-class="w-auto px-6"
|
|
:disabled="isSubmitting"
|
|
@click="handleSubmit"
|
|
/>
|
|
</div>
|
|
</form>
|
|
</MalioDrawer>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import type { Client, ClientWrite } from '~/services/dto/client'
|
|
import { useClientService } from '~/services/clients'
|
|
|
|
const props = defineProps<{
|
|
modelValue: boolean
|
|
client: Client | null
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'update:modelValue', value: boolean): void
|
|
(e: 'saved'): void
|
|
}>()
|
|
|
|
const isOpen = computed({
|
|
get: () => props.modelValue,
|
|
set: (v) => emit('update:modelValue', v),
|
|
})
|
|
|
|
const isEditing = computed(() => !!props.client)
|
|
const isSubmitting = ref(false)
|
|
|
|
const form = reactive({
|
|
name: '',
|
|
email: '',
|
|
phone: '',
|
|
street: '',
|
|
city: '',
|
|
postalCode: '',
|
|
})
|
|
|
|
const touched = reactive({
|
|
name: false,
|
|
email: false,
|
|
})
|
|
|
|
watch(() => props.modelValue, (open) => {
|
|
if (open) {
|
|
if (props.client) {
|
|
form.name = props.client.name ?? ''
|
|
form.email = props.client.email ?? ''
|
|
form.phone = props.client.phone ?? ''
|
|
form.street = props.client.street ?? ''
|
|
form.city = props.client.city ?? ''
|
|
form.postalCode = props.client.postalCode ?? ''
|
|
} else {
|
|
form.name = ''
|
|
form.email = ''
|
|
form.phone = ''
|
|
form.street = ''
|
|
form.city = ''
|
|
form.postalCode = ''
|
|
}
|
|
touched.name = false
|
|
touched.email = false
|
|
}
|
|
})
|
|
|
|
const { create, update } = useClientService()
|
|
|
|
async function handleSubmit() {
|
|
touched.name = true
|
|
if (!form.name.trim()) return
|
|
|
|
isSubmitting.value = true
|
|
try {
|
|
const payload: ClientWrite = {
|
|
name: form.name.trim(),
|
|
email: form.email.trim() || null,
|
|
phone: form.phone.trim() || null,
|
|
street: form.street.trim() || null,
|
|
city: form.city.trim() || null,
|
|
postalCode: form.postalCode.trim() || null,
|
|
}
|
|
|
|
if (isEditing.value && props.client) {
|
|
await update(props.client.id, payload)
|
|
} else {
|
|
await create(payload)
|
|
}
|
|
|
|
emit('saved')
|
|
isOpen.value = false
|
|
} finally {
|
|
isSubmitting.value = false
|
|
}
|
|
}
|
|
</script>
|