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
Showing
with 175 additions and 264 deletions
...@@ -8,21 +8,27 @@ ...@@ -8,21 +8,27 @@
<vitamui-common-select-language></vitamui-common-select-language> <vitamui-common-select-language></vitamui-common-select-language>
<div class="selection-component"> <div class="selection-component">
<vitamui-common-select-tenant <!-- tenant selection -->
<vitamui-common-item-select
*ngIf="hasTenantSelection" *ngIf="hasTenantSelection"
class="mx-4" class="mx-4"
[tenants]="tenants" [label]="'SELECT-TENANT.SELECT' | translate"
[selectedTenant]="selectedTenant" [selectedLabel]="'SELECT-TENANT.SELECTED' | translate"
(tenantSelected)="updateTenant($event)"> [items]="tenants"
</vitamui-common-select-tenant> [selectedItem]="selectedTenant"
(itemSelected)="updateTenant($event)">
<vitamui-common-select-customer </vitamui-common-item-select>
<!-- customer selection -->
<vitamui-common-item-select
*ngIf="hasCustomerSelection" *ngIf="hasCustomerSelection"
class="mx-4" class="mx-4"
[customers]="customers" [label]="'SELECT-CUSTOMER.SELECT' | translate"
[selectedCustomer]="selectedCustomer" [selectedLabel]="'SELECT-CUSTOMER.SELECTED' | translate"
(customerSelected)="updateCustomer($event)"> [items]="customers"
</vitamui-common-select-customer> [selectedItem]="selectedCustomer"
(itemSelected)="updateCustomer($event)">
</vitamui-common-item-select>
<div class="separator"></div> <div class="separator"></div>
</div> </div>
......
@import '../../../../sass/variables/colors';
mat-toolbar { mat-toolbar {
z-index: 10; z-index: 10;
} }
...@@ -49,11 +47,11 @@ mat-toolbar { ...@@ -49,11 +47,11 @@ mat-toolbar {
} }
.apps-button { .apps-button {
background-color: $white; background-color: white;
} }
.apps-button mat-icon { .apps-button mat-icon {
color: $charcoal-grey; color: var(--vitamui-grey-700);
} }
.vitamui-icon-apps-colored { .vitamui-icon-apps-colored {
......
...@@ -41,13 +41,13 @@ export class HeaderComponent implements OnInit, OnDestroy { ...@@ -41,13 +41,13 @@ export class HeaderComponent implements OnInit, OnDestroy {
private destroyer$ = new Subject(); private destroyer$ = new Subject();
public selectedTenant: Tenant; public selectedTenant: MenuOption;
public selectedCustomer: MenuOption; public selectedCustomer: MenuOption;
public customers: MenuOption[]; public customers: MenuOption[];
public tenants: Tenant[]; public tenants: MenuOption[];
public headerLogoUrl: SafeResourceUrl; public headerLogoUrl: SafeResourceUrl;
...@@ -64,8 +64,10 @@ export class HeaderComponent implements OnInit, OnDestroy { ...@@ -64,8 +64,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
private globalEventService: GlobalEventService) { } private globalEventService: GlobalEventService) { }
ngOnInit() { ngOnInit() {
this.tenants = this.tenantService.getTenants();
this.portalUrl = this.startupService.getPortalUrl(); this.portalUrl = this.startupService.getPortalUrl();
this.tenants = this.tenantService.getTenants().map((tenant: Tenant) => {
return {value: tenant, label: tenant.name};
});
if (this.authService.user) { if (this.authService.user) {
this.currentUser = this.authService.user; this.currentUser = this.authService.user;
...@@ -103,10 +105,10 @@ export class HeaderComponent implements OnInit, OnDestroy { ...@@ -103,10 +105,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.destroyer$)) .pipe(takeUntil(this.destroyer$))
.subscribe((tenant: Tenant) => { .subscribe((tenant: Tenant) => {
if (!this.selectedTenant) { if (!this.selectedTenant) {
this.selectedTenant = tenant; this.selectedTenant = {value: tenant, label: tenant.name};
} else { } else {
if (this.selectedTenant.identifier !== tenant.identifier) { if (this.selectedTenant.value.identifier !== tenant.identifier) {
this.selectedTenant = tenant; this.selectedTenant = {value: tenant, label: tenant.name};
this.tenantService.saveSelectedTenant(tenant).toPromise(); this.tenantService.saveSelectedTenant(tenant).toPromise();
} }
} }
...@@ -117,9 +119,9 @@ export class HeaderComponent implements OnInit, OnDestroy { ...@@ -117,9 +119,9 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.tenantService.getLastTenantIdentifier$() this.tenantService.getLastTenantIdentifier$()
.pipe(takeUntil(this.tenantService.getSelectedTenant$()), takeUntil(this.destroyer$)) .pipe(takeUntil(this.tenantService.getSelectedTenant$()), takeUntil(this.destroyer$))
.subscribe((identifier: number) => { .subscribe((identifier: number) => {
const lastTenant = this.tenants.find(value => value.identifier === identifier); const lastTenant = this.tenants.find((option: MenuOption) => option.value.identifier === identifier);
if (!this.selectedTenant && lastTenant) { if (!this.selectedTenant && lastTenant) {
this.tenantService.setSelectedTenant(lastTenant); this.tenantService.setSelectedTenant(lastTenant.value);
} }
}); });
...@@ -132,8 +134,8 @@ export class HeaderComponent implements OnInit, OnDestroy { ...@@ -132,8 +134,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.destroyer$.complete(); this.destroyer$.complete();
} }
public updateTenant(tenant: Tenant): void { public updateTenant(tenant: MenuOption): void {
this.tenantService.setSelectedTenant(tenant); this.tenantService.setSelectedTenant(tenant.value);
} }
public updateCustomer(customer: MenuOption): void { public updateCustomer(customer: MenuOption): void {
......
...@@ -6,12 +6,10 @@ import { MatMenuModule } from '@angular/material/menu'; ...@@ -6,12 +6,10 @@ import { MatMenuModule } from '@angular/material/menu';
import { MatToolbarModule } from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { HeaderComponent } from './header.component'; import { HeaderComponent } from './header.component';
import { SelectTenantModule } from './select-tenant/select-tenant.module'; import { ItemSelectModule } from './item-select/item-select.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { MenuModule } from './menu/menu.module'; import { MenuModule } from './menu/menu.module';
import { SelectCustomerModule } from './select-customer/select-customer.module'; import { SelectCustomerModule } from './select-customer/select-customer.module';
import { SelectLanguageModule } from './select-language/select-language.module';
import { SelectTenantDialogComponent } from './select-tenant-dialog/select-tenant-dialog.component'; import { SelectTenantDialogComponent } from './select-tenant-dialog/select-tenant-dialog.component';
import { UserPhotoModule } from './user-photo/user-photo.module'; import { UserPhotoModule } from './user-photo/user-photo.module';
...@@ -26,9 +24,7 @@ import { UserPhotoModule } from './user-photo/user-photo.module'; ...@@ -26,9 +24,7 @@ import { UserPhotoModule } from './user-photo/user-photo.module';
MatIconModule, MatIconModule,
MatToolbarModule, MatToolbarModule,
MatButtonModule, MatButtonModule,
SelectTenantModule, ItemSelectModule,
SelectLanguageModule,
SelectCustomerModule,
UserPhotoModule, UserPhotoModule,
MenuModule.forRoot(), MenuModule.forRoot(),
TranslateModule TranslateModule
......
<mat-form-field appearance="fill">
<mat-label *ngIf="selectedItem" class="selected-item-label">{{label}}</mat-label>
<mat-label *ngIf="!selectedItem" class="unselected-item-label">{{selectedLabel}}</mat-label>
<mat-select (selectionChange)="selectItem($event.source.value)" [(value)]="_selectedItem">
<mat-option *ngFor="let item of items" [value]="item.label">
{{ item.label }}
</mat-option>
</mat-select>
</mat-form-field>
\ No newline at end of file
:host::ng-deep {
.selected-item-label, .unselected-item-label {
color: var(--vitamui-grey-600);
font-size: 16px;
}
.mat-form-field-underline {
display: none;
}
.mat-select-value-text {
font-weight: bold;
}
.mat-select-arrow {
color: var(--vitamui-primary);
}
.mat-form-field-wrapper {
padding-bottom: 0;
}
mat-form-field {
border: 1px solid var(--vitamui-grey-300);
background-color: white;
padding-left: 25px;
padding-right: 25px;
border-radius: 50px;
height: 50px;
display: inline-flex;
align-items: center;
}
.mat-form-field-flex {
background-color: white;
padding: 0!important;
}
mat-select {
color: var(--vitamui-grey-900);
font-size: 16px;
}
.mat-form-field-infix {
padding: 0;
}
.mat-select-arrow-wrapper {
vertical-align: inherit;
}
span.mat-select-placeholder {
margin-top: 0.4rem;
}
}
\ No newline at end of file
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MenuOption } from '../../navbar/customer-menu/menu-option.interface';
@Component({
selector: 'vitamui-common-item-select',
templateUrl: './item-select.component.html',
styleUrls: ['./item-select.component.scss']
})
export class ItemSelectComponent {
@Input() label: string;
@Input() selectedLabel: string;
@Input() items: MenuOption[];
@Output() itemSelected = new EventEmitter<MenuOption>();
@Input() set selectedItem(value: MenuOption) {
if (value) {
this._selectedItem = value.label;
}
}
// tslint:disable-next-line: variable-name
public _selectedItem: string;
constructor() { }
public selectItem(itemLabel: string): void {
const item = this.items.find(value => value.label === itemLabel);
this.itemSelected.emit(item);
}
}
...@@ -3,16 +3,16 @@ import { NgModule } from '@angular/core'; ...@@ -3,16 +3,16 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { SelectCustomerComponent } from './select-customer.component'; import { ItemSelectComponent } from './item-select.component';
@NgModule({ @NgModule({
declarations: [SelectCustomerComponent],
imports: [ imports: [
CommonModule, CommonModule,
MatSelectModule,
FormsModule, FormsModule,
MatSelectModule,
TranslateModule TranslateModule
], ],
exports: [SelectCustomerComponent] declarations: [ItemSelectComponent],
exports: [ItemSelectComponent]
}) })
export class SelectCustomerModule { } export class ItemSelectModule { }
...@@ -4,18 +4,21 @@ ...@@ -4,18 +4,21 @@
> >
<div class="row header"> <div class="row header">
<vitamui-common-search-bar <vitamui-common-search-bar
class="col-5" class="col-5 mr-2"
name="category-search" name="category-search"
(searchChanged)="onSearch($event)" (searchChanged)="onSearch($event)"
(clear)="resetSearch()" (clear)="resetSearch()"
placeholder="{{'MENU.GRAB_APPLICATION' | translate}}" placeholder="{{'MENU.GRAB_APPLICATION' | translate}}"
></vitamui-common-search-bar> ></vitamui-common-search-bar>
<vitamui-common-select-tenant class="col-3 p-0 ml-5" <vitamui-common-item-select
[tenants]="tenants" class="col-3 p-0 ml-5"
[selectedTenant]="selectedTenant" [label]="'SELECT-TENANT.SELECT' | translate"
(tenantSelected)="updateApps($event)" [selectedLabel]="'SELECT-TENANT.SELECTED' | translate"
></vitamui-common-select-tenant> [items]="tenants"
[selectedItem]="selectedTenant"
(itemSelected)="updateApps($event)"
></vitamui-common-item-select>
<div class="apps-container col-3 ml-auto" (click)="onClose()"> <div class="apps-container col-3 ml-auto" (click)="onClose()">
<span class="pr-2">{{'MENU.MY_APPLICATIONS' | translate}}</span> <span class="pr-2">{{'MENU.MY_APPLICATIONS' | translate}}</span>
......
...@@ -9,6 +9,7 @@ import { ApplicationService } from '../../../application.service'; ...@@ -9,6 +9,7 @@ import { ApplicationService } from '../../../application.service';
import { Category } from '../../../models'; import { Category } from '../../../models';
import { Application } from '../../../models/application/application.interface'; import { Application } from '../../../models/application/application.interface';
import { TenantSelectionService } from '../../../tenant-selection.service'; import { TenantSelectionService } from '../../../tenant-selection.service';
import { MenuOption } from '../../navbar';
import { Tenant } from './../../../models/customer/tenant.interface'; import { Tenant } from './../../../models/customer/tenant.interface';
import { StartupService } from './../../../startup.service'; import { StartupService } from './../../../startup.service';
import { MenuOverlayRef } from './menu-overlay-ref'; import { MenuOverlayRef } from './menu-overlay-ref';
...@@ -72,9 +73,9 @@ export class MenuComponent implements OnInit, AfterViewInit { ...@@ -72,9 +73,9 @@ export class MenuComponent implements OnInit, AfterViewInit {
private firstResultFocused = false; private firstResultFocused = false;
public selectedTenant: Tenant; public selectedTenant: MenuOption;
public tenants: Tenant[]; public tenants: MenuOption[];
private destroyer$ = new Subject(); private destroyer$ = new Subject();
...@@ -107,16 +108,18 @@ export class MenuComponent implements OnInit, AfterViewInit { ...@@ -107,16 +108,18 @@ export class MenuComponent implements OnInit, AfterViewInit {
ngOnInit() { ngOnInit() {
this.dialogRef.overlay.backdropClick().subscribe(() => this.onClose()); this.dialogRef.overlay.backdropClick().subscribe(() => this.onClose());
this.tenants = this.tenantService.getTenants(); this.tenants = this.tenantService.getTenants().map((tenant: Tenant) => {
return {value: tenant, label: tenant.name};
});
// Display application list depending on the current active tenant. // Display application list depending on the current active tenant.
// If no active tenant is set, then use the last tenant identifier. // If no active tenant is set, then use the last tenant identifier.
this.selectedTenant = this.tenantService.getSelectedTenant(); this.selectedTenant = {value: this.tenantService.getSelectedTenant(), label: this.tenantService.getSelectedTenant().name};
if (this.selectedTenant) { if (this.selectedTenant) {
this.updateApps(this.selectedTenant); this.updateApps(this.selectedTenant);
} else { } else {
this.tenantService.getLastTenantIdentifier$().pipe(takeUntil(this.destroyer$)).subscribe((identifier: number) => { this.tenantService.getLastTenantIdentifier$().pipe(takeUntil(this.destroyer$)).subscribe((identifier: number) => {
this.updateApps(this.tenants.find(value => value.identifier === identifier)); this.updateApps(this.tenants.find(option => option.value.identifier === identifier));
}); });
} }
} }
...@@ -172,13 +175,13 @@ export class MenuComponent implements OnInit, AfterViewInit { ...@@ -172,13 +175,13 @@ export class MenuComponent implements OnInit, AfterViewInit {
public openApplication(app: Application) { public openApplication(app: Application) {
this.onClose(); this.onClose();
this.applicationService. this.applicationService.
openApplication(app, this.router, this.startupService.getConfigStringValue('UI_URL'), this.selectedTenant.identifier); openApplication(app, this.router, this.startupService.getConfigStringValue('UI_URL'), this.selectedTenant.value.identifier);
} }
public updateApps(tenant: Tenant) { public updateApps(tenant: MenuOption) {
if (tenant) { if (tenant) {
this.selectedTenant = tenant; this.selectedTenant = tenant;
this.appMap = this.applicationService.getTenantAppMap(tenant); this.appMap = this.applicationService.getTenantAppMap(tenant.value);
} }
} }
} }
...@@ -10,7 +10,7 @@ import { RouterModule } from '@angular/router'; ...@@ -10,7 +10,7 @@ import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { PipesModule } from '../../../pipes/pipes.module'; import { PipesModule } from '../../../pipes/pipes.module';
import { SearchBarModule } from '../../search-bar/search-bar.module'; import { SearchBarModule } from '../../search-bar/search-bar.module';
import { SelectTenantModule } from '../select-tenant/select-tenant.module'; import { ItemSelectModule } from '../item-select/item-select.module';
import { MenuApplicationTileComponent } from './menu-application-tile/menu-application-tile.component'; import { MenuApplicationTileComponent } from './menu-application-tile/menu-application-tile.component';
import { MenuOverlayService } from './menu-overlay.service'; import { MenuOverlayService } from './menu-overlay.service';
import { MenuComponent } from './menu.component'; import { MenuComponent } from './menu.component';
...@@ -33,7 +33,7 @@ import { MenuComponent } from './menu.component'; ...@@ -33,7 +33,7 @@ import { MenuComponent } from './menu.component';
SearchBarModule, SearchBarModule,
PipesModule, PipesModule,
TranslateModule, TranslateModule,
SelectTenantModule ItemSelectModule
], ],
entryComponents: [ entryComponents: [
MenuComponent MenuComponent
......
<mat-form-field appearance="fill">
<mat-label *ngIf="selectedCustomer" class="selected-customer-label">{{'SELECT-CUSTOMER.SELECTED' | translate}}</mat-label>
<mat-label *ngIf="!selectedCustomer" class="unselected-customer-label">{{'SELECT-CUSTOMER.SELECT' | translate}}</mat-label>
<mat-select (selectionChange)="selectCustomer($event.source.value)" [(value)]="selectedCustomer">
<mat-option *ngFor="let customer of customers" [value]="customer">
{{ customer.label }}
</mat-option>
</mat-select>
</mat-form-field>
\ No newline at end of file
@import '../../../../../sass/variables/colors';
:host::ng-deep {
.selected-customer-label, .unselected-customer-label {
color: var(--vitamui-grey-600);
font-size: 16px;
}
.mat-form-field-underline {
display: none;
}
.mat-select-value-text {
font-weight: bold;
}
.mat-select-arrow {
color: var(--vitamui-primary);
}
.mat-form-field-wrapper {
padding-bottom: 0;
}
mat-form-field {
border: 1px solid var(--vitamui-grey-300);
background-color: white;
padding-left: 25px;
padding-right: 25px;
border-radius: 50px;
height: 50px;
display: inline-flex;
align-items: center;
}
.mat-form-field-flex {
background-color: white;
padding: 0!important;
}
mat-select {
color: var(--vitamui-grey-900);
font-size: 16px;
}
.mat-form-field-infix {
padding: 0;
}
.mat-select-arrow-wrapper {
vertical-align: inherit;
}
span.mat-select-placeholder {
margin-top: 0.4rem;
}
}
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Subject } from 'rxjs';
import { Customer } from '../../../models/customer/customer.interface';
import { MenuOption } from '../../navbar/customer-menu/menu-option.interface';
@Component({
selector: 'vitamui-common-select-customer',
templateUrl: './select-customer.component.html',
styleUrls: ['./select-customer.component.scss']
})
export class SelectCustomerComponent implements OnInit, OnDestroy {
@Input() customers: MenuOption[];
@Input() selectedCustomer: MenuOption;
@Output() customerSelected = new EventEmitter<MenuOption>();
private destroyer$ = new Subject();
constructor() { }
ngOnInit() { }
ngOnDestroy() {
this.destroyer$.next();
this.destroyer$.complete();
}
public selectCustomer(customer: MenuOption): void {
this.selectedCustomer = customer;
this.customerSelected.emit(this.selectedCustomer);
}
}
...@@ -3,7 +3,13 @@ ...@@ -3,7 +3,13 @@
<h2 class="col-12">{{ 'SELECT-TENANT.DIALOG_SUBTITLE' | translate }}</h2> <h2 class="col-12">{{ 'SELECT-TENANT.DIALOG_SUBTITLE' | translate }}</h2>
<p class="col-12">{{ 'SELECT-TENANT.DIALOG_INSTRUCTIONS' | translate }} <span class="asterix">*</span></p> <p class="col-12">{{ 'SELECT-TENANT.DIALOG_INSTRUCTIONS' | translate }} <span class="asterix">*</span></p>
<vitamui-common-select-tenant class="col-12" (tenantSelected)="selectedTenant = $event" [tenants]="tenants"></vitamui-common-select-tenant> <vitamui-common-item-select
class="col-12"
[label]="'SELECT-TENANT.SELECT' | translate"
[selectedLabel]="'SELECT-TENANT.SELECTED' | translate"
(itemSelected)="selectedTenant = $event"
[items]="tenants">
</vitamui-common-item-select>
<button class="col-12 btn primary" [disabled]="!selectedTenant" (click)="closeDialog()">{{ 'SELECT-TENANT.DIALOG_BUTTON_LABEL' | translate }}</button> <button class="col-12 btn primary" [disabled]="!selectedTenant" (click)="closeDialog()">{{ 'SELECT-TENANT.DIALOG_BUTTON_LABEL' | translate }}</button>
<p><span class="asterix">*</span> {{ 'SELECT-TENANT.DIALOG_MESSAGE' | translate }}</p> <p><span class="asterix">*</span> {{ 'SELECT-TENANT.DIALOG_MESSAGE' | translate }}</p>
......
...@@ -2,6 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatDialogConfig, MatDialogRef } from '@angular/material/dialog'; import { MatDialogConfig, MatDialogRef } from '@angular/material/dialog';
import { Tenant } from '../../../models/customer/tenant.interface'; import { Tenant } from '../../../models/customer/tenant.interface';
import { MenuOption } from '../../navbar';
@Component({ @Component({
selector: 'vitamui-common-select-tenant-dialog', selector: 'vitamui-common-select-tenant-dialog',
...@@ -15,19 +16,21 @@ export class SelectTenantDialogComponent implements OnInit { ...@@ -15,19 +16,21 @@ export class SelectTenantDialogComponent implements OnInit {
disableClose: true, disableClose: true,
}; };
public selectedTenant: Tenant; public selectedTenant: MenuOption;
public tenants: Tenant[]; public tenants: MenuOption[];
constructor(private dialogRef: MatDialogRef<SelectTenantDialogComponent>, @Inject(MAT_DIALOG_DATA) private data: any) { } constructor(private dialogRef: MatDialogRef<SelectTenantDialogComponent>, @Inject(MAT_DIALOG_DATA) private data: any) { }
ngOnInit() { ngOnInit() {
this.tenants = this.data.tenants; this.tenants = this.data.tenants.getTenants().map((tenant: Tenant) => {
return {value: tenant, label: tenant.name};
});
} }
public closeDialog(): void { public closeDialog(): void {
if (this.selectedTenant) { if (this.selectedTenant) {
this.dialogRef.close(this.selectedTenant); this.dialogRef.close(this.selectedTenant.value);
} }
} }
......
...@@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common'; ...@@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { SelectTenantModule } from '../select-tenant/select-tenant.module'; import { ItemSelectModule } from '../item-select/item-select.module';
import { SelectTenantDialogComponent } from './select-tenant-dialog.component'; import { SelectTenantDialogComponent } from './select-tenant-dialog.component';
@NgModule({ @NgModule({
...@@ -12,8 +12,8 @@ import { SelectTenantDialogComponent } from './select-tenant-dialog.component'; ...@@ -12,8 +12,8 @@ import { SelectTenantDialogComponent } from './select-tenant-dialog.component';
imports: [ imports: [
CommonModule, CommonModule,
MatButtonModule, MatButtonModule,
SelectTenantModule, TranslateModule,
TranslateModule ItemSelectModule
], ],
exports: [ exports: [
SelectTenantDialogComponent SelectTenantDialogComponent
......
<mat-form-field appearance="fill">
<mat-label *ngIf="selectedTenant" class="selected-tenant-label">{{'SELECT-TENANT.SELECTED' | translate}}</mat-label>
<mat-label *ngIf="!selectedTenant" class="unselected-tenant-label">{{'SELECT-TENANT.SELECT' | translate}}</mat-label>
<mat-select (selectionChange)="selectTenant($event.source.value)" [(value)]="selectedTenant">
<mat-option *ngFor="let tenant of tenants" [value]="tenant">
{{ tenant.name }}
</mat-option>
</mat-select>
</mat-form-field>
\ No newline at end of file
:host::ng-deep {
.selected-tenant-label, .unselected-tenant-label {
color: var(--vitamui-grey-600);
font-size: 16px;
}
.mat-form-field-underline {
display: none;
}
.mat-select-value-text {
font-weight: bold;
color: #485053;
}
.mat-select-arrow {
color: var(--vitamui-primary);
}
.mat-form-field-wrapper {
padding-bottom: 0;
}
mat-form-field {
border: 1px solid var(--vitamui-grey-300);
background-color: white;
padding-left: 25px;
padding-right: 25px;
border-radius: 50px;
height: 50px;
display: inline-flex;
align-items: center;
}
.mat-form-field-flex {
background-color: white;
padding: 0!important;
}
mat-select {
color: var(--vitamui-grey-900);
font-size: 16px;
}
.mat-form-field-infix {
padding: 0;
}
.mat-select-arrow-wrapper {
vertical-align: inherit;
}
span.mat-select-placeholder {
margin-top: 0.4rem;
}
}
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Subject } from 'rxjs';
import { Tenant } from '../../../models/customer/tenant.interface';
@Component({
selector: 'vitamui-common-select-tenant',
templateUrl: './select-tenant.component.html',
styleUrls: ['./select-tenant.component.scss']
})
export class SelectTenantComponent implements OnInit, OnDestroy {
/** Available tenant list to display */
@Input() tenants: Tenant[];
/** Current tenant in the select box */
@Input() selectedTenant: Tenant;
@Output() tenantSelected = new EventEmitter<Tenant>();
private destroyer$ = new Subject();
constructor() { }
ngOnInit() { }
ngOnDestroy() {
this.destroyer$.next();
this.destroyer$.complete();
}
public selectTenant(tenant: Tenant): void {
this.selectedTenant = tenant;
this.tenantSelected.emit(this.selectedTenant);
}
}
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