admin-sidebar-section.component.ts (dspace-angular-dspace-7.0) | : | admin-sidebar-section.component.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
import { Component, Inject, Injector, OnInit } from '@angular/core'; | import { Component, Inject, Injector, OnInit } from '@angular/core'; | |||
import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-sec tion.component'; | import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-sec tion.component'; | |||
import { MenuID } from '../../../shared/menu/initial-menus-state'; | import { MenuID } from '../../../shared/menu/initial-menus-state'; | |||
import { MenuService } from '../../../shared/menu/menu.service'; | import { MenuService } from '../../../shared/menu/menu.service'; | |||
import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorat or'; | import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorat or'; | |||
import { LinkMenuItemModel } from '../../../shared/menu/menu-item/models/link.mo del'; | import { LinkMenuItemModel } from '../../../shared/menu/menu-item/models/link.mo del'; | |||
import { MenuSection } from '../../../shared/menu/menu.reducer'; | import { MenuSection } from '../../../shared/menu/menu.reducer'; | |||
import { isNotEmpty } from '../../../shared/empty.util'; | ||||
import { Router } from '@angular/router'; | ||||
/** | /** | |||
* Represents a non-expandable section in the admin sidebar | * Represents a non-expandable section in the admin sidebar | |||
*/ | */ | |||
@Component({ | @Component({ | |||
selector: 'ds-admin-sidebar-section', | /* tslint:disable:component-selector */ | |||
selector: 'li[ds-admin-sidebar-section]', | ||||
templateUrl: './admin-sidebar-section.component.html', | templateUrl: './admin-sidebar-section.component.html', | |||
styleUrls: ['./admin-sidebar-section.component.scss'], | styleUrls: ['./admin-sidebar-section.component.scss'], | |||
}) | }) | |||
@rendersSectionForMenu(MenuID.ADMIN, false) | @rendersSectionForMenu(MenuID.ADMIN, false) | |||
export class AdminSidebarSectionComponent extends MenuSectionComponent implement s OnInit { | export class AdminSidebarSectionComponent extends MenuSectionComponent implement s OnInit { | |||
/** | /** | |||
* This section resides in the Admin Sidebar | * This section resides in the Admin Sidebar | |||
*/ | */ | |||
menuID: MenuID = MenuID.ADMIN; | menuID: MenuID = MenuID.ADMIN; | |||
itemModel; | itemModel; | |||
constructor(@Inject('sectionDataProvider') menuSection: MenuSection, protected | hasLink: boolean; | |||
menuService: MenuService, protected injector: Injector,) { | constructor( | |||
@Inject('sectionDataProvider') menuSection: MenuSection, | ||||
protected menuService: MenuService, | ||||
protected injector: Injector, | ||||
protected router: Router, | ||||
) { | ||||
super(menuSection, menuService, injector); | super(menuSection, menuService, injector); | |||
this.itemModel = menuSection.model as LinkMenuItemModel; | this.itemModel = menuSection.model as LinkMenuItemModel; | |||
} | } | |||
ngOnInit(): void { | ngOnInit(): void { | |||
this.hasLink = isNotEmpty(this.itemModel?.link); | ||||
super.ngOnInit(); | super.ngOnInit(); | |||
} | } | |||
navigate(event: any): void { | ||||
event.preventDefault(); | ||||
if (this.hasLink) { | ||||
this.router.navigate(this.itemModel.link); | ||||
} | ||||
} | ||||
} | } | |||
End of changes. 5 change blocks. | ||||
3 lines changed or deleted | 19 lines changed or added |