WEB-252: Buy Down fee adjustment template pop up window - Adjustment button active / not active

This commit is contained in:
Jose Alberto Hernandez
2025-07-11 16:09:39 -05:00
parent b9d8bd2b64
commit 85d28acb65
9 changed files with 48 additions and 18 deletions
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { UntypedFormControl, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms';
import { FormfieldBase } from './formfield/model/formfield-base';
@@ -14,10 +14,21 @@ export class FormGroupService {
formfields.forEach((formfield) => {
group[formfield.controlName] = formfield.required
? new UntypedFormControl(formfield.value, Validators.required)
: new UntypedFormControl(formfield.value);
? new UntypedFormControl(formfield.value, this.buildValidators(formfield))
: new UntypedFormControl(formfield.value, this.buildValidators(formfield));
});
return new UntypedFormGroup(group);
}
buildValidators(formfield: FormfieldBase): ValidatorFn[] {
let validators: ValidatorFn[] = [];
if (formfield.required) {
validators.push(Validators.required);
}
if (formfield.validators) {
formfield.validators.forEach((validator: ValidatorFn) => validators.push(validator));
}
return validators;
}
}
@@ -10,6 +10,12 @@
[formControlName]="formfield.controlName"
[required]="formfield.required"
/>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('max')">
<strong>{{ 'labels.commons.Maximum Value must be' | translate }} {{ formfield.max }}</strong>
</mat-error>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('min')">
<strong>{{ 'labels.commons.Minimum Value must be' | translate }} {{ formfield.min }}</strong>
</mat-error>
<mat-select
*ngIf="formfield.controlType === 'select'"
@@ -1,10 +1,16 @@
import { ValidatorFn } from '@angular/forms';
export class FormfieldBase {
controlType: string;
controlName: string;
type: string;
label: string;
value: any;
required: boolean;
order: number;
validators?: ValidatorFn[];
min?: number | null;
max?: number | null;
constructor(
options: {
@@ -14,6 +20,9 @@ export class FormfieldBase {
value?: any;
required?: boolean;
order?: number;
validators?: ValidatorFn[];
min?: number | null;
max?: number | null;
} = {}
) {
this.controlType = options.controlType || '';
@@ -22,5 +31,8 @@ export class FormfieldBase {
this.value = options.value === undefined ? '' : options.value;
this.required = !!options.required;
this.order = options.order === undefined ? 1 : options.order;
this.validators = options.validators === undefined ? [] : options.validators;
this.min = options.min === undefined ? null : options.min;
this.max = options.max === undefined ? null : options.max;
}
}