Merge pull request #5750 from guerler/fix_columnassigner

Add additional validation to numeric input element
This commit is contained in:
John Chilton
2018-03-22 11:41:53 -04:00
committed by GitHub
+12 -4
View File
@@ -100,10 +100,18 @@ var View = Backbone.View.extend({
var options = this.model.attributes;
if (new_val !== undefined) {
if (new_val !== null && new_val !== "" && !this._isParameter(new_val)) {
isNaN(new_val) && (new_val = 0);
!options.precise && (new_val = Math.round(new_val));
options.max !== null && (new_val = Math.min(new_val, options.max));
options.min !== null && (new_val = Math.max(new_val, options.min));
if (isNaN(new_val)) {
new_val = 0;
}
if (!options.precise) {
new_val = Math.round(new_val);
}
if (options.max !== null && !isNaN(options.max)) {
new_val = Math.min(new_val, options.max);
}
if (options.min !== null && !isNaN(options.min)) {
new_val = Math.max(new_val, options.min);
}
}
this.model.set("value", new_val);
this.model.trigger("change");