| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import {ItemMenu, ItemsMenu, Menu} from "~/types/interfaces";
- import BaseMenu from "~/use/layout/Menus/baseMenu";
- import {NuxtConfig} from "@nuxt/types/config";
- import {Ability} from "@casl/ability";
- /**
- * @category Use/layout/Menus
- * @class Admin2iosMenu
- * Classe pour la construction du Menu Admin 2IOS
- */
- class Admin2iosMenu extends BaseMenu implements Menu{
- private $ability:Ability;
- /**
- * @constructor
- * Initialisation des services issues du context
- */
- constructor($config:NuxtConfig, $ability:Ability) {
- super($config)
- this.$ability = $ability
- }
- /**
- * Construit le menu Administration 2ios ou null si aucune page accessible
- * @return {ItemMenu | null}
- */
- getMenu():ItemMenu | null {
- const children:ItemsMenu = [];
- if (this.$ability.can('display', 'all_accesses_page')) {
- children.push(this.constructMenu('all_accesses', 'fa-users', '/all_accesses/list/', true))
- }
- if (this.$ability.can('display', 'all_organizations_page')) {
- children.push(this.constructMenu('all_organizations', 'fa-building', '/organization_params/list/', true))
- }
- if (this.$ability.can('display', 'tips_page')) {
- children.push(this.constructMenu('tips', 'fa-info-circle', '/tips/list/', true))
- }
- if (this.$ability.can('display', 'dgv_page')) {
- children.push(this.constructMenu('dgv', 'fa-house-damage', '/admin2ios/dgv', true))
- }
- if (this.$ability.can('display', 'cmf_cotisation_page')) {
- children.push(this.constructMenu('cmf_cotisation', 'fa-info-circle', '/admin2ios/cotisationcmf', true))
- }
- if (this.$ability.can('display', 'right_page')) {
- children.push(this.constructMenu('right_menu', 'fa-balance-scale-right', '/admin2ios/right', true))
- }
- if (this.$ability.can('display', 'tree_page')) {
- children.push(this.constructMenu('tree_menu', 'fa-sitemap', '/admin2ios/tree', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('admin2ios', 'fa-sitemap', undefined, undefined, children) : null;
- }
- }
- export const getAdmin2iosMenu = ($config:NuxtConfig, $ability:Ability) => new Admin2iosMenu($config, $ability).getMenu()
|