Fix adding too small/big number to input for decimals for number repo column type

This commit is contained in:
Mojca Lorber 2020-02-12 12:14:58 +01:00
parent a472eda699
commit 0f67ce78c0
2 changed files with 11 additions and 2 deletions

View file

@ -196,6 +196,14 @@ function filesSizeValidator(ev, fileInputs, fileTypeEnum) {
return filesSizeValid;
}
function numberMinMaxValidator(value, min, max) {
if(parseInt(value) < min || isNaN(value))
return min;
else if(parseInt(value) > max)
return max;
else return value;
}
/*
* Overriden in billing module for checking whether enough
* team space is free.

View file

@ -5,7 +5,8 @@
<%= t('libraries.manange_modal_column.number_type.decimals_label') %>
</label>
<div class="col-sm-3">
<%= number_field_tag('decimals', selected_decimals, in: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS,
class: 'form-control') %>
<%= number_field_tag('decimals', selected_decimals, between: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS,
class: 'form-control',
oninput: "this.value = numberMinMaxValidator(this.value, 0, #{Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS})" ) %>
</div>
</div>