import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces' import BaseMenu from '~/composables/layout/Menus/baseMenu' import {useAbility} from "@casl/vue"; /** * @category composables/layout/Menus * @class CotisationsMenu * Classe pour la construction du Menu Cotisation (CMF) */ class CotisationsMenu extends BaseMenu implements Menu { /** * @constructor * Initialisation des services issues du context */ constructor () { const {$config} = useNuxtApp() super($config) } /** * Construit le menu Cotisations ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu (): ItemMenu | null { const {can} = useAbility() const children: ItemsMenu = [] if (can('display', 'rate_cotisation_page')) { children.push(this.constructMenu('rate_cotisation', {name: 'fa-euro-sign'}, '/cotisation/rate', true)) } if (can('display', 'parameters_cotisation_page')) { children.push(this.constructMenu('parameters_cotisation', {name: 'fa-euro-sign'}, '/cotisation/parameter', true)) } if (can('display', 'send_cotisation_page')) { children.push(this.constructMenu('send_cotisation', {name: 'fa-euro-sign'}, '/cotisation/send', true)) } if (can('display', 'state_cotisation_page')) { children.push(this.constructMenu('state_cotisation', {name: 'fa-euro-sign'}, '/cotisation/state', true)) } if (can('display', 'pay_cotisation_page')) { children.push(this.constructMenu('pay_cotisation', {name: 'fa-euro-sign'}, '/cotisation/pay', true)) } if (can('display', 'check_cotisation_page')) { children.push(this.constructMenu('check_cotisation', {name: 'fa-euro-sign'}, '/cotisation/check', true)) } if (can('display', 'ledger_cotisation_page')) { children.push(this.constructMenu('ledger_cotisation', {name: 'fa-euro-sign'}, '/cotisation/ledger', true)) } if (can('display', 'magazine_cotisation_page')) { children.push(this.constructMenu('magazine_cotisation', {name: 'fa-euro-sign'}, '/cotisation/magazine', true)) } if (can('display', 'ventilated_cotisation_page')) { children.push(this.constructMenu('ventilated_cotisation', {name: 'fa-euro-sign'}, '/cotisation/ventilated', true)) } if (can('display', 'pay_erase_cotisation_page')) { children.push(this.constructMenu('pay_erase_cotisation', {name: 'fa-euro-sign'}, '/cotisation/payerase', true)) } if (can('display', 'resume_cotisation_page')) { children.push(this.constructMenu('resume_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resume', true)) } if (can('display', 'history_cotisation_page')) { children.push(this.constructMenu('history_cotisation', {name: 'fa-euro-sign'}, '/cotisation/history', true)) } if (can('display', 'call_cotisation_page')) { children.push(this.constructMenu('call_cotisation', {name: 'fa-euro-sign'}, '/cotisation/call', true)) } if (can('display', 'history_struture_cotisation_page')) { children.push(this.constructMenu('history_struture_cotisation', {name: 'fa-euro-sign'}, '/cotisation/historystructure', true)) } if (can('display', 'insurance_cotisation_page')) { children.push(this.constructMenu('insurance_cotisation', {name: 'fa-euro-sign'}, '/cotisation/insurance', true)) } if (can('display', 'resume_all_cotisation_page')) { children.push(this.constructMenu('resume_all_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resumeall', true)) } if (can('display', 'resume_pay_cotisation_page')) { children.push(this.constructMenu('resume_pay_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resumepay', true)) } if (children.length === 1) { return children[0] } else if (children.length > 0) { return this.constructMenu('cotisations', {name: 'fa-money-bill'}, undefined, undefined, children) } else { return null } } } export const getCotisationsMenu = () => new CotisationsMenu().getMenu()