Commit c9a91264 by kalyani Committed by kevalbhatt

ATLAS-1433 : Atlas allows creation of tag with attributes' name same as that of its parent tags.

parent 97209e81
...@@ -118,3 +118,11 @@ g.type-TK > rect { ...@@ -118,3 +118,11 @@ g.type-TK > rect {
top: 4px; top: 4px;
right: 5px; right: 5px;
} }
.legends {
> i {
> span {
font-family: 'Source Sans Pro';
}
}
}
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
max-width: 91%; max-width: 91%;
overflow: hidden; overflow: hidden;
font-size: 14px;
} }
} }
ul { ul {
...@@ -252,6 +253,10 @@ ...@@ -252,6 +253,10 @@
} }
} }
.superType {
margin-bottom: 15px;
}
form-control .tagInpput { form-control .tagInpput {
margin-bottom: 15px; margin-bottom: 15px;
margin-top: 15px; margin-top: 15px;
...@@ -288,6 +293,13 @@ form-control .tagInpput { ...@@ -288,6 +293,13 @@ form-control .tagInpput {
margin-right: 5px; margin-right: 5px;
} }
.superTypeLabel {
font-weight: 600;
width: 90px;
margin-right: 5px;
float: left;
}
.inputAssignTag { .inputAssignTag {
display: block; display: block;
padding: 2px 5px; padding: 2px 5px;
......
...@@ -48,7 +48,7 @@ define(['require', ...@@ -48,7 +48,7 @@ define(['require',
}, options); }, options);
return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options); return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
}, },
saveTagAttribute: function(guid, options) { saveTagAttribute: function(options) {
var url = UrlLinks.typesClassicationApiUrl(); var url = UrlLinks.typesClassicationApiUrl();
options = _.extend({ options = _.extend({
contentType: 'application/json', contentType: 'application/json',
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
<h1><span data-id="title"></span></h1> <h1><span data-id="title"></span></h1>
<button type="button" data-id="editButton" class="btn btn-default pull-right editbutton" id="editText"><i class="fa fa-pencil"></i></button> <button type="button" data-id="editButton" class="btn btn-default pull-right editbutton" id="editText"><i class="fa fa-pencil"></i></button>
<p class="sub-title" data-id="description"></p> <p class="sub-title" data-id="description"></p>
<div class="superType" style="display:none">
<span class="superTypeLabel">Derived From:</span>
<div data-id="showSuperType" style="display: inline-block;">
</div>
</div>
<div class="attributes"> <div class="attributes">
<span class="attrLabel">Attributes:</span> <span class="attrLabel">Attributes:</span>
<div data-id="showAttribute"> <div data-id="showAttribute">
......
...@@ -45,7 +45,8 @@ define(['require', ...@@ -45,7 +45,8 @@ define(['require',
addTagPlus: '[data-id="addTagPlus"]', addTagPlus: '[data-id="addTagPlus"]',
addTagBtn: '[data-id="addTagBtn"]', addTagBtn: '[data-id="addTagBtn"]',
description: '[data-id="description"]', description: '[data-id="description"]',
publishButton: '[data-id="publishButton"]' publishButton: '[data-id="publishButton"]',
showSuperType: "[data-id='showSuperType']"
}, },
/** ui events hash */ /** ui events hash */
events: function() { events: function() {
...@@ -100,8 +101,9 @@ define(['require', ...@@ -100,8 +101,9 @@ define(['require',
}, },
renderTagDetail: function() { renderTagDetail: function() {
var attributeData = "", var attributeData = "",
attributeDefs = this.model.get("attributeDefs"); supertypeData = "",
attributeDefs = this.model.get("attributeDefs"),
superTypeArr = this.model.get('superTypes');
this.ui.title.html('<span>' + (Utils.getName(this.model.toJSON())) + '</span>'); this.ui.title.html('<span>' + (Utils.getName(this.model.toJSON())) + '</span>');
if (this.model.get("description")) { if (this.model.get("description")) {
this.ui.description.text(this.model.get("description")); this.ui.description.text(this.model.get("description"));
...@@ -115,6 +117,13 @@ define(['require', ...@@ -115,6 +117,13 @@ define(['require',
}); });
this.ui.showAttribute.html(attributeData); this.ui.showAttribute.html(attributeData);
} }
if (superTypeArr.length > 0) {
this.$(".superType").show();
_.each(superTypeArr, function(value, key) {
supertypeData += ' <a class="inputAttribute" href="#!/tag/tagAttribute/' + value + '">' + value + '</a>';
});
this.ui.showSuperType.html(supertypeData);
}
Utils.hideTitleLoader(this.$('.fontLoader'), this.$('.tagDetail')); Utils.hideTitleLoader(this.$('.fontLoader'), this.$('.tagDetail'));
}, },
onSaveButton: function(saveObject, message) { onSaveButton: function(saveObject, message) {
...@@ -138,7 +147,7 @@ define(['require', ...@@ -138,7 +147,7 @@ define(['require',
return; return;
} }
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail')); Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail'));
this.model.saveTagAttribute(this.model.get('guid'), { this.model.saveTagAttribute({
data: JSON.stringify({ data: JSON.stringify({
classificationDefs: [saveObject], classificationDefs: [saveObject],
entityDefs: [], entityDefs: [],
...@@ -154,6 +163,9 @@ define(['require', ...@@ -154,6 +163,9 @@ define(['require',
Utils.notifySuccess({ Utils.notifySuccess({
content: message content: message
}); });
},
cust_error: function() {
Utils.hideTitleLoader(that.$('.fontLoader'), that.$('.tagDetail'));
} }
}); });
that.modal.close(); that.modal.close();
...@@ -182,20 +194,61 @@ define(['require', ...@@ -182,20 +194,61 @@ define(['require',
} }
}); });
that.modal.on('ok', function() { that.modal.on('ok', function() {
var newAttributeList = view.collection.toJSON(); var newAttributeList = view.collection.toJSON(),
try { activeTagAttribute = _.extend([], that.model.get('attributeDefs')),
var saveJSON = JSON.parse(JSON.stringify(that.model.toJSON())); superTypes = that.model.get('superTypes');
} catch (err) {
Utils.serverErrorHandler(); _.each(superTypes, function(name) {
} var parentTags = that.collection.fullCollection.findWhere({ name: name });
if (saveJSON) { activeTagAttribute = activeTagAttribute.concat(parentTags.get('attributeDefs'));
var oldAttributeList = saveJSON.attributeDefs; });
}
var duplicateAttributeList = [],
saveObj = $.extend(true, {}, that.model.toJSON());
_.each(newAttributeList, function(obj) { _.each(newAttributeList, function(obj) {
oldAttributeList.push(obj); var duplicateCheck = _.find(activeTagAttribute, function(activeTagObj) {
return activeTagObj.name.toLowerCase() === obj.name.toLowerCase();
});
if (duplicateCheck) {
duplicateAttributeList.push(obj.name);
} else {
saveObj.attributeDefs.push(obj);
}
}); });
if (saveJSON) { var notifyObj = {
that.onSaveButton(saveJSON, Messages.addAttributeSuccessMessage); confirm: {
confirm: true,
buttons: [{
text: 'Ok',
addClass: 'btn-primary',
click: function(notice) {
notice.remove();
}
},
null
]
}
}
if (saveObj && !duplicateAttributeList.length) {
that.onSaveButton(saveObj, Messages.addAttributeSuccessMessage);
} else {
if (duplicateAttributeList.length < 2) {
var text = "Attribute <b>" + duplicateAttributeList.join(",") + "</b> is duplicate !"
} else {
if (newAttributeList.length > duplicateAttributeList.length) {
var text = "Attributes: <b>" + duplicateAttributeList.join(",") + "</b> are duplicate ! Do you want to continue with other attributes ?"
notifyObj = {
ok: function(argument) {
that.onSaveButton(saveObj, Messages.addAttributeSuccessMessage);
},
cancel: function(argument) {}
}
} else {
var text = "All attributes are duplicate !"
}
}
notifyObj['text'] = text;
Utils.notifyConfirm(notifyObj);
} }
}); });
that.modal.on('closeModal', function() { that.modal.on('closeModal', function() {
......
...@@ -228,6 +228,7 @@ define(['require', ...@@ -228,6 +228,7 @@ define(['require',
}); });
return; return;
} }
this.name = ref.ui.tagName.val(); this.name = ref.ui.tagName.val();
this.description = ref.ui.description.val(); this.description = ref.ui.description.val();
var superTypes = []; var superTypes = [];
...@@ -238,6 +239,57 @@ define(['require', ...@@ -238,6 +239,57 @@ define(['require',
if (ref.collection.length === 1 && ref.collection.first().get("name") === "") { if (ref.collection.length === 1 && ref.collection.first().get("name") === "") {
attributeObj = []; attributeObj = [];
} }
if (attributeObj.length) {
var superTypesAttributes = [];
_.each(superTypes, function(name) {
var parentTags = that.collection.fullCollection.findWhere({ name: name });
superTypesAttributes = superTypesAttributes.concat(parentTags.get('attributeDefs'));
});
var duplicateAttributeList = [];
_.each(attributeObj, function(obj) {
var duplicateCheck = _.find(superTypesAttributes, function(activeTagObj) {
return activeTagObj.name.toLowerCase() === obj.name.toLowerCase();
});
if (duplicateCheck) {
duplicateAttributeList.push(obj.name);
}
});
var notifyObj = {
confirm: {
confirm: true,
buttons: [{
text: 'Ok',
addClass: 'btn-primary',
click: function(notice) {
notice.remove();
}
},
null
]
}
}
if (duplicateAttributeList.length) {
if (duplicateAttributeList.length < 2) {
var text = "Attribute <b>" + duplicateAttributeList.join(",") + "</b> is duplicate !"
} else {
if (attributeObj.length > duplicateAttributeList.length) {
var text = "Attributes: <b>" + duplicateAttributeList.join(",") + "</b> are duplicate !"
} else {
var text = "All attributes are duplicate !"
}
}
notifyObj['text'] = text;
Utils.notifyConfirm(notifyObj);
return false;
}
}
this.json = { this.json = {
classificationDefs: [{ classificationDefs: [{
'name': this.name.trim(), 'name': this.name.trim(),
......
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