From 4cec2907da5e1bf55cf59930c23dd9a45c569b89 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 20 Sep 2022 18:00:19 +0300 Subject: [PATCH] [Explore | Library | new-theme]: resources.service.ts & menu.ts & navigationBar.component.ts & navigationBar.component.html & app.component.ts: Removed deprecated RootMenuItem and used MenuItem instead. --- monitor/services/resources.service.ts | 6 +-- sharedComponents/menu.ts | 30 ++----------- sharedComponents/navigationBar.component.html | 42 +++++++++---------- sharedComponents/navigationBar.component.ts | 18 ++++---- 4 files changed, 36 insertions(+), 60 deletions(-) diff --git a/monitor/services/resources.service.ts b/monitor/services/resources.service.ts index 3d528c63..9264723c 100644 --- a/monitor/services/resources.service.ts +++ b/monitor/services/resources.service.ts @@ -1,5 +1,5 @@ import {Injectable} from "@angular/core"; -import {MenuItem, RootMenuItem} from "../../sharedComponents/menu"; +import {MenuItem} from "../../sharedComponents/menu"; import {Option} from "../../sharedComponents/input/input.component"; import {StakeholderEntities} from "../entities/stakeholder"; import {from, Subscription} from "rxjs"; @@ -64,12 +64,12 @@ export class ResourcesService { /** * @deprecated * */ - setResourcesDeprecated(items: RootMenuItem[], prefix = '', portal: string = null) { + setResourcesDeprecated(items: MenuItem[], prefix = '', portal: string = null) { if (this.subscription) { this.subscription.unsubscribe(); } let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {}); - let index = items.push({rootItem: resources, items: []}) - 1; + let index = items.push(resources) - 1; this.subscription = from(this.getResourcesItemsAsync(prefix, portal)).subscribe(resourcesItems => { items[index].items = resourcesItems; }); diff --git a/sharedComponents/menu.ts b/sharedComponents/menu.ts index 787741da..000f05a5 100644 --- a/sharedComponents/menu.ts +++ b/sharedComponents/menu.ts @@ -24,7 +24,7 @@ export class MenuItem { constructor(id: string, title: string, url: string, route: string, needsAuthorization: boolean, entitiesRequired: string[], routeRequired: string[], params, icon: Icon = null, fragment = null, customClass = null, routeActive = null, - target: string = "_blank", type: string = "internal", isFeatured: boolean = false) { + target: string = "_blank", type: string = "internal", isFeatured: boolean = false, items: MenuItem[] = []) { this._id = id; this.title = title; this.url = url; @@ -34,7 +34,7 @@ export class MenuItem { this.entitiesRequired = entitiesRequired; this.routeRequired = routeRequired; this.params = params; - this.items = []; + this.items = items; this.icon = icon; this.fragment = fragment; this.customClass = customClass; @@ -80,30 +80,6 @@ export class Menu { menuItems: MenuItemExtended[] = []; } -/** - * @deprecated - * */ -export class RootMenuItem { - rootItem: MenuItem; - items: MenuItem[] = []; - - public static isTheActiveRootMenu(menu: RootMenuItem, currentRoute: string): boolean { - if (currentRoute == menu.rootItem.route) { - return true; - } else if (menu.items.length > 0) { - for (let menuItem of menu.items) { - let isActive = MenuItem.isTheActiveMenu(menuItem, currentRoute); - if (isActive) { - return true; - } - } - return false; - } - } -} - -export class SideMenuItem { - rootItem: MenuItem; - items: RootMenuItem[] = []; +export class SideMenuItem extends MenuItem { ukIcon: string = ''; } diff --git a/sharedComponents/navigationBar.component.html b/sharedComponents/navigationBar.component.html index 0d6eea90..e53bf9ae 100644 --- a/sharedComponents/navigationBar.component.html +++ b/sharedComponents/navigationBar.component.html @@ -36,19 +36,19 @@ Home
  • + *ngIf="isAtleastOneEnabled(menu.entitiesRequired,showEntity) && isAtleastOneEnabled(menu.routeRequired, showPage)"> - {{menu.rootItem.title}} - {{menu.rootItem.title}} - {{menu.rootItem.title}} + {{menu.title}} + {{menu.title}} + {{menu.title}}