ATLAS-2212: UI fix to allow negative number input for tag attributes
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
diff --git a/dashboardv2/public/js/utils/Overrides.js b/dashboardv2/public/js/utils/Overrides.js
index 4ffda57..dd36859 100644
--- a/dashboardv2/public/js/utils/Overrides.js
+++ b/dashboardv2/public/js/utils/Overrides.js
@@ -87,6 +87,17 @@
return false;
}
});
+ $('body').on('keypress', 'input.number-input-negative,.number-input-negative .select2-search__field', function(e) {
+ if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
+ if (e.which == 45) {
+ if (this.value.length) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ });
// For placeholder support
if (!('placeholder' in HTMLInputElement.prototype)) {
diff --git a/dashboardv2/public/js/views/tag/addTagModalView.js b/dashboardv2/public/js/views/tag/addTagModalView.js
index 423a92e..a169867 100644
--- a/dashboardv2/public/js/views/tag/addTagModalView.js
+++ b/dashboardv2/public/js/views/tag/addTagModalView.js
@@ -312,16 +312,14 @@
},
getElement: function(labelName, typeName) {
var value = this.tagModel && this.tagModel.attributes ? (this.tagModel.attributes[labelName] || "") : "",
- type = (typeName === "int" || typeName === "long" || typeName === "float" || typeName === "byte" || typeName === "double" || typeName === "short") ? "number" : "text";
+ className = ((typeName === "int" || typeName === "long" || typeName === "float" || typeName === "byte" || typeName === "double" || typeName === "short") ? "number-input-negative" : "") + " form-control attributeInputVal attrName";
if (typeName === "boolean") {
return '<select class="form-control attributeInputVal attrName" data-key="' + labelName + '" data-type="' + typeName + '"> ' +
'<option value="">--Select true or false--</option>' +
'<option value="true">true</option>' +
'<option value="false">false</option></select>';
- } else if (typeName === "int") {
- return '<input type="' + type + '" value="' + value + '" class="form-control attributeInputVal attrName number-input" data-key="' + labelName + '" data-type="' + typeName + '"></input></div>';
} else {
- return '<input type="' + type + '" value="' + value + '" class="form-control attributeInputVal attrName" data-key="' + labelName + '" data-type="' + typeName + '"></input></div>';
+ return '<input type="text" value="' + value + '" class="' + className + '" data-key="' + labelName + '" data-type="' + typeName + '"></input></div>';
}
},
saveTagData: function(options) {