billingMenu.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
  2. import BaseMenu from '~/composables/layout/Menus/baseMenu'
  3. import {useAbility} from "@casl/vue";
  4. /**
  5. * @category composables/layout/Menus
  6. * @class BillingMenu
  7. * Classe pour la construction du Menu Facturation
  8. */
  9. class BillingMenu extends BaseMenu implements Menu {
  10. /**
  11. * @constructor
  12. * Initialisation des services issues du context
  13. */
  14. constructor () {
  15. const {$config} = useNuxtApp()
  16. super($config)
  17. }
  18. /**
  19. * Construit le menu Facturation ou null si aucune page accessible
  20. * @return {ItemMenu | null}
  21. */
  22. getMenu (): ItemMenu | null {
  23. const {can} = useAbility()
  24. const children: ItemsMenu = []
  25. if (can('display', 'billing_product_page')) {
  26. children.push(this.constructMenu('billing_product', {name: 'fa-cube'}, '/intangibles/list/', true))
  27. }
  28. if (can('display', 'billing_products_by_student_page')) {
  29. children.push(this.constructMenu('billing_products_by_student', {name: 'fa-cubes'}, '/access_intangibles/list/', true))
  30. }
  31. if (can('display', 'billing_edition_page')) {
  32. children.push(this.constructMenu('billing_edition', {name: 'fa-copy'}, '/billing_edition', true))
  33. }
  34. if (can('display', 'billing_accounting_page')) {
  35. children.push(this.constructMenu('billing_accounting', {name: 'fa-file-alt'}, '/bill_accountings/list/', true))
  36. }
  37. if (can('display', 'billing_payment_list_page')) {
  38. children.push(this.constructMenu('billing_payment_list', {name: 'fa-credit-card'}, '/bill_payments_list/list/', true))
  39. }
  40. if (can('display', 'pes_page')) {
  41. children.push(this.constructMenu('pes_export', {name: 'fa-align-justify'}, '/pes/list/', true))
  42. }
  43. if (can('display', 'berger_levrault_page')) {
  44. children.push(this.constructMenu('berger_levrault_export', {name: 'fa-align-justify'}, '/berger_levraults/list/', true))
  45. }
  46. if (can('display', 'jvs_page')) {
  47. children.push(this.constructMenu('jvs_export', {name: 'fa-align-justify'}, '/jvs/list/', true))
  48. }
  49. if (children.length === 1) {
  50. return children[0]
  51. } else if (children.length > 0) {
  52. return this.constructMenu('billing', {name: 'fa-euro-sign'}, undefined, undefined, children)
  53. } else {
  54. return null
  55. }
  56. }
  57. }
  58. export const getBillingMenu = () => new BillingMenu().getMenu()