2019-10-16 12:45:01 +02:00
|
|
|
import {Component, Input, OnInit} from '@angular/core';
|
|
|
|
import {RootMenuItem, SideMenuItem} from '../menu';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
2019-04-22 12:32:25 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'sidebar',
|
|
|
|
templateUrl: 'sideBar.component.html'
|
|
|
|
})
|
2019-10-16 12:45:01 +02:00
|
|
|
export class SideBarComponent implements OnInit {
|
2019-04-22 12:32:25 +02:00
|
|
|
@Input() communityId: string = '';
|
|
|
|
@Input() menuItems: SideMenuItem[] = [];
|
2019-10-16 12:45:01 +02:00
|
|
|
currentParams: any = {};
|
2019-04-22 12:32:25 +02:00
|
|
|
|
2019-10-16 12:45:01 +02:00
|
|
|
constructor(private router: Router,
|
|
|
|
private route: ActivatedRoute) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
this.currentParams = params;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private getCurrentRoute(): string {
|
|
|
|
return this.router.url.split('?')[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
isTheActiveMenu(route: string, params: any): boolean {
|
|
|
|
return route === this.getCurrentRoute() &&
|
|
|
|
(!params || JSON.stringify(this.currentParams) === JSON.stringify(params));
|
|
|
|
}
|
2019-04-22 12:32:25 +02:00
|
|
|
}
|