From 908033f3010859c41c681c8b33e465eb1c3910b2 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Thu, 7 Nov 2024 18:04:53 +0200 Subject: [PATCH] VCST-2213: Cannot save empty field for catalog property with type decimal number (#2859) fix: Allow to save empty field for catalog property with type decimal number --- .../wwwroot/js/common/directives/smartFloat.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/common/directives/smartFloat.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/common/directives/smartFloat.js index a7e118b136..65f96155f2 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/common/directives/smartFloat.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/common/directives/smartFloat.js @@ -17,7 +17,7 @@ angular.module('platformWebApp') // possible values for fraction are: 0, positive number, negative number, none // when fraction is a negative number result has maximum length of the fractional part of the value var fraction = (attrs.fraction || Number(attrs.fraction) === 0) ? attrs.fraction : 2; - if (attrs.numType === "float") { + if (attrs.numType === 'float') { ctrl.$parsers.unshift(function (viewValue) { if (FLOAT_REGEXP_1.test(viewValue)) { ctrl.$setValidity('float', true); @@ -32,7 +32,8 @@ angular.module('platformWebApp') ctrl.$setValidity('float', true); return parseFloat(viewValue.replace(',', '.')); } else { - ctrl.$setValidity('float', false); + //Allow to use empty values + ctrl.$setValidity('float', !viewValue); return viewValue; } }); @@ -54,7 +55,7 @@ angular.module('platformWebApp') } ); } - else if (attrs.numType === "positiveInteger") { + else if (attrs.numType === 'positiveInteger') { ctrl.$parsers.unshift(function (viewValue) { ctrl.$setValidity('positiveInteger', INTEGER_REGEXP.test(viewValue) && viewValue > 0); return viewValue;