import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces' import BaseMenu from '~/composables/layout/Menus/baseMenu' import {useAbility} from "@casl/vue"; /** * @category composables/layout/Menus * @class BillingMenu * Classe pour la construction du Menu Facturation */ class BillingMenu extends BaseMenu implements Menu { /** * @constructor * Initialisation des services issues du context */ constructor () { const {$config} = useNuxtApp() super($config) } /** * Construit le menu Facturation ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu (): ItemMenu | null { const {can} = useAbility() const children: ItemsMenu = [] if (can('display', 'billing_product_page')) { children.push(this.constructMenu('billing_product', {name: 'fa-cube'}, '/intangibles/list/', true)) } if (can('display', 'billing_products_by_student_page')) { children.push(this.constructMenu('billing_products_by_student', {name: 'fa-cubes'}, '/access_intangibles/list/', true)) } if (can('display', 'billing_edition_page')) { children.push(this.constructMenu('billing_edition', {name: 'fa-copy'}, '/billing_edition', true)) } if (can('display', 'billing_accounting_page')) { children.push(this.constructMenu('billing_accounting', {name: 'fa-file-alt'}, '/bill_accountings/list/', true)) } if (can('display', 'billing_payment_list_page')) { children.push(this.constructMenu('billing_payment_list', {name: 'fa-credit-card'}, '/bill_payments_list/list/', true)) } if (can('display', 'pes_page')) { children.push(this.constructMenu('pes_export', {name: 'fa-align-justify'}, '/pes/list/', true)) } if (can('display', 'berger_levrault_page')) { children.push(this.constructMenu('berger_levrault_export', {name: 'fa-align-justify'}, '/berger_levraults/list/', true)) } if (can('display', 'jvs_page')) { children.push(this.constructMenu('jvs_export', {name: 'fa-align-justify'}, '/jvs/list/', true)) } if (children.length === 1) { return children[0] } else if (children.length > 0) { return this.constructMenu('billing', {name: 'fa-euro-sign'}, undefined, undefined, children) } else { return null } } } export const getBillingMenu = () => new BillingMenu().getMenu()