| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { Ability } from '@casl/ability'
- import { NuxtConfig } from '@nuxt/types/config'
- import { AnyStore, ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
- import BaseMenu from '~/composables/layout/Menus/baseMenu'
- /**
- * @category composables/layout/Menus
- * @class ConfigurationMenu
- * Classe pour la construction du Menu Paramètres
- */
- class ParametersMenu extends BaseMenu implements Menu {
- private $ability: Ability;
- private $store: AnyStore;
- /**
- * @constructor
- * Initialisation des services issues du context
- */
- constructor ($config: NuxtConfig, $ability: Ability, $store: AnyStore) {
- super($config)
- this.$ability = $ability
- this.$store = $store
- }
- /**
- * Construit le menu Header Configuration ou null si aucune page accessible
- * @return {ItemMenu | null}
- */
- getMenus (): ItemsMenu | null {
- const children: ItemsMenu = []
- if (this.$ability.can('display', 'parameters_page')) {
- children.push(this.constructMenu('general_params', 'fa-cogs',`/parameters`, false))
- }
- if (this.$ability.can('display', 'parameters_communication_page')) {
- children.push(this.constructMenu('communication_params', 'fa-comments',`/parameters/communication`, false))
- }
- if (this.$ability.can('display', 'parameters_student_page')) {
- children.push(this.constructMenu('students_params', 'fa-users',`/parameters/student`, false))
- }
- if (this.$ability.can('display', 'parameters_education_page')) {
- children.push(this.constructMenu('education_params', 'fa-graduation-cap',`/parameters/education`, false))
- }
- if (this.$ability.can('display', 'parameters_bills_page')) {
- children.push(this.constructMenu('bills_params', 'fa-euro-sign',`/parameters/billing`, false))
- }
- if (this.$ability.can('display', 'parameters_secure_page')) {
- children.push(this.constructMenu('secure_params', 'fa-lock',`/parameters/secure`, false))
- }
- if (children.length > 0) {
- return children
- } else {
- return null
- }
- }
- }
- export const getParametersMenu = ($config: NuxtConfig, $ability: Ability, $store: AnyStore) => new ParametersMenu($config, $ability, $store).getMenus()
|