[DURACOM-191] set map for menu section

This commit is contained in:
Andrea Barbasso
2024-01-16 11:45:53 +01:00
parent 09c070e164
commit 0fb34e984d
10 changed files with 38 additions and 22 deletions

View File

@@ -1,7 +1,6 @@
import { Component, Inject, Injector, OnInit } from '@angular/core'; import { Component, Inject, Injector, OnInit } from '@angular/core';
import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-section.component'; import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-section.component';
import { MenuService } from '../../../shared/menu/menu.service'; 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 { LinkMenuItemModel } from '../../../shared/menu/menu-item/models/link.model';
import { MenuSection } from '../../../shared/menu/menu-section.model'; import { MenuSection } from '../../../shared/menu/menu-section.model';
import { MenuID } from '../../../shared/menu/menu-id.model'; import { MenuID } from '../../../shared/menu/menu-id.model';
@@ -21,7 +20,6 @@ import { NgClass } from '@angular/common';
imports: [NgClass, RouterLink, TranslateModule] imports: [NgClass, RouterLink, TranslateModule]
}) })
@rendersSectionForMenu(MenuID.ADMIN, false)
export class AdminSidebarSectionComponent extends MenuSectionComponent implements OnInit { export class AdminSidebarSectionComponent extends MenuSectionComponent implements OnInit {
/** /**

View File

@@ -7,11 +7,10 @@ import { bgColor } from '../../../shared/animations/bgColor';
import { MenuService } from '../../../shared/menu/menu.service'; import { MenuService } from '../../../shared/menu/menu.service';
import { combineLatest as combineLatestObservable, Observable } from 'rxjs'; import { combineLatest as combineLatestObservable, Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorator';
import { MenuID } from '../../../shared/menu/menu-id.model'; import { MenuID } from '../../../shared/menu/menu-id.model';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; 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 * 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] imports: [NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe, TranslateModule]
}) })
@rendersSectionForMenu(MenuID.ADMIN, true)
export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit { export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit {
/** /**
* This section resides in the Admin Sidebar * This section resides in the Admin Sidebar

View File

@@ -13,7 +13,7 @@ import { DSpaceObject } from '../core/shared/dspace-object.model';
import { RemoteData } from '../core/data/remote-data'; import { RemoteData } from '../core/data/remote-data';
import { PAGE_NOT_FOUND_PATH } from '../app-routing-paths'; 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 * A guard taking care of the correct route.data being set for the Browse-By components
*/ */

View File

@@ -1,8 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { ThemedComponent } from '../../shared/theme-support/themed.component'; import { ThemedComponent } from '../../shared/theme-support/themed.component';
import { ExpandableNavbarSectionComponent } from './expandable-navbar-section.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 * Themed wrapper for ExpandableNavbarSectionComponent
@@ -13,7 +11,6 @@ import { MenuID } from '../../shared/menu/menu-id.model';
templateUrl: '../../shared/theme-support/themed.component.html', templateUrl: '../../shared/theme-support/themed.component.html',
standalone: true standalone: true
}) })
@rendersSectionForMenu(MenuID.PUBLIC, true)
export class ThemedExpandableNavbarSectionComponent extends ThemedComponent<ExpandableNavbarSectionComponent> { export class ThemedExpandableNavbarSectionComponent extends ThemedComponent<ExpandableNavbarSectionComponent> {
protected getComponentName(): string { protected getComponentName(): string {
return 'ExpandableNavbarSectionComponent'; return 'ExpandableNavbarSectionComponent';

View File

@@ -1,9 +1,8 @@
import { Component, Inject, Injector, OnInit } from '@angular/core'; import { Component, Inject, Injector, OnInit } from '@angular/core';
import { MenuSectionComponent } from '../../shared/menu/menu-section/menu-section.component'; import { MenuSectionComponent } from '../../shared/menu/menu-section/menu-section.component';
import { MenuService } from '../../shared/menu/menu.service'; import { MenuService } from '../../shared/menu/menu.service';
import { rendersSectionForMenu } from '../../shared/menu/menu-section.decorator';
import { MenuID } from '../../shared/menu/menu-id.model'; 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 * Represents a non-expandable section in the navbar
@@ -15,7 +14,6 @@ import { NgComponentOutlet, AsyncPipe } from '@angular/common';
standalone: true, standalone: true,
imports: [NgComponentOutlet, AsyncPipe] imports: [NgComponentOutlet, AsyncPipe]
}) })
@rendersSectionForMenu(MenuID.PUBLIC, false)
export class NavbarSectionComponent extends MenuSectionComponent implements OnInit { export class NavbarSectionComponent extends MenuSectionComponent implements OnInit {
/** /**
* This section resides in the Public Navbar * This section resides in the Public Navbar

View File

@@ -1,5 +1,4 @@
import { Component, Inject, Injector } from '@angular/core'; 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 { MenuSectionComponent } from 'src/app/shared/menu/menu-section/menu-section.component';
import { MenuService } from '../../../menu/menu.service'; import { MenuService } from '../../../menu/menu.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@@ -9,7 +8,7 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { hasValue } from '../../../empty.util'; import { hasValue } from '../../../empty.util';
import { TranslateModule } from '@ngx-translate/core'; 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'; import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
/** /**
@@ -22,7 +21,6 @@ import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
standalone: true, standalone: true,
imports: [NgbDropdownModule, NgbTooltipModule, NgFor, NgIf, NgComponentOutlet, TranslateModule, AsyncPipe] imports: [NgbDropdownModule, NgbTooltipModule, NgFor, NgIf, NgComponentOutlet, TranslateModule, AsyncPipe]
}) })
@rendersSectionForMenu(MenuID.DSO_EDIT, true)
export class DsoEditMenuExpandableSectionComponent extends MenuSectionComponent { export class DsoEditMenuExpandableSectionComponent extends MenuSectionComponent {
menuID: MenuID = MenuID.DSO_EDIT; menuID: MenuID = MenuID.DSO_EDIT;

View File

@@ -1,5 +1,4 @@
import { Component, Inject, Injector, OnInit } from '@angular/core'; 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 { MenuSectionComponent } from 'src/app/shared/menu/menu-section/menu-section.component';
import { MenuService } from '../../../menu/menu.service'; import { MenuService } from '../../../menu/menu.service';
import { isNotEmpty } from '../../../empty.util'; import { isNotEmpty } from '../../../empty.util';
@@ -20,7 +19,6 @@ import { NgIf } from '@angular/common';
standalone: true, standalone: true,
imports: [NgIf, NgbTooltipModule, RouterLink, TranslateModule] imports: [NgIf, NgbTooltipModule, RouterLink, TranslateModule]
}) })
@rendersSectionForMenu(MenuID.DSO_EDIT, false)
export class DsoEditMenuSectionComponent extends MenuSectionComponent implements OnInit { export class DsoEditMenuSectionComponent extends MenuSectionComponent implements OnInit {
menuID: MenuID = MenuID.DSO_EDIT; menuID: MenuID = MenuID.DSO_EDIT;

View File

@@ -1,9 +1,39 @@
import { DEFAULT_THEME } from '../object-collection/shared/listable-object/listable-object.decorator'; import { DEFAULT_THEME } from '../object-collection/shared/listable-object/listable-object.decorator';
import { MenuID } from './menu-id.model'; import { MenuID } from './menu-id.model';
import { hasValue } from '../empty.util'; 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(); 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 * Decorator function to render a MenuSection for a menu
* @param {MenuID} menuID The ID of the Menu in which the section is rendered * @param {MenuID} menuID The ID of the Menu in which the section is rendered

View File

@@ -1,4 +1,6 @@
import { defer } from 'rxjs'; import { defer } from 'rxjs';
import { StartsWithDateComponent } from './date/starts-with-date.component';
import { StartsWithTextComponent } from './text/starts-with-text.component';
const startsWithMap = new Map(); const startsWithMap = new Map();
@@ -10,8 +12,8 @@ export enum StartsWithType {
date = 'Date' date = 'Date'
} }
startsWithMap.set(StartsWithType.text, defer(() => import('./text/starts-with-text.component').then(m => m.StartsWithTextComponent))); startsWithMap.set(StartsWithType.text, StartsWithTextComponent);
startsWithMap.set(StartsWithType.date, defer(() => import('./date/starts-with-date.component').then(m => m.StartsWithDateComponent))); startsWithMap.set(StartsWithType.date, StartsWithDateComponent);
/** /**

View File

@@ -3,8 +3,6 @@ import {
ExpandableNavbarSectionComponent as BaseComponent ExpandableNavbarSectionComponent as BaseComponent
} from '../../../../../app/navbar/expandable-navbar-section/expandable-navbar-section.component'; } from '../../../../../app/navbar/expandable-navbar-section/expandable-navbar-section.component';
import { slide } from '../../../../../app/shared/animations/slide'; 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 * Represents an expandable section in the navbar
@@ -18,6 +16,5 @@ import { MenuID } from '../../../../../app/shared/menu/menu-id.model';
animations: [slide], animations: [slide],
standalone: true standalone: true
}) })
@rendersSectionForMenu(MenuID.PUBLIC, true)
export class ExpandableNavbarSectionComponent extends BaseComponent { export class ExpandableNavbarSectionComponent extends BaseComponent {
} }