Skip to content
Snippets Groups Projects
Commit 5c8b48fe authored by Delphine's avatar Delphine Committed by pybelecalo
Browse files

[US TRTL-519] Tenant & customer header selection refactoring

parent b5bdd7c6
No related branches found
No related tags found
No related merge requests found
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core';
import { SelectTenantComponent } from './select-tenant.component';
@NgModule({
declarations: [SelectTenantComponent],
imports: [
CommonModule,
MatSelectModule,
FormsModule,
TranslateModule,
],
exports: [SelectTenantComponent]
})
export class SelectTenantModule { }
......@@ -34,10 +34,13 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*/
import { Component } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { ApplicationId } from '../../application-id.enum';
import { GlobalEventService } from '../../global-event.service';
import { MenuOption } from '../navbar/customer-menu/menu-option.interface';
@Component({
......@@ -45,21 +48,33 @@ import { MenuOption } from '../navbar/customer-menu/menu-option.interface';
templateUrl: './vitamui-customer-select.component.html',
styleUrls: ['./vitamui-customer-select.component.scss']
})
export class VitamUICustomerSelectComponent {
export class VitamUICustomerSelectComponent implements OnInit, OnDestroy {
appId: ApplicationId;
hideTenantMenu = true;
hideCustomerMenu = false;
customers: MenuOption[];
public customers: MenuOption[];
constructor(private router: Router, private route: ActivatedRoute) {
this.route.data.subscribe((data) => {
this.customers = data.customers;
this.appId = data.appId;
private destroyer$ = new Subject();
constructor(
private router: Router,
private route: ActivatedRoute,
private globalEventService: GlobalEventService) { }
ngOnInit() {
this.route.data.pipe(takeUntil(this.destroyer$))
.subscribe((data) => {
this.customers = data.customers;
});
this.globalEventService.customerEvent.pipe(takeUntil(this.destroyer$))
.subscribe((customerId: string) => this.selectCustomer(customerId));
}
ngOnDestroy() {
this.destroyer$.next();
this.destroyer$.complete();
}
selectCustomerInNavbar(customerId: Event) {
selectCustomer(customerId: string): void {
this.router.navigate(['./' + customerId], { relativeTo: this.route });
}
......
......@@ -40,7 +40,6 @@ import { APP_INITIALIZER, NgModule } from '@angular/core';
import { MatDialogModule } from '@angular/material/dialog';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { CommonTooltipModule } from './components/common-tooltip/common-tooltip.module';
import { SelectTenantModule } from './components/header/select-tenant/select-tenant.module';
import { VitamuiBodyModule } from './components/vitamui-body/vitamui-body.module';
import { VitamUIDisplayNodeModule } from './components/vitamui-display-node/vitamui-display-node.module';
import { LoggerModule } from './logger/logger.module';
......@@ -140,7 +139,6 @@ export function startupServiceFactory(startupService: StartupService) {
LoggerModule,
NavbarModule,
HeaderModule,
SelectTenantModule,
SelectTenantDialogModule,
OrderByButtonModule,
OrderDropdownModule,
......@@ -191,7 +189,6 @@ export function startupServiceFactory(startupService: StartupService) {
LoggerModule,
NavbarModule,
HeaderModule,
SelectTenantModule,
SelectTenantDialogModule,
OrderByButtonModule,
OrderDropdownModule,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment