| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {AnyStore, ItemMenu, ItemsMenu, Menu} from "~/types/interfaces";
- import BaseMenu from "~/use/layout/Menus/baseMenu";
- import {Ability} from "@casl/ability";
- import {NuxtConfig} from "@nuxt/types/config";
- /**
- * @category Use/layout/Menus
- * @class AccountMenu
- * Classe pour la construction du Menu Mon compte
- */
- class AccountMenu 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}
- */
- getHeaderMenu():ItemMenu | null {
- const children:ItemsMenu = [];
- if (this.$ability.can('display', 'organization_page')) {
- children.push(this.constructMenu('organization_page', undefined,'/organization/edit'))
- }
- return children.length > 0 ? this.constructMenu('configuration', 'fa-user', undefined, undefined, children) : null;
- }
- }
- export const getAccountMenu = ($config:NuxtConfig, $ability:Ability, $store:AnyStore) => new AccountMenu($config, $ability, $store).getHeaderMenu()
|