Fix negative numbers on filters and item card [SCI-11749]

This commit is contained in:
Anton 2025-04-02 13:30:36 +02:00
parent 9b6f1ff631
commit 0af24169a3
2 changed files with 3 additions and 10 deletions

View file

@ -75,7 +75,7 @@ export default {
},
methods: {
validateNumber(number) {
return number.replace(/[^0-9.]/g, '').match(/^\d*(\.\d{0,10})?/)[0];
return number.replace(/[^0-9.-]/g, '').match(/^-?\d*(\.\d{0,10})?/)[0];
}
},
watch: {

View file

@ -81,11 +81,6 @@ export default {
this.toggleExpandableState();
}
},
computed: {
canEdit() {
return this.permissions?.can_manage && !this.inArchivedRepositoryRow;
}
},
methods: {
handleKeydown(event) {
if (event.key === 'Enter') {
@ -115,8 +110,6 @@ export default {
});
},
enableEdit(e) {
if (!this.canEdit) return;
if (e && $(e.target).hasClass('atwho-user-popover')) return;
if (e && $(e.target).hasClass('sa-name')) return;
if (e && $(e.target).hasClass('sa-link')) return;
@ -146,8 +139,8 @@ export default {
});
},
enforceNumberInput() {
const regexp = this.decimals === 0 ? /[^0-9]/g : /[^0-9.]/g;
const decimalsRegex = new RegExp(`^\\d*(\\.\\d{0,${this.decimals}})?`);
const regexp = this.decimals === 0 ? /[^0-9-]/g : /[^0-9.-]/g;
const decimalsRegex = new RegExp(`^-?\\d*(\\.\\d{0,${this.decimals}})?`);
let { value } = this;
value = value.replace(regexp, '');
value = value.match(decimalsRegex)[0];