mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
finished dynamic menus
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Component, Injector, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Injector, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { MenuService } from '../../shared/menu/menu.service';
|
||||
import { MenuID } from '../../shared/menu/initial-menus-state';
|
||||
import { MenuSection } from '../../shared/menu/menu.reducer';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
import { getComponentForMenu } from './menu.decorator';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
import { MenuSectionComponent } from './menu-section/menu-section.component';
|
||||
@@ -15,14 +15,25 @@ import { MenuSectionComponent } from './menu-section/menu-section.component';
|
||||
export class MenuComponent implements OnInit {
|
||||
menuID: MenuID;
|
||||
menuCollapsed: Observable<boolean>;
|
||||
menuVisible: Observable<boolean>;
|
||||
sections: Observable<MenuSection[]>;
|
||||
sectionInjectors: Map<string, Injector> = new Map<string, Injector>();
|
||||
sectionComponents: Map<string, GenericConstructor<MenuSectionComponent>> = new Map<string, GenericConstructor<MenuSectionComponent>>();
|
||||
changeDetection: ChangeDetectionStrategy.OnPush;
|
||||
|
||||
constructor(protected menuService: MenuService, protected injector: Injector) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID);
|
||||
this.sections = this.menuService.getMenuTopSections(this.menuID);
|
||||
this.menuVisible = this.menuService.isMenuVisible(this.menuID);
|
||||
this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(first());
|
||||
this.sections.subscribe((sections: MenuSection[]) => {
|
||||
sections.forEach((section: MenuSection) => {
|
||||
this.sectionInjectors.set(section.id, this.getSectionDataInjector(section));
|
||||
this.getSectionComponent(section).pipe(first()).subscribe((constr) => this.sectionComponents.set(section.id, constr));
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
toggle(event: Event) {
|
||||
|
Reference in New Issue
Block a user