Browse Source

Added validators

pull/15394/head
Maksym Tsymbarov 6 months ago
parent
commit
b15c8fd52c
  1. 15
      ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts
  2. 2
      ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html

15
ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts

@ -22,6 +22,7 @@ import {
NG_VALUE_ACCESSOR,
ValidationErrors,
Validator,
Validators,
} from '@angular/forms';
import {
EntityKeyValueType,
@ -135,10 +136,24 @@ export class FilterPredicateComponent implements ControlValueAccessor, Validator
writeValue(predicate: KeyFilterPredicateInfo): void {
this.type = predicate.keyFilterPredicate.type;
this.updateValidators();
this.filterPredicateFormGroup.patchValue(predicate.keyFilterPredicate, {emitEvent: false});
this.filterPredicateFormGroup.get('userInfo').patchValue(predicate.userInfo, {emitEvent: false});
}
private updateValidators(): void {
const operationCtrl = this.filterPredicateFormGroup.get('operation');
const predicatesCtrl = this.filterPredicateFormGroup.get('predicates');
operationCtrl.setValidators([Validators.required]);
if (this.type === FilterPredicateType.COMPLEX) {
predicatesCtrl.setValidators([Validators.required]);
} else {
predicatesCtrl.clearValidators();
}
operationCtrl.updateValueAndValidity({emitEvent: false});
predicatesCtrl.updateValueAndValidity({emitEvent: false});
}
private updateModel() {
let predicate: KeyFilterPredicateInfo = null;
if (this.filterPredicateFormGroup.valid) {

2
ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html

@ -41,7 +41,7 @@
<mat-slide-toggle [formControl]="control.get('editable')"></mat-slide-toggle>
</mat-cell>
</ng-container>
<ng-container matColumnDef="actions" stickyEnd="true">
<ng-container matColumnDef="actions" stickyEnd>
<mat-header-cell *matHeaderCellDef/>
<mat-cell *matCellDef="let control; let i = index">
<div class="tb-form-table-row-cell-buttons flex-end">

Loading…
Cancel
Save