From 75982b1ede4f8c47f1f1a0fb820c15f98a15f4c0 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 28 Mar 2022 11:40:22 +0300 Subject: [PATCH] [Library & Monitor Dashboard | new-theme]: Sidebar & Navbar checks updated to use the same method | "activeMenuItem" in route data (optional) to set which menu item is active when url does not match | Bug fix in . 1. layout.service.ts: Added "activeMenuItemSubject" to keep value of data['activeMenuItem']. 2. menu.ts: Removed "markAsActive" (not used) | Set RootMenuItem as deprecated (should use only MenuItem) | Added "isTheActiveMenuItem()" method to check if a MenuItem (root or not / sidebar or navbar) is active. 3. navigationBar.component.ts: Updated "isTheActiveMenu()" method to call MenuItem.isTheActiveMenu() | Removed method "isTheActiveMenuItem()". 4. navigationBar.component.html: Always call "isTheActiveMenu()" method. 5. sideBar.component.ts: Added "get currentRoute()" and updated method "isTheActiveMenuItem()". 6. tabs.component.ts: [Bug fix] Removed [class.uk-active] from
  • of tabs (since small-tabs are not currently used it is ok to remove this) - caused by version update of Uikit. 7. monitor-routing.module.ts: Set activeMenuItem: "dashboard" for any path under a stakeholder that has nothing or anything under a topic. | Set activeMenuItem: "search" in paths under search. 8. app-routing.module.ts: Set activeMenuItem: "manage" for paths under admin/:stakeholder. 9. app.component.ts: Updated menu in Admin Dashboard (all items visible and logo of monitor used) | Set value for MenuItem.routeActive when adding menu items of topics and users. --- src/app/app-routing.module.ts | 5 +- src/app/app.component.ts | 90 ++++++++++++----------- src/app/monitor/monitor-routing.module.ts | 23 ++++-- src/app/openaireLibrary | 2 +- 4 files changed, 71 insertions(+), 49 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index c1a2c1d..3bf9f7e 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -42,7 +42,10 @@ const routes: Routes = [ { path: 'admin/:stakeholder', loadChildren: () => import('./admin-stakeholder/admin-stakeholder-routing.module').then(m => m.AdminStakeholderRoutingModule), - canActivateChild: [AdminDashboardGuard] + canActivateChild: [AdminDashboardGuard], + data: { + activeMenuItem: "manage" + } }, {path: 'theme', loadChildren: () => import('./openaireLibrary/utils/theme/theme.module').then(m => m.ThemeModule)}, { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 53ea941..6de1adf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -241,7 +241,8 @@ export class AppComponent implements OnInit, OnDestroy { if (this.isPublicOrIsMember(topic.visibility)) { let topicItem: MenuItem = new MenuItem(topic.alias, topic.name, "", ( '/' + this.stakeholder.alias + '/' + topic.alias), - null, [], [], {}); + null, [], [], {}, null, null, null, ( + '/' + this.stakeholder.alias + '/' + topic.alias)); topicItem.icon = topic.icon; items.push(topicItem); } @@ -273,6 +274,43 @@ export class AppComponent implements OnInit, OnDestroy { this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); } if (this.stakeholder) { + + this.menuItems.push({ + rootItem: new MenuItem("dashboard", "Dashboard", + "", "/" + this.stakeholder.alias, false, [], null, {} + , null, null, null, null), items: [] + }); + if (this.isPublicOrIsMember(this.stakeholder.visibility)) { + this.menuItems.push({ + rootItem: new MenuItem("search", "Search", "", this.properties.searchLinkToResults, + false, [], null, {resultbestaccessright: '"' + encodeURIComponent("Open Access") + '"'}, + null, null, null, null), + items: [] + }); + } + this.menuItems.push({ + rootItem: new MenuItem("methodology", "Methodology", + "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}), items: [ + new MenuItem("methodology", "Terminology and construction", + "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}), + new MenuItem("methodology", "See how it works", + "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}, null, "how"), + ] + }); + if (this.stakeholder.type === "funder") { + this.menuItems.push({ + rootItem: new MenuItem("develop", "Develop", + "", "/" + this.stakeholder.alias + "/develop", false, [], null, {}), items: [] + }); + } + if (this.isManager(this.stakeholder)) { + this.menuItems.push({ + rootItem: new MenuItem("manage", "Manage", + "", "/admin/" + this.stakeholder.alias, false, [], null, {} + , null, null, null, null), items: [] + }); + } + if (!this.hasAdminMenu && this.isFrontPage) { this.menuHeader = { route: "/" + this.stakeholder.alias, @@ -285,58 +323,26 @@ export class AppComponent implements OnInit, OnDestroy { stickyAnimation: true, menuPosition: "center" }; - this.menuItems.push({ - rootItem: new MenuItem("dashboard", "Dashboard", - "", "/" + this.stakeholder.alias, false, [], null, {}), items: [] - }); - if (this.isPublicOrIsMember(this.stakeholder.visibility)) { - this.menuItems.push({ - rootItem: new MenuItem("search", "Search", "", this.properties.searchLinkToResults, - false, [], null, {resultbestaccessright: '"' + encodeURIComponent("Open Access") + '"'}), - items: [] - }); - } - this.menuItems.push({ - rootItem: new MenuItem("methodology", "Methodology", - "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}), items: [ - new MenuItem("methodology", "Terminology and construction", - "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}), - new MenuItem("methodology", "See how it works", - "", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}, null, "how"), - ] - }); - if (this.stakeholder.type === "funder") { - this.menuItems.push({ - rootItem: new MenuItem("develop", "Develop", - "", "/" + this.stakeholder.alias + "/develop", false, [], null, {}), items: [] - }); - } - if (this.isManager(this.stakeholder)) { - this.menuItems.push({ - rootItem: new MenuItem("manage", "Manage", - "", "/admin/" + this.stakeholder.alias, false, [], null, {}), items: [] - }); - } } else { this.menuHeader = { - route: "/admin/" + this.stakeholder.alias, + route: "/" + this.stakeholder.alias, url: null, - title: 'Admin - ' + this.stakeholder.name, - logoUrl: null, - logoSmallUrl: null, + title: this.stakeholder.name, + logoUrl: 'assets/common-assets/logo-services/monitor/small.svg', + logoSmallUrl: "assets/common-assets/logo-services/monitor/small.svg", position: 'center', badge: false, stickyAnimation: true, menuPosition: "center" }; - this.menuItems.push({ - rootItem: new MenuItem("", "Dashboard", - "", '/' + this.stakeholder.alias + '/', false, [], null, {}), items: [] - }); + // this.menuItems.push({ + // rootItem: new MenuItem("", "Dashboard", + // "", '/' + this.stakeholder.alias + '/', false, [], null, {}), items: [] + // }); this.adminMenuItems.push(new MenuItem("general", "General", "", "/admin/" + this.stakeholder.alias, false, [], [], {}, "")); this.adminMenuItems.push(new MenuItem("indicators", "Indicators", "", "/admin/" + this.stakeholder.alias + '/indicators', false, [], [], {}, "")); if (this.stakeholder.defaultId) { - this.adminMenuItems.push(new MenuItem("users", "Users", "", "/admin/" + this.stakeholder.alias + "/users", false, [], [], {}, "")); + this.adminMenuItems.push(new MenuItem("users", "Users", "", "/admin/" + this.stakeholder.alias + "/users", false, [], [], {}, "", null, null, "/admin/" + this.stakeholder.alias+"/users")); if (Session.isPortalAdministrator(this.user)) { this.adminMenuItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, null, null, null, "/admin/" + this.stakeholder.alias + "/admin-tools")); } diff --git a/src/app/monitor/monitor-routing.module.ts b/src/app/monitor/monitor-routing.module.ts index 10c3e83..411d6ec 100644 --- a/src/app/monitor/monitor-routing.module.ts +++ b/src/app/monitor/monitor-routing.module.ts @@ -10,7 +10,10 @@ import {MonitorComponent} from "./monitor.component"; { path: ':stakeholder', component: MonitorComponent, - canDeactivate: [PreviousRouteRecorder] + canDeactivate: [PreviousRouteRecorder], + data: { + activeMenuItem: "dashboard" + } }, { path: ':stakeholder/develop', @@ -36,23 +39,33 @@ import {MonitorComponent} from "./monitor.component"; canDeactivate: [PreviousRouteRecorder], data: { hasSidebar: false, - isDashboard: true + isDashboard: true, + activeMenuItem: "search" } }, { path: ':stakeholder/:topic', component: MonitorComponent, - canDeactivate: [PreviousRouteRecorder] + canDeactivate: [PreviousRouteRecorder], + data: { + activeMenuItem: "dashboard" + } }, { path: ':stakeholder/:topic/:category', component: MonitorComponent, - canDeactivate: [PreviousRouteRecorder] + canDeactivate: [PreviousRouteRecorder], + data: { + activeMenuItem: "dashboard" + } }, { path: ':stakeholder/:topic/:category/:subCategory', component: MonitorComponent, - canDeactivate: [PreviousRouteRecorder] + canDeactivate: [PreviousRouteRecorder], + data: { + activeMenuItem: "dashboard" + } } ]) ] diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index dc0544d..99ed7ea 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit dc0544d0d8f54071cb7c9bffec36de19b0bccd68 +Subproject commit 99ed7ea6ba683a3b9427a3cb03d6c3b896269bee