UI: Rename default state controller to static

This commit is contained in:
Vladyslav_Prykhodko 2023-12-19 16:08:05 +02:00
parent 45796d253f
commit ca8eda8aa7
3 changed files with 18 additions and 10 deletions

View File

@ -34,7 +34,7 @@
<mat-label translate>dashboard.state-controller</mat-label>
<mat-select required formControlName="stateControllerId">
<mat-option *ngFor="let stateControllerId of stateControllerIds" [value]="stateControllerId">
{{stateControllerId}}
{{ getStatesControllerTranslation(stateControllerId) }}
</mat-option>
</mat-select>
</mat-form-field>

View File

@ -19,14 +19,12 @@ import { ErrorStateMatcher } from '@angular/material/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, FormGroupDirective, NgForm, Validators } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { DialogComponent } from '@app/shared/components/dialog.component';
import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core';
import { DashboardSettings, GridSettings, StateControllerId } from '@app/shared/models/dashboard.models';
import { isDefined, isUndefined } from '@core/utils';
import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
import { StatesControllerService } from './states/states-controller.service';
export interface DashboardSettingsDialogData {
@ -46,21 +44,23 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
settings: DashboardSettings;
gridSettings: GridSettings;
settingsFormGroup: UntypedFormGroup;
gridSettingsFormGroup: UntypedFormGroup;
settingsFormGroup: FormGroup;
gridSettingsFormGroup: FormGroup;
stateControllerIds: string[];
submitted = false;
private stateControllerTranslationMap = new Map<string, string>([
['default', 'dashboard.state-controller-default'],
]);
constructor(protected store: Store<AppState>,
protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: DashboardSettingsDialogData,
@SkipSelf() private errorStateMatcher: ErrorStateMatcher,
public dialogRef: MatDialogRef<DashboardSettingsDialogComponent, DashboardSettingsDialogData>,
private fb: UntypedFormBuilder,
private utils: UtilsService,
private dashboardUtils: DashboardUtilsService,
private fb: FormBuilder,
private translate: TranslateService,
private statesControllerService: StatesControllerService) {
super(store, router, dialogRef);
@ -182,7 +182,7 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
ngOnInit(): void {
}
isErrorState(control: UntypedFormControl | null, form: FormGroupDirective | NgForm | null): boolean {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const originalErrorState = this.errorStateMatcher.isErrorState(control, form);
const customErrorState = !!(control && control.invalid && this.submitted);
return originalErrorState || customErrorState;
@ -204,4 +204,11 @@ export class DashboardSettingsDialogComponent extends DialogComponent<DashboardS
}
this.dialogRef.close({settings, gridSettings});
}
getStatesControllerTranslation(stateControllerId: string): string {
if (this.stateControllerTranslationMap.has(stateControllerId)) {
return this.translate.instant(this.stateControllerTranslationMap.get(stateControllerId));
}
return stateControllerId;
}
}

View File

@ -1186,6 +1186,7 @@
"hide-details": "Hide details",
"select-state": "Select target state",
"state-controller": "State controller",
"state-controller-default": "static (deprecated)",
"search": "Search dashboards",
"selected-dashboards": "{ count, plural, =1 {1 dashboard} other {# dashboards} } selected",
"home-dashboard": "Home dashboard",