Commit 69d403e8 by kevalbhatt

ATLAS-3636 : [Namespace-UI] Issues/ambiguous error messages while adding a new…

ATLAS-3636 : [Namespace-UI] Issues/ambiguous error messages while adding a new attribute in a Namespace
parent 43c134dd
...@@ -228,7 +228,6 @@ pre { ...@@ -228,7 +228,6 @@ pre {
.custom-col-1, .custom-col-1,
.custom-col-2 { .custom-col-2 {
vertical-align: top; vertical-align: top;
display: inline-block;
textarea { textarea {
resize: vertical; resize: vertical;
...@@ -254,8 +253,13 @@ pre { ...@@ -254,8 +253,13 @@ pre {
.custom-col-2 { .custom-col-2 {
text-align: center; text-align: center;
width: 17%; width: 17%;
margin-left: 1%; padding-left: 1%;
margin-bottom: 10px; margin-bottom: 10px;
&>button {
padding: 7px 10px;
margin-bottom: 10px;
}
} }
} }
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
width: 35%; width: 35%;
} }
word-break: break-all; word-break: break-word;
} }
} }
......
...@@ -15,21 +15,25 @@ ...@@ -15,21 +15,25 @@
* limitations under the License. * limitations under the License.
--> -->
{{#ifCond model "has" "isNew"}} {{#ifCond model "has" "isNew"}}
<td class="custom-col-1"> <table class="custom-table" style="font-weight: 100;">
<tr class="custom-tr">
<td class="custom-col-1">
{{{callmyfunction getNamespaceDroupdown nameSpaceCollection}}} {{{callmyfunction getNamespaceDroupdown nameSpaceCollection}}}
</td> </td>
<td class="custom-col-0"> : </td> <td class="custom-col-0"> : </td>
<td class="custom-col-1" data-id="value"> <td class="custom-col-1" data-id="value">
<input type="text" data-key disabled class="form-control"> <input type="text" data-key disabled class="form-control">
</td> </td>
<td class="custom-col-2 btn-group"> <td class="custom-col-2 btn-group">
<button class="btn btn-default btn-sm" data-id="deleteItem"> <button class="btn btn-default btn-sm" data-id="deleteItem">
<i class="fa fa-minus"> </i> <i class="fa fa-minus"> </i>
</button> </button>
<button class="btn btn-default btn-sm" data-id="addItem"> <button class="btn btn-default btn-sm" data-id="addItem">
<i class="fa fa-plus"> </i> <i class="fa fa-plus"> </i>
</button> </button>
</td> </td>
</tr>
</table>
{{else}} {{else}}
<hr /> <hr />
<ul class="namespace-tree-parent"> <ul class="namespace-tree-parent">
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</div> </div>
</div> </div>
<div class="panel-actions"> <div class="panel-actions">
<button class="btn btn-action btn-sm" title="" data-id="addNameSpace">Add</button> <button class="btn btn-action btn-sm" data-id="addNameSpace">Add</button>
<button class="btn btn-action btn-sm" style="display: none;" data-id="saveNameSpace">Save</button> <button class="btn btn-action btn-sm" style="display: none;" data-id="saveNameSpace">Save</button>
<button class="btn btn-action btn-sm" style="display: none;" data-id="cancel">Cancel</button> <button class="btn btn-action btn-sm" style="display: none;" data-id="cancel">Cancel</button>
</div> </div>
...@@ -35,9 +35,7 @@ ...@@ -35,9 +35,7 @@
<div class="form-group"> <div class="form-group">
<a href="javascript:void(0)" class="btn btn-action btn-sm" data-id="addItem" data-type="addAttrButton">Add New Attribute</a> <a href="javascript:void(0)" class="btn btn-action btn-sm" data-id="addItem" data-type="addAttrButton">Add New Attribute</a>
</div> </div>
<table class="custom-table"> <ul class="namespace-tree-parent" data-id="itemView"></ul>
<tbody data-id="itemView"></tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<div class="form-group clearfix namespace-attr"> <div id="{{modalID}}" class="form-group clearfix namespace-attr">
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 attributePlusData " align="right"> <div class="col-sm-12 attributePlusData " align="right">
<button type="button" class="btn btn-danger btn-sm closeInput" data-id="close"><i class="fa fa-times"></i></button> <button type="button" class="btn btn-danger btn-sm closeInput" data-id="close"><i class="fa fa-times"></i></button>
......
...@@ -38,8 +38,8 @@ define(['require', ...@@ -38,8 +38,8 @@ define(['require',
model: this.model.toJSON() model: this.model.toJSON()
} }
}, },
tagName: 'tr', tagName: 'li',
className: "custom-tr", className: "namespace-tree-child",
/** Layout sub regions */ /** Layout sub regions */
regions: {}, regions: {},
...@@ -142,9 +142,10 @@ define(['require', ...@@ -142,9 +142,10 @@ define(['require',
}); });
} }
}, },
getAttrElement: function(options) { getAttrElement: function(opt) {
var that = this, var that = this,
returnEL = "N/A"; returnEL = "N/A",
options = $.extend(true, {}, opt);
if (options) { if (options) {
var key = options.key, var key = options.key,
typeName = options.val.typeName || "", typeName = options.val.typeName || "",
...@@ -153,24 +154,21 @@ define(['require', ...@@ -153,24 +154,21 @@ define(['require',
namespace = options.namespace, namespace = options.namespace,
allowOnlyNum = false; allowOnlyNum = false;
var elType = isMultiValued ? "select" : "input"; var elType = isMultiValued ? "select" : "input";
if (!_.isEmpty(val)) { if (!isMultiValued && !_.isEmpty(val)) {
val = _.escape(val); val = _.escape(val);
} }
if (!_.isUndefinedNull(val) && typeName.indexOf("boolean") > -1) { if (!_.isUndefinedNull(val) && typeName.indexOf("boolean") > -1) {
val = String(val); val = String(val);
} }
if (typeName.indexOf("date") > -1) { if (typeName.indexOf("date") > -1) {
if (isMultiValued && val) { if (isMultiValued && val && val.length) {
var dateVlaues = val.split(',');
if (dateVlaues.length) {
var dateStr = []; var dateStr = [];
_.each(dateVlaues, function(selectedDate) { _.each(val, function(selectedDate) {
selectedDate = parseInt(selectedDate); selectedDate = parseInt(selectedDate);
dateStr.push(moment(selectedDate).format("MM/DD/YYYY")); dateStr.push(moment(selectedDate).format("MM/DD/YYYY"));
}); });
val = dateStr.join(','); val = dateStr.join(',');
} } else if (!isMultiValued && val) {
} else if (val) {
val = parseInt(val); val = parseInt(val);
val = moment(val).format("MM/DD/YYYY"); val = moment(val).format("MM/DD/YYYY");
} }
...@@ -199,13 +197,14 @@ define(['require', ...@@ -199,13 +197,14 @@ define(['require',
allowOnlyNum = true; allowOnlyNum = true;
returnEL = '<' + elType + ' data-key="' + key + '" data-namespace="' + namespace + '" data-typename="' + typeName + '" type="number" data-multi="' + isMultiValued + '" data-tags="true" placeholder="Enter Number" class="form-control" ' + (!_.isUndefinedNull(val) ? 'value="' + val + '"' : "") + '></' + elType + '>'; returnEL = '<' + elType + ' data-key="' + key + '" data-namespace="' + namespace + '" data-typename="' + typeName + '" type="number" data-multi="' + isMultiValued + '" data-tags="true" placeholder="Enter Number" class="form-control" ' + (!_.isUndefinedNull(val) ? 'value="' + val + '"' : "") + '></' + elType + '>';
} else if (typeName) { } else if (typeName) {
var modTypeName = typeName;
if (isMultiValued) { if (isMultiValued) {
var multipleType = typeName.match("array<(.*)>"); var multipleType = typeName.match("array<(.*)>");
if (multipleType && multipleType[1]) { if (multipleType && multipleType[1]) {
typeName = multipleType[1]; modTypeName = multipleType[1];
} }
} }
var foundEnumType = this.enumDefCollection.fullCollection.find({ name: typeName }); var foundEnumType = this.enumDefCollection.fullCollection.find({ name: modTypeName });
if (foundEnumType) { if (foundEnumType) {
var enumOptions = ""; var enumOptions = "";
_.forEach(foundEnumType.get("elementDefs"), function(obj) { _.forEach(foundEnumType.get("elementDefs"), function(obj) {
...@@ -214,15 +213,17 @@ define(['require', ...@@ -214,15 +213,17 @@ define(['require',
returnEL = '<select data-key="' + key + '" data-namespace="' + namespace + '" data-typename="' + typeName + '" data-multi="' + isMultiValued + '" >' + enumOptions + '</select>'; returnEL = '<select data-key="' + key + '" data-namespace="' + namespace + '" data-typename="' + typeName + '" data-multi="' + isMultiValued + '" >' + enumOptions + '</select>';
} }
setTimeout(function() { setTimeout(function() {
if (!isMultiValued) {
var selectEl = that.$el.find('.custom-col-1[data-id="value"] select[data-key="' + key + '"]'); var selectEl = that.$el.find('.custom-col-1[data-id="value"] select[data-key="' + key + '"]');
selectEl.val((val || "")); selectEl.val((val || ""));
selectEl.select2(); selectEl.select2();
}
}, 0); }, 0);
} }
if (isMultiValued) { if (isMultiValued) {
setTimeout(function() { setTimeout(function() {
var selectEl = that.$el.find('.custom-col-1[data-id="value"] select[data-key="' + key + '"][data-multi="true"]'); var selectEl = that.$el.find('.custom-col-1[data-id="value"] select[data-key="' + key + '"][data-multi="true"]');
var data = val && val.split(",") || []; var data = val && val.length && (_.isArray(val) ? val : val.split(",")) || [];
if (allowOnlyNum) { if (allowOnlyNum) {
selectEl.parent().addClass("select2_only_number"); selectEl.parent().addClass("select2_only_number");
} }
...@@ -323,7 +324,7 @@ define(['require', ...@@ -323,7 +324,7 @@ define(['require',
'<button class="btn btn-default btn-sm" data-key="' + key + '" data-id="deleteItem">' + '<button class="btn btn-default btn-sm" data-key="' + key + '" data-id="deleteItem">' +
'<i class="fa fa-times"> </i>' + '<i class="fa fa-times"> </i>' +
'</button></td>'; '</button></td>';
trs += "<tr>" + td + "</tr>"; trs += "<tr class='custom-tr'>" + td + "</tr>";
} }
}) })
this.$("[data-id='namespaceTreeChild']").html("<table class='custom-table'>" + trs + "</table>"); this.$("[data-id='namespaceTreeChild']").html("<table class='custom-table'>" + trs + "</table>");
......
...@@ -117,10 +117,8 @@ define([ ...@@ -117,10 +117,8 @@ define([
this.$el.find(".panel-heading").addClass("collapsed"); this.$el.find(".panel-heading").addClass("collapsed");
this.$el.find(".panel-collapse.collapse").removeClass("in"); this.$el.find(".panel-collapse.collapse").removeClass("in");
this.ui.addNameSpace.text("Add"); this.ui.addNameSpace.text("Add");
this.ui.addNameSpace.attr("data-original-title", "Add");
} else { } else {
this.ui.addNameSpace.text("Edit"); this.ui.addNameSpace.text("Edit");
this.ui.addNameSpace.attr("data-original-title", "Edit All");
this.$el.find(".panel-heading").removeClass("collapsed"); this.$el.find(".panel-heading").removeClass("collapsed");
this.$el.find(".panel-collapse.collapse").addClass("in"); this.$el.find(".panel-collapse.collapse").addClass("in");
} }
...@@ -157,8 +155,13 @@ define([ ...@@ -157,8 +155,13 @@ define([
if (!this.validate()) { if (!this.validate()) {
return; return;
} }
var nData = this.generateData();
if (this.actualCollection.length === 0 && _.isEmpty(nData)) {
this.onCancel();
return;
}
this.entityModel.saveNamespaceEntity(this.guid, { this.entityModel.saveNamespaceEntity(this.guid, {
data: JSON.stringify(this.generateData()), data: JSON.stringify(nData),
type: "POST", type: "POST",
success: function(data) { success: function(data) {
Utils.notifySuccess({ Utils.notifySuccess({
......
...@@ -89,12 +89,20 @@ define(["require", "backbone", "hbs!tmpl/name_space/EnumCreateUpdateItemView_tmp ...@@ -89,12 +89,20 @@ define(["require", "backbone", "hbs!tmpl/name_space/EnumCreateUpdateItemView_tmp
entitytypes = "", entitytypes = "",
enumTypes = []; enumTypes = [];
this.ui.enumValueSelectorContainer.hide(); this.ui.enumValueSelectorContainer.hide();
this.bindEvents();
this.emumTypeSelectDisplay(); this.emumTypeSelectDisplay();
if (!this.options.closeModal) { if (!this.options.closeModal) {
this.ui.enumCancleBtn.attr("disabled", "true"); this.ui.enumCancleBtn.attr("disabled", "true");
this.ui.enumCancleBtn.text("Clear"); this.ui.enumCancleBtn.text("Clear");
} }
}, },
bindEvents: function() {
var that = this;
this.listenTo(this.enumDefCollection, 'reset', function() {
that.emumTypeSelectDisplay();
})
},
showEnumValues: function(enumName) { showEnumValues: function(enumName) {
var enumValues = "", var enumValues = "",
selectedValues = [], selectedValues = [],
...@@ -225,7 +233,8 @@ define(["require", "backbone", "hbs!tmpl/name_space/EnumCreateUpdateItemView_tmp ...@@ -225,7 +233,8 @@ define(["require", "backbone", "hbs!tmpl/name_space/EnumCreateUpdateItemView_tmp
content: "Enumeration " + selectedEnumName + " updated successfully" content: "Enumeration " + selectedEnumName + " updated successfully"
}); });
} }
if (that.options.onUpdateEnum) { that.enumDefCollection.fetch({ reset: true });
if (that.options.onUpdateEnum) { //callback from namespaceattributeItemView
that.options.onUpdateEnum(); that.options.onUpdateEnum();
} }
that.ui.enumCancleBtn.attr("disabled", "true"); that.ui.enumCancleBtn.attr("disabled", "true");
......
...@@ -30,6 +30,11 @@ define(['require', ...@@ -30,6 +30,11 @@ define(['require',
{ {
template: NameSpaceAttributeItemViewTmpl, template: NameSpaceAttributeItemViewTmpl,
templateHelpers: function() {
return {
modalID: this.viewId
};
},
/** Layout sub regions */ /** Layout sub regions */
regions: {}, regions: {},
...@@ -109,12 +114,14 @@ define(['require', ...@@ -109,12 +114,14 @@ define(['require',
*/ */
initialize: function(options) { initialize: function(options) {
this.parentView = options.parentView; this.parentView = options.parentView;
this.viewId = options.model ? options.model.cid : this.parentView.cid;
}, },
onRender: function() { onRender: function() {
var that = this, var that = this,
entitytypes = '', entitytypes = '',
enumTypes = []; enumTypes = [];
this.model.set({ "modalID": this.viewId });
this.parentView.typeHeaders.fullCollection.each(function(model) { this.parentView.typeHeaders.fullCollection.each(function(model) {
if (model.toJSON().category == "ENTITY") { if (model.toJSON().category == "ENTITY") {
that.ui.entityTypeSelector.append("<option>" + model.get('name') + "</option>"); that.ui.entityTypeSelector.append("<option>" + model.get('name') + "</option>");
......
...@@ -151,15 +151,15 @@ define(['require', ...@@ -151,15 +151,15 @@ define(['require',
}, },
onEditAttr: function(e) { onEditAttr: function(e) {
var that = this, var that = this,
isAttrEdit = e.target.dataset && e.target.dataset.id === 'attributeEdit' ? true : false, isAttrEdit = e.currentTarget.dataset && e.currentTarget.dataset.id === 'attributeEdit' ? true : false,
guid = e.target.dataset && e.target.dataset.guid ? e.target.dataset.guid : null, guid = e.currentTarget.dataset && e.currentTarget.dataset.guid ? e.currentTarget.dataset.guid : null,
selectedNamespace = that.nameSpaceCollection.fullCollection.findWhere({ guid: guid }), selectedNamespace = that.nameSpaceCollection.fullCollection.findWhere({ guid: guid }),
attrributes = selectedNamespace ? selectedNamespace.get('attributeDefs') : null, attrributes = selectedNamespace ? selectedNamespace.get('attributeDefs') : null,
attrName = e.target.dataset.name ? e.target.dataset.name : null, attrName = e.currentTarget.dataset.name ? e.currentTarget.dataset.name : null,
attrDetails = { name: attrName }; attrDetails = { name: attrName };
if (selectedNamespace) { if (selectedNamespace) {
that.ui.namespaceAttrPageOk.text("Save"); that.ui.namespaceAttrPageOk.text("Save");
that.newAttr = e.target && e.target.dataset.action === "createAttr" ? true : false; that.newAttr = e.currentTarget && e.currentTarget.dataset.action === "createAttr" ? true : false;
that.guid = guid; that.guid = guid;
_.each(attrributes, function(attrObj) { _.each(attrributes, function(attrObj) {
if (attrObj.name === attrName) { if (attrObj.name === attrName) {
...@@ -176,7 +176,7 @@ define(['require', ...@@ -176,7 +176,7 @@ define(['require',
that.showDetails = false; that.showDetails = false;
that.toggleNamespaceDetailsAttrView(); that.toggleNamespaceDetailsAttrView();
that.ui.namespaceAttrPageOk.attr('data-action', e.target.dataset.id); that.ui.namespaceAttrPageOk.attr('data-action', e.currentTarget.dataset.id);
require(["views/name_space/CreateNameSpaceLayoutView"], function(CreateNameSpaceLayoutView) { require(["views/name_space/CreateNameSpaceLayoutView"], function(CreateNameSpaceLayoutView) {
that.view = new CreateNameSpaceLayoutView({ that.view = new CreateNameSpaceLayoutView({
onEditCallback: function() { onEditCallback: function() {
......
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