[develop | DONE | CHANGED] Range filters set placeholder/ validator based on min/max year from input

This commit is contained in:
argirok 2024-02-23 10:11:00 +02:00
parent e71aa35b98
commit f5ca757771
1 changed files with 6 additions and 1 deletions

View File

@ -21,7 +21,7 @@ export class RangeFilterComponent {
@Input() yearMax: number = Dates.yearMax;
@Input() mandatoryRange:boolean = false;
public currentYear: number = Dates.currentYear;
public yearValidators = [StringUtils.inValidYearValidator(this.yearMin, this.yearMax)];
public yearValidators;
public formValidators = [StringUtils.fromYearAfterToYearValidator];
public rangeForm: UntypedFormGroup;
public yearRange: YearRange = {
@ -41,6 +41,11 @@ export class RangeFilterComponent {
constructor(private _router: Router, private route: ActivatedRoute, private _fb: UntypedFormBuilder) {}
ngOnInit() {
this.yearValidators = [StringUtils.inValidYearValidator(this.yearMin, this.yearMax)];
this.yearRange = {
from: {control: 'yearFrom', placeholder: this.yearMin.toString()},
to: {control: 'yearTo', placeholder: this.yearMax.toString()}
}
if(this.mandatoryRange) {
this.formValidators.push(StringUtils.rangeRequired(this.mandatoryRange));
}