mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-485] Fix card view int item validator when value is empty (#5205)
* [AAE-485] Fix card view int item validator when value is empty * Avoid creating a function every time we validate number * Add return type to method
This commit is contained in:
committed by
Eugenio Romano
parent
f0ac4b19ad
commit
2a76b0846d
@@ -59,7 +59,6 @@
|
||||
<button mat-icon-button class="adf-textitem-action" (click)="update()"
|
||||
[attr.aria-label]="'CORE.METADATA.ACTIONS.SAVE' | translate"
|
||||
[attr.title]="'CORE.METADATA.ACTIONS.SAVE' | translate"
|
||||
[disabled]="hasErrors()"
|
||||
[attr.data-automation-id]="'card-textitem-update-' + property.key">
|
||||
|
||||
<mat-icon class="adf-textitem-icon">done</mat-icon>
|
||||
|
@@ -22,6 +22,8 @@ export class CardViewItemFloatValidator implements CardViewItemValidator {
|
||||
message = 'CORE.CARDVIEW.VALIDATORS.FLOAT_VALIDATION_ERROR';
|
||||
|
||||
isValid(value: any): boolean {
|
||||
return !isNaN(parseFloat(value)) && isFinite(value);
|
||||
return value === ''
|
||||
|| !isNaN(parseFloat(value))
|
||||
&& isFinite(value);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,13 @@ export class CardViewItemIntValidator implements CardViewItemValidator {
|
||||
message = 'CORE.CARDVIEW.VALIDATORS.INT_VALIDATION_ERROR';
|
||||
|
||||
isValid(value: any): boolean {
|
||||
return !isNaN(value) && (function(x) { return (x | 0) === x; })(parseFloat(value));
|
||||
return value === ''
|
||||
|| !isNaN(value)
|
||||
&& this.isIntegerNumber(value);
|
||||
}
|
||||
|
||||
isIntegerNumber(value: any): boolean {
|
||||
const parsedNumber = parseFloat(value);
|
||||
return (parsedNumber | 0) === parsedNumber;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user