Browse Source

UI: changed validation hints of add telemetry dialog to more precise

pull/9218/head
rusikv 3 years ago
parent
commit
0519fc8eaf
  1. 6
      ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html
  2. 5
      ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.ts
  3. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

6
ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html

@ -17,7 +17,7 @@
--> -->
<form [formGroup]="attributeFormGroup" (ngSubmit)="add()" style="min-width: 400px;"> <form [formGroup]="attributeFormGroup" (ngSubmit)="add()" style="min-width: 400px;">
<mat-toolbar color="primary"> <mat-toolbar color="primary">
<h2>{{ title | translate }}</h2> <h2>{{ (isTelemetry ? 'attribute.add-telemetry' : 'attribute.add') | translate }}</h2>
<span fxFlex></span> <span fxFlex></span>
<button mat-icon-button <button mat-icon-button
(click)="cancel()" (click)="cancel()"
@ -34,7 +34,7 @@
<mat-label translate>attribute.key</mat-label> <mat-label translate>attribute.key</mat-label>
<input matInput formControlName="key" required> <input matInput formControlName="key" required>
<mat-error *ngIf="attributeFormGroup.get('key').hasError('required')"> <mat-error *ngIf="attributeFormGroup.get('key').hasError('required')">
{{ 'attribute.key-required' | translate }} {{ (isTelemetry ? 'attribute.telemetry-key-required' : 'attribute.key-required') | translate }}
</mat-error> </mat-error>
<mat-error *ngIf="attributeFormGroup.get('key').hasError('maxlength')"> <mat-error *ngIf="attributeFormGroup.get('key').hasError('maxlength')">
{{ 'attribute.key-max-length' | translate }} {{ 'attribute.key-max-length' | translate }}
@ -42,7 +42,7 @@
</mat-form-field> </mat-form-field>
<tb-value-input <tb-value-input
formControlName="value" formControlName="value"
requiredText="attribute.value-required"> [requiredText]="isTelemetry ? 'attribute.telemetry-value-required' : 'attribute.value-required'">
</tb-value-input> </tb-value-input>
</fieldset> </fieldset>
</div> </div>

5
ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.ts

@ -45,7 +45,7 @@ export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDia
submitted = false; submitted = false;
title = ''; isTelemetry = false;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
protected router: Router, protected router: Router,
@ -62,8 +62,7 @@ export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDia
key: ['', [Validators.required, Validators.maxLength(255)]], key: ['', [Validators.required, Validators.maxLength(255)]],
value: [null, [Validators.required]] value: [null, [Validators.required]]
}); });
this.title = this.data.attributeScope === LatestTelemetry.LATEST_TELEMETRY ? this.isTelemetry = this.data.attributeScope === LatestTelemetry.LATEST_TELEMETRY;
'attribute.add-telemetry' : 'attribute.add'
} }
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -722,6 +722,8 @@
"key-required": "Attribute key is required.", "key-required": "Attribute key is required.",
"value": "Value", "value": "Value",
"value-required": "Attribute value is required.", "value-required": "Attribute value is required.",
"telemetry-key-required": "Telemetry key is required",
"telemetry-value-required": "Telemetry value is required",
"delete-attributes-title": "Are you sure you want to delete { count, plural, =1 {1 attribute} other {# attributes} }?", "delete-attributes-title": "Are you sure you want to delete { count, plural, =1 {1 attribute} other {# attributes} }?",
"delete-attributes-text": "Be careful, after the confirmation all selected attributes will be removed.", "delete-attributes-text": "Be careful, after the confirmation all selected attributes will be removed.",
"delete-attributes": "Delete attributes", "delete-attributes": "Delete attributes",

Loading…
Cancel
Save