TSK-1815: Merged administration titles
This commit is contained in:
parent
df40c6dad9
commit
4c674f5111
|
@ -37,7 +37,7 @@ export class WorkbasketDistributionTargetsComponent implements OnInit, OnDestroy
|
|||
destroy$ = new Subject<void>();
|
||||
private selectedWorkbasket: WorkbasketSummary;
|
||||
|
||||
constructor(private notificationsService: NotificationService, private store: Store, private ngxsActions$: Actions) {}
|
||||
constructor(private notificationsService: NotificationService, private store: Store) {}
|
||||
|
||||
/**
|
||||
* Rework with modification based on old components,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
import { FormsValidatorService } from 'app/shared/services/forms-validator/forms-validator.service';
|
||||
import { SidenavService } from './shared/services/sidenav/sidenav.service';
|
||||
|
@ -27,6 +27,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
toggle: boolean = false;
|
||||
|
||||
destroy$ = new Subject<void>();
|
||||
@ViewChild('sidenav') public sidenav: MatSidenav;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
|
@ -44,11 +45,9 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
this.orientationService.onResize();
|
||||
}
|
||||
|
||||
@ViewChild('sidenav') public sidenav: MatSidenav;
|
||||
|
||||
ngOnInit() {
|
||||
this.router.events.pipe(takeUntil(this.destroy$)).subscribe((event) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.selectedRouteService.selectRoute(event);
|
||||
this.formsValidatorService.formSubmitAttempt = false;
|
||||
}
|
||||
|
|
|
@ -53,19 +53,11 @@ describe('NavBarComponent', () => {
|
|||
});
|
||||
|
||||
it('should set title to workbasket if workbasket ist selected', () => {
|
||||
route = 'workbaskets';
|
||||
route = 'administration';
|
||||
fixture.detectChanges();
|
||||
component.setTitle(route);
|
||||
expect(component.title).toBe('Workbaskets');
|
||||
expect(component.title).toBe('Administration');
|
||||
});
|
||||
|
||||
it('should set title to classification if classification ist selected', () => {
|
||||
route = 'classifications';
|
||||
fixture.detectChanges();
|
||||
component.setTitle(route);
|
||||
expect(component.title).toBe('Classifications');
|
||||
});
|
||||
|
||||
it('should set title to monitor if monitor ist selected', () => {
|
||||
route = 'monitor';
|
||||
fixture.detectChanges();
|
||||
|
@ -80,13 +72,6 @@ describe('NavBarComponent', () => {
|
|||
expect(component.title).toBe('Workplace');
|
||||
});
|
||||
|
||||
it('should set title to access-items if access-items ist selected', () => {
|
||||
route = 'access-items';
|
||||
fixture.detectChanges();
|
||||
component.setTitle(route);
|
||||
expect(component.title).toBe('Access items');
|
||||
});
|
||||
|
||||
it('should set title to history if history ist selected', () => {
|
||||
route = 'history';
|
||||
fixture.detectChanges();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { SelectedRouteService } from 'app/shared/services/selected-route/selected-route';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Subject } from 'rxjs';
|
||||
import { expandRight } from 'app/shared/animations/expand.animation';
|
||||
import { SidenavService } from '../../services/sidenav/sidenav.service';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-shared-nav-bar',
|
||||
|
@ -12,26 +13,26 @@ import { SidenavService } from '../../services/sidenav/sidenav.service';
|
|||
})
|
||||
export class NavBarComponent implements OnInit {
|
||||
selectedRoute = '';
|
||||
titleWorkbaskets = 'Workbaskets';
|
||||
titleClassifications = 'Classifications';
|
||||
titleAccessItems = 'Access items';
|
||||
titleAdministration = 'Administration';
|
||||
titleMonitor = 'Monitor';
|
||||
titleWorkplace = 'Workplace';
|
||||
titleHistory = 'History';
|
||||
titleSettings = 'Settings';
|
||||
toggle: boolean = false;
|
||||
title = this.titleWorkplace;
|
||||
title = '';
|
||||
|
||||
selectedRouteSubscription: Subscription;
|
||||
destroy$ = new Subject();
|
||||
|
||||
constructor(private selectedRouteService: SelectedRouteService, private sidenavService: SidenavService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.selectedRouteSubscription = this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
|
||||
// does not work
|
||||
this.selectedRoute = value;
|
||||
this.setTitle(value);
|
||||
});
|
||||
this.selectedRouteService
|
||||
.getSelectedRoute()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((value: string) => {
|
||||
this.selectedRoute = value;
|
||||
this.setTitle(value);
|
||||
});
|
||||
}
|
||||
|
||||
toggleSidenav() {
|
||||
|
@ -40,16 +41,12 @@ export class NavBarComponent implements OnInit {
|
|||
}
|
||||
|
||||
setTitle(value: string = '') {
|
||||
if (value.includes('workbaskets')) {
|
||||
this.title = this.titleWorkbaskets;
|
||||
} else if (value.includes('classifications')) {
|
||||
this.title = this.titleClassifications;
|
||||
if (value.includes('administration')) {
|
||||
this.title = this.titleAdministration;
|
||||
} else if (value.includes('monitor')) {
|
||||
this.title = this.titleMonitor;
|
||||
} else if (value.includes('workplace')) {
|
||||
this.title = this.titleWorkplace;
|
||||
} else if (value.includes('access-items')) {
|
||||
this.title = this.titleAccessItems;
|
||||
} else if (value.includes('history')) {
|
||||
this.title = this.titleHistory;
|
||||
} else if (value.includes('settings')) {
|
||||
|
|
|
@ -1,24 +1,16 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class SelectedRouteService {
|
||||
public selectedRouteTriggered = new Subject<string>();
|
||||
|
||||
private detailRoutes: Array<string> = [
|
||||
'workplace',
|
||||
'administration/workbaskets',
|
||||
'administration/classifications',
|
||||
'monitor',
|
||||
'administration/access-items-management',
|
||||
'history',
|
||||
'settings'
|
||||
];
|
||||
private detailRoutes: Array<string> = ['workplace', 'administration', 'monitor', 'history', 'settings'];
|
||||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
selectRoute(value) {
|
||||
selectRoute(value: NavigationEnd): void {
|
||||
this.selectedRouteTriggered.next(this.getRoute(value));
|
||||
}
|
||||
|
||||
|
@ -26,11 +18,11 @@ export class SelectedRouteService {
|
|||
return this.selectedRouteTriggered.asObservable();
|
||||
}
|
||||
|
||||
private getRoute(event): string {
|
||||
private getRoute(event: NavigationEnd): string {
|
||||
if (!event) {
|
||||
return this.checkUrl(this.router.url);
|
||||
}
|
||||
return this.checkUrl(event.url);
|
||||
return this.checkUrl(event.urlAfterRedirects);
|
||||
}
|
||||
|
||||
private checkUrl(url: string): string {
|
||||
|
|
Loading…
Reference in New Issue