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