Enable adding negative numbers in Number column type in Inventories [SCI-10394]

This commit is contained in:
Giga Chubinidze 2024-03-26 12:44:31 +04:00
parent f571ec5c0c
commit 6d2de3ca12
2 changed files with 3 additions and 3 deletions

View file

@ -132,8 +132,8 @@ $.fn.dataTable.render.editRepositoryNumberValue = function(formId, columnId, cel
});
$input.on('input', function() {
const regexp = decimals === 0 ? /[^0-9]/g : /[^0-9.]/g;
const decimalsRegex = new RegExp(`^\\d*(\\.\\d{0,${decimals}})?`);
const regexp = decimals === 0 ? /[^-0-9]/g : /[^-0-9.]/g;
const decimalsRegex = new RegExp(`^-?\\d*(\\.\\d{0,${decimals}})?`);
let value = this.value;
value = value.replace(regexp, '');
value = value.match(decimalsRegex)[0];

View file

@ -64,7 +64,7 @@ $.fn.dataTable.render.newRepositoryNumberValue = function(formId, columnId, $cel
});
$input.on('input', function() {
const decimalsRegex = new RegExp(`^\\d*(\\.\\d{0,${decimals}})?`);
const decimalsRegex = new RegExp(`^-?\\d*(\\.\\d{0,${decimals}})?`);
let value = this.value;
value = value.replace(/[^0-9.]/g, '');
value = value.match(decimalsRegex)[0];