From 0fb34e984d347c3ec8fb8f188ad1e245254771a4 Mon Sep 17 00:00:00 2001 From: Andrea Barbasso <´andrea.barbasso@4science.com´> Date: Tue, 16 Jan 2024 11:45:53 +0100 Subject: [PATCH] [DURACOM-191] set map for menu section --- .../admin-sidebar-section.component.ts | 2 -- ...andable-admin-sidebar-section.component.ts | 4 +-- src/app/browse-by/browse-by-guard.ts | 2 +- ...med-expandable-navbar-section.component.ts | 3 -- .../navbar-section.component.ts | 4 +-- ...-edit-menu-expandable-section.component.ts | 4 +-- .../dso-edit-menu-section.component.ts | 2 -- src/app/shared/menu/menu-section.decorator.ts | 30 +++++++++++++++++++ .../starts-with/starts-with-decorator.ts | 6 ++-- .../expandable-navbar-section.component.ts | 3 -- 10 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts index e342ee8168..63ce022e54 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts +++ b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts @@ -1,7 +1,6 @@ import { Component, Inject, Injector, OnInit } from '@angular/core'; import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-section.component'; import { MenuService } from '../../../shared/menu/menu.service'; -import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorator'; import { LinkMenuItemModel } from '../../../shared/menu/menu-item/models/link.model'; import { MenuSection } from '../../../shared/menu/menu-section.model'; import { MenuID } from '../../../shared/menu/menu-id.model'; @@ -21,7 +20,6 @@ import { NgClass } from '@angular/common'; imports: [NgClass, RouterLink, TranslateModule] }) -@rendersSectionForMenu(MenuID.ADMIN, false) export class AdminSidebarSectionComponent extends MenuSectionComponent implements OnInit { /** diff --git a/src/app/admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts b/src/app/admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts index cb99d75f80..828c2e8ba1 100644 --- a/src/app/admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts +++ b/src/app/admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts @@ -7,11 +7,10 @@ import { bgColor } from '../../../shared/animations/bgColor'; import { MenuService } from '../../../shared/menu/menu.service'; import { combineLatest as combineLatestObservable, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorator'; import { MenuID } from '../../../shared/menu/menu-id.model'; import { Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe } from '@angular/common'; +import { AsyncPipe, NgClass, NgComponentOutlet, NgFor, NgIf } from '@angular/common'; /** * Represents a expandable section in the sidebar @@ -25,7 +24,6 @@ import { NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe } from '@angular/com imports: [NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe, TranslateModule] }) -@rendersSectionForMenu(MenuID.ADMIN, true) export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit { /** * This section resides in the Admin Sidebar diff --git a/src/app/browse-by/browse-by-guard.ts b/src/app/browse-by/browse-by-guard.ts index dd87699a84..ca99acd5ce 100644 --- a/src/app/browse-by/browse-by-guard.ts +++ b/src/app/browse-by/browse-by-guard.ts @@ -13,7 +13,7 @@ import { DSpaceObject } from '../core/shared/dspace-object.model'; import { RemoteData } from '../core/data/remote-data'; import { PAGE_NOT_FOUND_PATH } from '../app-routing-paths'; -@Injectable() +@Injectable({providedIn: 'root'}) /** * A guard taking care of the correct route.data being set for the Browse-By components */ diff --git a/src/app/navbar/expandable-navbar-section/themed-expandable-navbar-section.component.ts b/src/app/navbar/expandable-navbar-section/themed-expandable-navbar-section.component.ts index 842889dbb8..4874bd5e4c 100644 --- a/src/app/navbar/expandable-navbar-section/themed-expandable-navbar-section.component.ts +++ b/src/app/navbar/expandable-navbar-section/themed-expandable-navbar-section.component.ts @@ -1,8 +1,6 @@ import { Component } from '@angular/core'; import { ThemedComponent } from '../../shared/theme-support/themed.component'; import { ExpandableNavbarSectionComponent } from './expandable-navbar-section.component'; -import { rendersSectionForMenu } from '../../shared/menu/menu-section.decorator'; -import { MenuID } from '../../shared/menu/menu-id.model'; /** * Themed wrapper for ExpandableNavbarSectionComponent @@ -13,7 +11,6 @@ import { MenuID } from '../../shared/menu/menu-id.model'; templateUrl: '../../shared/theme-support/themed.component.html', standalone: true }) -@rendersSectionForMenu(MenuID.PUBLIC, true) export class ThemedExpandableNavbarSectionComponent extends ThemedComponent { protected getComponentName(): string { return 'ExpandableNavbarSectionComponent'; diff --git a/src/app/navbar/navbar-section/navbar-section.component.ts b/src/app/navbar/navbar-section/navbar-section.component.ts index e7373d287f..c30df9fcdd 100644 --- a/src/app/navbar/navbar-section/navbar-section.component.ts +++ b/src/app/navbar/navbar-section/navbar-section.component.ts @@ -1,9 +1,8 @@ import { Component, Inject, Injector, OnInit } from '@angular/core'; import { MenuSectionComponent } from '../../shared/menu/menu-section/menu-section.component'; import { MenuService } from '../../shared/menu/menu.service'; -import { rendersSectionForMenu } from '../../shared/menu/menu-section.decorator'; import { MenuID } from '../../shared/menu/menu-id.model'; -import { NgComponentOutlet, AsyncPipe } from '@angular/common'; +import { AsyncPipe, NgComponentOutlet } from '@angular/common'; /** * Represents a non-expandable section in the navbar @@ -15,7 +14,6 @@ import { NgComponentOutlet, AsyncPipe } from '@angular/common'; standalone: true, imports: [NgComponentOutlet, AsyncPipe] }) -@rendersSectionForMenu(MenuID.PUBLIC, false) export class NavbarSectionComponent extends MenuSectionComponent implements OnInit { /** * This section resides in the Public Navbar diff --git a/src/app/shared/dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component.ts b/src/app/shared/dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component.ts index ee31dfd93d..8db9c8e202 100644 --- a/src/app/shared/dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component.ts +++ b/src/app/shared/dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component.ts @@ -1,5 +1,4 @@ import { Component, Inject, Injector } from '@angular/core'; -import { rendersSectionForMenu } from 'src/app/shared/menu/menu-section.decorator'; import { MenuSectionComponent } from 'src/app/shared/menu/menu-section/menu-section.component'; import { MenuService } from '../../../menu/menu.service'; import { Router } from '@angular/router'; @@ -9,7 +8,7 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { hasValue } from '../../../empty.util'; import { TranslateModule } from '@ngx-translate/core'; -import { NgFor, NgIf, NgComponentOutlet, AsyncPipe } from '@angular/common'; +import { AsyncPipe, NgComponentOutlet, NgFor, NgIf } from '@angular/common'; import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; /** @@ -22,7 +21,6 @@ import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' standalone: true, imports: [NgbDropdownModule, NgbTooltipModule, NgFor, NgIf, NgComponentOutlet, TranslateModule, AsyncPipe] }) -@rendersSectionForMenu(MenuID.DSO_EDIT, true) export class DsoEditMenuExpandableSectionComponent extends MenuSectionComponent { menuID: MenuID = MenuID.DSO_EDIT; diff --git a/src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts b/src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts index 174bfd4b79..62d3452f20 100644 --- a/src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts +++ b/src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts @@ -1,5 +1,4 @@ import { Component, Inject, Injector, OnInit } from '@angular/core'; -import { rendersSectionForMenu } from 'src/app/shared/menu/menu-section.decorator'; import { MenuSectionComponent } from 'src/app/shared/menu/menu-section/menu-section.component'; import { MenuService } from '../../../menu/menu.service'; import { isNotEmpty } from '../../../empty.util'; @@ -20,7 +19,6 @@ import { NgIf } from '@angular/common'; standalone: true, imports: [NgIf, NgbTooltipModule, RouterLink, TranslateModule] }) -@rendersSectionForMenu(MenuID.DSO_EDIT, false) export class DsoEditMenuSectionComponent extends MenuSectionComponent implements OnInit { menuID: MenuID = MenuID.DSO_EDIT; diff --git a/src/app/shared/menu/menu-section.decorator.ts b/src/app/shared/menu/menu-section.decorator.ts index 515ee2ff5c..be4b00727e 100644 --- a/src/app/shared/menu/menu-section.decorator.ts +++ b/src/app/shared/menu/menu-section.decorator.ts @@ -1,9 +1,39 @@ import { DEFAULT_THEME } from '../object-collection/shared/listable-object/listable-object.decorator'; import { MenuID } from './menu-id.model'; import { hasValue } from '../empty.util'; +import { + ExpandableAdminSidebarSectionComponent +} from '../../admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component'; +import { + AdminSidebarSectionComponent +} from '../../admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component'; +import { NavbarSectionComponent } from '../../navbar/navbar-section/navbar-section.component'; +import { ExpandableNavbarSectionComponent } from 'src/app/navbar/expandable-navbar-section/expandable-navbar-section.component'; +import { + DsoEditMenuSectionComponent +} from '../dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component'; +import { + DsoEditMenuExpandableSectionComponent +} from '../dso-page/dso-edit-menu/dso-edit-expandable-menu-section/dso-edit-menu-expandable-section.component'; const menuComponentMap = new Map(); +menuComponentMap.set(MenuID.ADMIN, new Map()); +menuComponentMap.get(MenuID.ADMIN).set(false, new Map()); +menuComponentMap.get(MenuID.ADMIN).get(false).set(DEFAULT_THEME, AdminSidebarSectionComponent); +menuComponentMap.get(MenuID.ADMIN).set(true, new Map()); +menuComponentMap.get(MenuID.ADMIN).get(true).set(DEFAULT_THEME, ExpandableAdminSidebarSectionComponent); +menuComponentMap.set(MenuID.PUBLIC, new Map()); +menuComponentMap.get(MenuID.PUBLIC).set(false, new Map()); +menuComponentMap.get(MenuID.PUBLIC).get(false).set(DEFAULT_THEME, NavbarSectionComponent); +menuComponentMap.get(MenuID.PUBLIC).set(true, new Map()); +menuComponentMap.get(MenuID.PUBLIC).get(true).set(DEFAULT_THEME, ExpandableNavbarSectionComponent); +menuComponentMap.set(MenuID.DSO_EDIT, new Map()); +menuComponentMap.get(MenuID.DSO_EDIT).set(false, new Map()); +menuComponentMap.get(MenuID.DSO_EDIT).get(false).set(DEFAULT_THEME, DsoEditMenuSectionComponent); +menuComponentMap.get(MenuID.DSO_EDIT).set(true, new Map()); +menuComponentMap.get(MenuID.DSO_EDIT).get(true).set(DEFAULT_THEME, DsoEditMenuExpandableSectionComponent); + /** * Decorator function to render a MenuSection for a menu * @param {MenuID} menuID The ID of the Menu in which the section is rendered diff --git a/src/app/shared/starts-with/starts-with-decorator.ts b/src/app/shared/starts-with/starts-with-decorator.ts index 2e9a7491e5..6507b9c189 100644 --- a/src/app/shared/starts-with/starts-with-decorator.ts +++ b/src/app/shared/starts-with/starts-with-decorator.ts @@ -1,4 +1,6 @@ import { defer } from 'rxjs'; +import { StartsWithDateComponent } from './date/starts-with-date.component'; +import { StartsWithTextComponent } from './text/starts-with-text.component'; const startsWithMap = new Map(); @@ -10,8 +12,8 @@ export enum StartsWithType { date = 'Date' } -startsWithMap.set(StartsWithType.text, defer(() => import('./text/starts-with-text.component').then(m => m.StartsWithTextComponent))); -startsWithMap.set(StartsWithType.date, defer(() => import('./date/starts-with-date.component').then(m => m.StartsWithDateComponent))); +startsWithMap.set(StartsWithType.text, StartsWithTextComponent); +startsWithMap.set(StartsWithType.date, StartsWithDateComponent); /** diff --git a/src/themes/custom/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts b/src/themes/custom/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts index eb5a0b32e2..eecfa56393 100644 --- a/src/themes/custom/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts +++ b/src/themes/custom/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts @@ -3,8 +3,6 @@ import { ExpandableNavbarSectionComponent as BaseComponent } from '../../../../../app/navbar/expandable-navbar-section/expandable-navbar-section.component'; import { slide } from '../../../../../app/shared/animations/slide'; -import { rendersSectionForMenu } from '../../../../../app/shared/menu/menu-section.decorator'; -import { MenuID } from '../../../../../app/shared/menu/menu-id.model'; /** * Represents an expandable section in the navbar @@ -18,6 +16,5 @@ import { MenuID } from '../../../../../app/shared/menu/menu-id.model'; animations: [slide], standalone: true }) -@rendersSectionForMenu(MenuID.PUBLIC, true) export class ExpandableNavbarSectionComponent extends BaseComponent { }