35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import {Component, Input, OnInit} from '@angular/core';
|
|
import {MenuItem} from "../../../sharedComponents/menu";
|
|
import {Router} from "@angular/router";
|
|
|
|
@Component({
|
|
selector: 'dashboard-sidebar',
|
|
templateUrl: 'sideBar.component.html'
|
|
})
|
|
export class SideBarComponent implements OnInit {
|
|
@Input() items: MenuItem[] = [];
|
|
@Input() headerName: string;
|
|
@Input() headerDashboard: string;
|
|
@Input() headerLogoUrl: string;
|
|
@Input() showHeader: boolean = true;
|
|
@Input() activeItem: string = '';
|
|
@Input() activeSubItem: string = '';
|
|
|
|
constructor(private router: Router) {}
|
|
|
|
ngOnInit(): void {}
|
|
|
|
|
|
isTheActiveMenuItem(item: MenuItem, subItem: MenuItem = null): boolean {
|
|
if(this.activeItem || this.activeSubItem){
|
|
return (!subItem && this.activeItem === item.id) ||
|
|
(subItem && this.activeItem === item.id && this.activeSubItem === subItem.id);
|
|
}else {
|
|
if(subItem){
|
|
return MenuItem.isTheActiveMenu(subItem,this.router.url.split('?')[0])
|
|
}
|
|
return MenuItem.isTheActiveMenu(item,this.router.url.split('?')[0])
|
|
}
|
|
}
|
|
}
|