billingMenuBuilder.ts 2.3 KB

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