[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() yearMax: number = Dates.yearMax;
@Input() mandatoryRange:boolean = false; @Input() mandatoryRange:boolean = false;
public currentYear: number = Dates.currentYear; public currentYear: number = Dates.currentYear;
public yearValidators = [StringUtils.inValidYearValidator(this.yearMin, this.yearMax)]; public yearValidators;
public formValidators = [StringUtils.fromYearAfterToYearValidator]; public formValidators = [StringUtils.fromYearAfterToYearValidator];
public rangeForm: UntypedFormGroup; public rangeForm: UntypedFormGroup;
public yearRange: YearRange = { public yearRange: YearRange = {
@ -41,6 +41,11 @@ export class RangeFilterComponent {
constructor(private _router: Router, private route: ActivatedRoute, private _fb: UntypedFormBuilder) {} constructor(private _router: Router, private route: ActivatedRoute, private _fb: UntypedFormBuilder) {}
ngOnInit() { 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) { if(this.mandatoryRange) {
this.formValidators.push(StringUtils.rangeRequired(this.mandatoryRange)); this.formValidators.push(StringUtils.rangeRequired(this.mandatoryRange));
} }