Commit 32fa4be5 by pratik pandey Committed by Madhan Neethiraj

ATLAS-2212: UI fix to allow negative number input for tag attributes

parent 8663eb1d
......@@ -87,6 +87,17 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
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)) {
......
......@@ -312,16 +312,14 @@ define(['require',
},
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment