[develop | DONE | CHANGED] Range filters set placeholder/ validator based on min/max year from input
This commit is contained in:
parent
e71aa35b98
commit
f5ca757771
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue