forked from openMF/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtenant-selector.component.ts
More file actions
51 lines (45 loc) · 1.63 KB
/
tenant-selector.component.ts
File metadata and controls
51 lines (45 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Component, OnInit, inject } from '@angular/core';
import { UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
import { SettingsService } from 'app/settings/settings.service';
import { AlertService } from 'app/core/alert/alert.service';
import { MatFormField, MatPrefix, MatLabel } from '@angular/material/form-field';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@Component({
selector: 'mifosx-tenant-selector',
templateUrl: './tenant-selector.component.html',
styleUrls: ['./tenant-selector.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
MatPrefix,
FaIconComponent
]
})
export class TenantSelectorComponent implements OnInit {
private settingsService = inject(SettingsService);
private alertService = inject(AlertService);
/** Tenant selector form control. */
tenantSelector = new UntypedFormControl();
ngOnInit(): void {
this.tenantSelector.setValue(this.settingsService.tenantIdentifier);
if (this.tenants.length > 1) {
this.tenantSelector.enable;
} else {
this.tenantSelector.disable;
}
}
/**
* Returns all the languages supported by the application.
* @return {string[]} Supported languages.
*/
get tenants(): string[] {
return this.settingsService.tenantIdentifiers || [];
}
setTenantIdentifier(): void {
this.settingsService.setTenantIdentifier(this.tenantSelector.value);
this.alertService.alert({ type: 'Tenant Changed', message: this.tenantSelector.value });
}
allowSelection(): boolean {
return this.tenants.length > 1;
}
}