From 569d3b373f395c098183caae691851cf3558676f Mon Sep 17 00:00:00 2001 From: tristan Date: Mon, 27 Apr 2026 17:09:13 +0200 Subject: [PATCH] =?UTF-8?q?feat=20:=20refonte=20de=20l'affichage=20des=20?= =?UTF-8?q?=C3=A2ges=20et=20restriction=20des=20prix=20aux=20admins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Repository BovineRepository avec getInventoryStats en DQL - Sécurité ApiProperty ROLE_ADMIN sur pricePerKg et finalPrice - Endpoint inventory-export passe en ROLE_ADMIN - Composable useBovineColumns mutualisé entre inventory et case (admin/user séparés) - Stats par tranche d'âge filtrables par buildingCaseId - Légende avec cartes colorées pleines + texte blanc - Coloration de la cellule Age (badge) au lieu de toute la ligne - Décalage couleurs : red ≥ 24, orange 22-24, yellow 20-22 Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/composables/useBovineColumns.ts | 47 +++++++++++ frontend/pages/infrastructure/case.vue | 78 +++++++++++++------ frontend/pages/inventory.vue | 51 +++++------- frontend/utils/bovine-age.ts | 8 ++ src/ApiResource/BovineInventoryExport.php | 2 +- src/Entity/Bovine.php | 5 +- src/Repository/BovineRepository.php | 53 +++++++++++++ .../Bovin/BovineInventoryExportProvider.php | 12 +-- .../Bovin/BovineInventoryStatsProvider.php | 27 +++---- 9 files changed, 204 insertions(+), 79 deletions(-) create mode 100644 frontend/composables/useBovineColumns.ts create mode 100644 src/Repository/BovineRepository.php diff --git a/frontend/composables/useBovineColumns.ts b/frontend/composables/useBovineColumns.ts new file mode 100644 index 0000000..bdb228b --- /dev/null +++ b/frontend/composables/useBovineColumns.ts @@ -0,0 +1,47 @@ +import { computed } from 'vue' +import { useAuthStore } from '~/stores/auth' + +export interface BovineColumn { + key: string + label: string + width?: string +} + +/** + * Définition partagée des colonnes des tableaux bovins (inventory + case). + * Deux définitions distinctes admin/user pour pouvoir ajuster les largeurs + * indépendamment selon le contexte. + */ +export const useBovineColumns = () => { + const auth = useAuthStore() + + const adminColumns: BovineColumn[] = [ + { key: 'nationalNumber', label: 'N° National', width: '80px' }, + { key: 'workNumber', label: 'N° Travail', width: '60px' }, + { key: 'sex', label: 'Sexe', width: '70px' }, + { key: 'birthDate', label: 'Né le', width: '72px' }, + { key: 'age', label: 'Age', width: '110px' }, + { key: 'breedCode', label: 'Race', width: '70px' }, + { key: 'buildingCase.building.label', label: 'Bâtiment', width: '1fr' }, + { key: 'buildingCase.caseNumber', label: 'Case', width: '42px' }, + { key: 'arrivalDate', label: 'Entrée le', width: '90px' }, + { key: 'pricePerKg', label: 'Prix/kg', width: '65px' }, + { key: 'finalPrice', label: 'Prix total', width: '100px' } + ] + + const userColumns: BovineColumn[] = [ + { key: 'nationalNumber', label: 'N° National', width: '80px' }, + { key: 'workNumber', label: 'N° Travail', width: '60px' }, + { key: 'sex', label: 'Sexe', width: '70px' }, + { key: 'birthDate', label: 'Né le', width: '72px' }, + { key: 'age', label: 'Age', width: '110px' }, + { key: 'breedCode', label: 'Race', width: '70px' }, + { key: 'buildingCase.building.label', label: 'Bâtiment', width: '1fr' }, + { key: 'buildingCase.caseNumber', label: 'Case', width: '42px' }, + { key: 'arrivalDate', label: 'Entrée le', width: '90px' } + ] + + const columns = computed(() => auth.isAdmin ? adminColumns : userColumns) + + return { columns } +} diff --git a/frontend/pages/infrastructure/case.vue b/frontend/pages/infrastructure/case.vue index 7479157..9306352 100644 --- a/frontend/pages/infrastructure/case.vue +++ b/frontend/pages/infrastructure/case.vue @@ -33,7 +33,22 @@ -
+
+
+ {{ stats.over24 }} + ≥ 24 mois +
+
+ {{ stats.between22And24 }} + 22 – 24 mois +
+
+ {{ stats.between20And22 }} + 20 – 22 mois +
+
+ +