diff --git a/config/packages/security.yaml b/config/packages/security.yaml index cc32766..56050e8 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,4 +1,11 @@ security: + # Hiérarchie des rôles : ADMIN inclut BUREAU qui inclut USER. + # Ajouter un nouveau rôle = ajouter une ligne ici (et son équivalent côté + # front dans utils/roles.ts). + role_hierarchy: + ROLE_BUREAU: ROLE_USER + ROLE_ADMIN: ROLE_BUREAU + # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords password_hashers: App\Entity\User: 'auto' diff --git a/frontend/composables/useBovineColumns.ts b/frontend/composables/useBovineColumns.ts index a4866cd..7c4d978 100644 --- a/frontend/composables/useBovineColumns.ts +++ b/frontend/composables/useBovineColumns.ts @@ -18,13 +18,15 @@ export interface UseBovineColumnsOptions { /** * Définition partagée des colonnes des tableaux bovins (inventory + case). - * Variants distincts pour chaque écran et chaque rôle (admin/user) afin de - * pouvoir ajuster les largeurs indépendamment. + * 4 variants : avec/sans colonnes prix × inventory/case. + * + * Les colonnes Prix/kg et Prix total sont visibles pour les rôles BUREAU + * et ADMIN (BUREAU hérite ses droits price-visibility, ADMIN hérite de BUREAU). */ export const useBovineColumns = (options: UseBovineColumnsOptions = {}) => { const auth = useAuthStore() - const adminColumnsInventory: BovineColumn[] = [ + const withPricesInventory: BovineColumn[] = [ { key: 'nationalNumber', label: 'N° National', width: '80px' }, { key: 'workNumber', label: 'N° Travail', width: '60px' }, { key: 'sex', label: 'Sexe', width: '70px' }, @@ -38,7 +40,7 @@ export const useBovineColumns = (options: UseBovineColumnsOptions = {}) => { { key: 'finalPrice', label: 'Prix total', width: '80px' } ] - const userColumnsInventory: BovineColumn[] = [ + const withoutPricesInventory: BovineColumn[] = [ { key: 'nationalNumber', label: 'N° National', width: '80px' }, { key: 'workNumber', label: 'N° Travail', width: '60px' }, { key: 'sex', label: 'Sexe', width: '70px' }, @@ -50,7 +52,7 @@ export const useBovineColumns = (options: UseBovineColumnsOptions = {}) => { { key: 'arrivalDate', label: 'Entrée le', width: '90px' } ] - const adminColumnsCase: BovineColumn[] = [ + const withPricesCase: BovineColumn[] = [ { key: 'nationalNumber', label: 'N° National', width: '110px' }, { key: 'workNumber', label: 'N° Travail', width: '85px' }, { key: 'sex', label: 'Sexe', width: '90px' }, @@ -62,7 +64,7 @@ export const useBovineColumns = (options: UseBovineColumnsOptions = {}) => { { key: 'finalPrice', label: 'Prix total', width: '105px' } ] - const userColumnsCase: BovineColumn[] = [ + const withoutPricesCase: BovineColumn[] = [ { key: 'nationalNumber', label: 'N° National', width: '130px' }, { key: 'workNumber', label: 'N° Travail', width: '100px' }, { key: 'sex', label: 'Sexe', width: '110px' }, @@ -73,10 +75,13 @@ export const useBovineColumns = (options: UseBovineColumnsOptions = {}) => { ] const columns = computed(() => { - if (options.variant === 'case') { - return auth.isAdmin ? adminColumnsCase : userColumnsCase + const isCase = options.variant === 'case' + const seePrice = auth.isBureau + + if (isCase) { + return seePrice ? withPricesCase : withoutPricesCase } - return auth.isAdmin ? adminColumnsInventory : userColumnsInventory + return seePrice ? withPricesInventory : withoutPricesInventory }) return { columns } diff --git a/frontend/pages/inventory.vue b/frontend/pages/inventory.vue index 7f3fabe..9a1579b 100644 --- a/frontend/pages/inventory.vue +++ b/frontend/pages/inventory.vue @@ -13,7 +13,7 @@

Inventaire bovins

({{ totalItems }} bovin{{ totalItems > 1 ? 's' : '' }})