- Replace all AppDrawer with MalioDrawer across 10 drawer components - Replace native <button> with MalioButton/MalioButtonIcon in all pages and components - Fix TimeTrackingExportDrawer: use MalioSelectCheckbox for multi-select filters - Add Malio design system colors (m-btn-*, m-disabled, m-surface) to tailwind.config.ts - Align toggle button heights with MalioButton (h-[40px]) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
123 lines
3.4 KiB
Vue
123 lines
3.4 KiB
Vue
<template>
|
|
<MalioDrawer v-model="isOpen" :title="isEditing ? $t('taskStatuses.editStatus') : $t('taskStatuses.addStatus')">
|
|
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
|
<MalioInputText
|
|
v-model="form.label"
|
|
label="Libellé"
|
|
input-class="w-full"
|
|
:error="touched.label && !form.label.trim() ? 'Le libellé est requis' : ''"
|
|
@blur="touched.label = true"
|
|
/>
|
|
<MalioInputText
|
|
v-model="form.position"
|
|
label="Position"
|
|
input-class="w-full"
|
|
type="number"
|
|
/>
|
|
<div class="mt-4">
|
|
<ColorPicker v-model="form.color" />
|
|
</div>
|
|
|
|
<div class="mt-4 flex items-center gap-2">
|
|
<input
|
|
id="isFinal"
|
|
v-model="form.isFinal"
|
|
type="checkbox"
|
|
class="h-4 w-4 rounded border-neutral-300 text-primary-500 focus:ring-primary-500"
|
|
/>
|
|
<label for="isFinal" class="text-sm font-medium text-neutral-700">
|
|
{{ $t('archive.statusFinal') }}
|
|
</label>
|
|
</div>
|
|
|
|
<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 { TaskStatus, TaskStatusWrite } from '~/services/dto/task-status'
|
|
import { useTaskStatusService } from '~/services/task-statuses'
|
|
|
|
const props = defineProps<{
|
|
modelValue: boolean
|
|
item: TaskStatus | 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.item)
|
|
const isSubmitting = ref(false)
|
|
|
|
const form = reactive({
|
|
label: '',
|
|
position: '0',
|
|
color: '#222783',
|
|
isFinal: false,
|
|
})
|
|
|
|
const touched = reactive({
|
|
label: false,
|
|
})
|
|
|
|
watch(() => props.modelValue, (open) => {
|
|
if (open) {
|
|
if (props.item) {
|
|
form.label = props.item.label ?? ''
|
|
form.position = String(props.item.position ?? 0)
|
|
form.color = props.item.color ?? '#222783'
|
|
form.isFinal = props.item.isFinal ?? false
|
|
} else {
|
|
form.label = ''
|
|
form.position = '0'
|
|
form.color = '#222783'
|
|
form.isFinal = false
|
|
}
|
|
touched.label = false
|
|
}
|
|
})
|
|
|
|
const { create, update } = useTaskStatusService()
|
|
|
|
async function handleSubmit() {
|
|
touched.label = true
|
|
if (!form.label.trim()) return
|
|
|
|
isSubmitting.value = true
|
|
try {
|
|
const payload: TaskStatusWrite = {
|
|
label: form.label.trim(),
|
|
position: Number(form.position),
|
|
color: form.color,
|
|
isFinal: form.isFinal,
|
|
}
|
|
|
|
if (isEditing.value && props.item) {
|
|
await update(props.item.id, payload)
|
|
} else {
|
|
await create(payload)
|
|
}
|
|
|
|
emit('saved')
|
|
isOpen.value = false
|
|
} finally {
|
|
isSubmitting.value = false
|
|
}
|
|
}
|
|
</script>
|