billingMenuBuilder.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import {MenuGroup, MenuItem, MenuItems} from "~/types/layout";
  3. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  4. /**
  5. * Menu Facturation
  6. */
  7. export default class BillingMenuBuilder extends AbstractMenuBuilder {
  8. static readonly menuName = "Billing"
  9. /**
  10. * Construit le menu Facturation ou null si aucune page accessible
  11. */
  12. build (): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'billing_product_page')) {
  15. children.push(this.createItem('billing_product', {name: 'fas fa-cube'}, '/intangibles/list/', MENU_LINK_TYPE.V1))
  16. }
  17. if (this.ability.can('display', 'billing_products_by_student_page')) {
  18. children.push(this.createItem('billing_products_by_student', {name: 'fas fa-cubes'}, '/access_intangibles/list/', MENU_LINK_TYPE.V1))
  19. }
  20. if (this.ability.can('display', 'billing_edition_page')) {
  21. children.push(this.createItem('billing_edition', {name: 'fas fa-copy'}, '/billing_edition', MENU_LINK_TYPE.V1))
  22. }
  23. if (this.ability.can('display', 'billing_accounting_page')) {
  24. children.push(this.createItem('billing_accounting', {name: 'fas fa-file-alt'}, '/bill_accountings/list/', MENU_LINK_TYPE.V1))
  25. }
  26. if (this.ability.can('display', 'billing_payment_list_page')) {
  27. children.push(this.createItem('billing_payment_list', {name: 'fas fa-credit-card'}, '/bill_payments_list/list/', MENU_LINK_TYPE.V1))
  28. }
  29. if (this.ability.can('display', 'pes_page')) {
  30. children.push(this.createItem('pes_export', {name: 'fas fa-align-justify'}, '/pes/list/', MENU_LINK_TYPE.V1))
  31. }
  32. if (this.ability.can('display', 'berger_levrault_page')) {
  33. children.push(this.createItem('berger_levrault_export', {name: 'fas fa-align-justify'}, '/berger_levraults/list/', MENU_LINK_TYPE.V1))
  34. }
  35. if (this.ability.can('display', 'jvs_page')) {
  36. children.push(this.createItem('jvs_export', {name: 'fas fa-align-justify'}, '/jvs/list/', MENU_LINK_TYPE.V1))
  37. }
  38. if (this.ability.can('display', 'afi_page')) {
  39. children.push(this.createItem('afi_export', {name: 'fas fa-align-justify'}, '/afis/list/', MENU_LINK_TYPE.V1))
  40. }
  41. if (children.length > 1) {
  42. // Plusieurs éléments, on retourne un groupe
  43. return this.createGroup('billing', {name: 'fas fa-euro-sign'}, children)
  44. }
  45. else if (children.length === 1) {
  46. // Un seul élément, on retourne cet élément seul
  47. return children[0]
  48. }
  49. return null
  50. }
  51. }