mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-3238] content size min error added (#3532)
* content size min error added * clean code
This commit is contained in:
parent
f7aaafed86
commit
8cc07f5816
@ -5,7 +5,7 @@
|
|||||||
matInput [formControl]="from" [errorStateMatcher]="matcher"
|
matInput [formControl]="from" [errorStateMatcher]="matcher"
|
||||||
placeholder="{{ 'SEARCH.FILTER.RANGE.FROM' | translate }}"
|
placeholder="{{ 'SEARCH.FILTER.RANGE.FROM' | translate }}"
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<mat-error *ngIf="from.hasError('pattern')">
|
<mat-error *ngIf="from.hasError('pattern') || from.hasError('min')">
|
||||||
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="from.hasError('required')">
|
<mat-error *ngIf="from.hasError('required')">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
matInput [formControl]="to" [errorStateMatcher]="matcher"
|
matInput [formControl]="to" [errorStateMatcher]="matcher"
|
||||||
placeholder="{{ 'SEARCH.FILTER.RANGE.TO' | translate }}"
|
placeholder="{{ 'SEARCH.FILTER.RANGE.TO' | translate }}"
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<mat-error *ngIf="to.hasError('pattern')">
|
<mat-error *ngIf="to.hasError('pattern') || to.hasError('min')">
|
||||||
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="to.hasError('required')">
|
<mat-error *ngIf="to.hasError('required')">
|
||||||
|
@ -160,4 +160,10 @@ describe('SearchNumberRangeComponent', () => {
|
|||||||
component.from = new FormControl(123, component.validators);
|
component.from = new FormControl(123, component.validators);
|
||||||
expect(component.from.hasError('required')).toBe(false);
|
expect(component.from.hasError('required')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw error if "from" value is a negative value', () => {
|
||||||
|
component.ngOnInit();
|
||||||
|
component.from = new FormControl(-100, component.validators);
|
||||||
|
expect(component.from.hasError('min')).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,7 +55,8 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
|||||||
|
|
||||||
this.validators = Validators.compose([
|
this.validators = Validators.compose([
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.pattern(/^-?(0|[1-9]\d*)?$/)
|
Validators.pattern(/^-?(0|[1-9]\d*)?$/),
|
||||||
|
Validators.min(0)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.from = new FormControl('', this.validators);
|
this.from = new FormControl('', this.validators);
|
||||||
@ -78,9 +79,8 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
|||||||
map.set('TO', model.to);
|
map.set('TO', model.to);
|
||||||
|
|
||||||
const value = this.formatString(this.format, map);
|
const value = this.formatString(this.format, map);
|
||||||
const query = `${this.field}:${value}`;
|
|
||||||
|
|
||||||
this.context.queryFragments[this.id] = query;
|
this.context.queryFragments[this.id] = `${this.field}:${value}`;
|
||||||
this.context.update();
|
this.context.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user