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"
|
||||
placeholder="{{ 'SEARCH.FILTER.RANGE.FROM' | translate }}"
|
||||
autocomplete="off">
|
||||
<mat-error *ngIf="from.hasError('pattern')">
|
||||
<mat-error *ngIf="from.hasError('pattern') || from.hasError('min')">
|
||||
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="from.hasError('required')">
|
||||
@ -18,7 +18,7 @@
|
||||
matInput [formControl]="to" [errorStateMatcher]="matcher"
|
||||
placeholder="{{ 'SEARCH.FILTER.RANGE.TO' | translate }}"
|
||||
autocomplete="off">
|
||||
<mat-error *ngIf="to.hasError('pattern')">
|
||||
<mat-error *ngIf="to.hasError('pattern') || to.hasError('min')">
|
||||
{{ 'SEARCH.FILTER.VALIDATION.INVALID-FORMAT' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="to.hasError('required')">
|
||||
|
@ -160,4 +160,10 @@ describe('SearchNumberRangeComponent', () => {
|
||||
component.from = new FormControl(123, component.validators);
|
||||
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([
|
||||
Validators.required,
|
||||
Validators.pattern(/^-?(0|[1-9]\d*)?$/)
|
||||
Validators.pattern(/^-?(0|[1-9]\d*)?$/),
|
||||
Validators.min(0)
|
||||
]);
|
||||
|
||||
this.from = new FormControl('', this.validators);
|
||||
@ -78,9 +79,8 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
||||
map.set('TO', model.to);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user