Files
Lesstime/frontend/components/AdminPriorityTab.vue
matthieu c7b1e62037 feat : add admin page for task configuration
Add admin page with tabs for managing task statuses, efforts,
priorities and types, with CRUD drawers and color picker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:40:48 +01:00

104 lines
3.4 KiB
Vue

<template>
<div>
<div class="flex items-center justify-between">
<h2 class="text-lg font-bold text-neutral-900">Priorités</h2>
<button
class="rounded-md bg-primary-500 px-4 py-2 text-sm font-semibold text-white hover:bg-secondary-500"
@click="openCreate"
>
+ Ajouter une priorité
</button>
</div>
<div class="mt-6 overflow-x-auto rounded-lg border border-neutral-200">
<table class="w-full text-left text-sm">
<thead class="border-b border-neutral-200 bg-neutral-50">
<tr>
<th class="px-4 py-3 font-semibold text-neutral-700">Libellé</th>
<th class="px-4 py-3 font-semibold text-neutral-700">Couleur</th>
<th class="px-4 py-3 font-semibold text-neutral-700">Actions</th>
</tr>
</thead>
<tbody>
<tr
v-for="item in items"
:key="item.id"
class="border-b border-neutral-100 hover:bg-neutral-50 cursor-pointer"
@click="openEdit(item)"
>
<td class="px-4 py-3 font-semibold text-primary-500">{{ item.label }}</td>
<td class="px-4 py-3">
<span
class="inline-block h-6 w-6 rounded-full"
:style="{ backgroundColor: item.color }"
/>
</td>
<td class="px-4 py-3">
<button
class="text-red-500 hover:text-red-700"
@click.stop="handleDelete(item.id)"
>
<Icon name="mdi:delete-outline" size="20" />
</button>
</td>
</tr>
<tr v-if="items.length === 0 && !isLoading">
<td colspan="3" class="px-4 py-8 text-center text-neutral-400">
Aucune priorité trouvée.
</td>
</tr>
</tbody>
</table>
</div>
<TaskPriorityDrawer
v-model="drawerOpen"
:item="selectedItem"
@saved="onSaved"
/>
</div>
</template>
<script setup lang="ts">
import type { TaskPriority } from '~/services/dto/task-priority'
import { useTaskPriorityService } from '~/services/task-priorities'
const { getAll, remove } = useTaskPriorityService()
const items = ref<TaskPriority[]>([])
const isLoading = ref(true)
const drawerOpen = ref(false)
const selectedItem = ref<TaskPriority | null>(null)
async function loadItems() {
isLoading.value = true
try {
items.value = await getAll()
} finally {
isLoading.value = false
}
}
function openCreate() {
selectedItem.value = null
drawerOpen.value = true
}
function openEdit(item: TaskPriority) {
selectedItem.value = item
drawerOpen.value = true
}
async function handleDelete(id: number) {
await remove(id)
await loadItems()
}
async function onSaved() {
await loadItems()
}
onMounted(() => {
loadItems()
})
</script>