mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 11:33:04 +00:00
57053: intermediate commit active issue
This commit is contained in:
48
src/app/shared/menu/menu.component.ts
Normal file
48
src/app/shared/menu/menu.component.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { 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 { getComponentForMenu } from './menu.decorator';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
import { MenuSectionComponent } from './menu-section/menu-section.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-menu',
|
||||
template: ''
|
||||
})
|
||||
export class MenuComponent implements OnInit {
|
||||
menuID: MenuID;
|
||||
menuCollapsed: Observable<boolean>;
|
||||
sections: Observable<MenuSection[]>;
|
||||
|
||||
constructor(protected menuService: MenuService, protected injector: Injector) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID);
|
||||
this.sections = this.menuService.getMenuTopSections(this.menuID);
|
||||
}
|
||||
|
||||
toggle(event: Event) {
|
||||
event.preventDefault();
|
||||
this.menuService.toggleMenu(this.menuID);
|
||||
}
|
||||
|
||||
getSectionComponent(section: MenuSection): Observable<GenericConstructor<MenuSectionComponent>> {
|
||||
return this.menuService.hasSubSections(this.menuID, section.id).pipe(
|
||||
map((expandable: boolean) => {
|
||||
return getComponentForMenu(this.menuID, expandable);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
getSectionDataInjector(section: MenuSection) {
|
||||
return Injector.create({
|
||||
providers: [{ provide: 'sectionDataProvider', useFactory: () => (section), deps: [] }],
|
||||
parent: this.injector
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user