billingMenuBuilder.ts 2.3 KB

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