Commit f92e06cd by gutkaBinit Committed by nixonrodrigues

ATLAS-2945 UI - If a Term is assigned to an Category then to user is able to…

ATLAS-2945 UI - If a Term is assigned to an Category then to user is able to assign the same term again Signed-off-by: 's avatarnixonrodrigues <nixon@apache.org>
parent 4c7c911c
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Globals', 'utils/Enums', 'moment'], function(require, Utils, Modal, Messages, Globals, Enums, moment) { define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enums', 'moment'], function(require, Utils, Modal, Messages, Enums, moment) {
'use strict'; 'use strict';
var CommonViewFunction = {}; var CommonViewFunction = {};
...@@ -335,18 +335,6 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob ...@@ -335,18 +335,6 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Glob
} }
if (!Enums.entityStateReadOnly[obj.status]) { if (!Enums.entityStateReadOnly[obj.status]) {
if (obj.guid) { if (obj.guid) {
var newD = { "guid": obj.guid, "termLinks": obj.meanings };
Globals.termMeanings = Globals.termMeanings ? Globals.termMeanings : [];
if (Globals.termMeanings.length > 0) {
for (var x in Globals.termMeanings) {
if (Globals.termMeanings[x]['guid'] == obj.guid) {
Globals.termMeanings[x].termLinks = obj.meanings;
}
}
}
if (newD.termLinks.length > 0 && Globals.termMeanings == 0) {
Globals.termMeanings.push(newD);
}
addTerm += '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>'; addTerm += '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>';
} else { } else {
addTerm += '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>'; addTerm += '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>';
......
...@@ -198,7 +198,7 @@ define(['require', ...@@ -198,7 +198,7 @@ define(['require',
this.generateTag([]); this.generateTag([]);
} }
if (collectionJSON.relationshipAttributes && collectionJSON.relationshipAttributes.meanings) { if (collectionJSON.relationshipAttributes && collectionJSON.relationshipAttributes.meanings) {
this.generateTerm(collectionJSON.relationshipAttributes.meanings, collectionJSON); this.generateTerm(collectionJSON.relationshipAttributes.meanings);
} }
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) { if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
this.ui.editButtonContainer.html(ButtonsTmpl({ btn_edit: true })); this.ui.editButtonContainer.html(ButtonsTmpl({ btn_edit: true }));
...@@ -403,21 +403,9 @@ define(['require', ...@@ -403,21 +403,9 @@ define(['require',
this.ui.propagatedTagList.html(propagatedTagListData); this.ui.propagatedTagList.html(propagatedTagListData);
}, },
generateTerm: function(data, obj) { generateTerm: function(data) {
var that = this, var that = this,
termData = ""; termData = "";
var newD = { "guid": obj.guid, "termLinks": obj.relationshipAttributes.meanings };
Globals.termMeanings = Globals.termMeanings ? Globals.termMeanings : [];
if (Globals.termMeanings.length > 0) {
for (var x in Globals.termMeanings) {
if (Globals.termMeanings[x]['guid'] == obj.guid) {
Globals.termMeanings[x].termLinks = obj.relationshipAttributes.meanings;
}
}
}
if (newD.termLinks.length > 0 && Globals.termMeanings == 0) {
Globals.termMeanings.push(newD);
}
_.each(data, function(val) { _.each(data, function(val) {
if (val.relationshipStatus == "ACTIVE") { if (val.relationshipStatus == "ACTIVE") {
termData += '<span class="btn btn-action btn-sm btn-icon btn-blue" title=' + val.displayText + ' data-id="termClick"><span>' + val.displayText + '</span><i class="fa fa-close" data-id="deleteTerm" data-guid="' + val.guid + '" data-type="term" title="Remove Term"></i></span>'; termData += '<span class="btn btn-action btn-sm btn-icon btn-blue" title=' + val.displayText + ' data-id="termClick"><span>' + val.displayText + '</span><i class="fa fa-close" data-id="deleteTerm" data-guid="' + val.guid + '" data-type="term" title="Remove Term"></i></span>';
...@@ -458,13 +446,18 @@ define(['require', ...@@ -458,13 +446,18 @@ define(['require',
}); });
}, },
onClickAddTermBtn: function(e) { onClickAddTermBtn: function(e) {
var that = this; var that = this,
entityGuid = that.id,
associatedTerms = this.collection.first().get('entity').relationshipAttributes.meanings;
require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) { require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) {
var view = new AssignTermLayoutView({ var view = new AssignTermLayoutView({
guid: that.id, guid: that.id,
callback: function() { callback: function() {
that.fetchCollection(); that.fetchCollection();
}, },
associatedTerms: associatedTerms,
showLoader: that.showLoader.bind(that), showLoader: that.showLoader.bind(that),
hideLoader: that.hideLoader.bind(that), hideLoader: that.hideLoader.bind(that),
glossaryCollection: that.glossaryCollection glossaryCollection: that.glossaryCollection
......
...@@ -59,7 +59,7 @@ define(['require', ...@@ -59,7 +59,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'glossaryCollection', 'guid', 'callback', 'hideLoader', 'isCategoryView', 'categoryData', 'isTermView', 'termData', 'isAttributeRelationView', 'selectedTermAttribute')); _.extend(this, _.pick(options, 'glossaryCollection', 'guid', 'callback', 'hideLoader', 'isCategoryView', 'categoryData', 'isTermView', 'termData', 'isAttributeRelationView', 'selectedTermAttribute', 'associatedTerms'));
var that = this; var that = this;
this.options = options; this.options = options;
if (!this.isCategoryView && !this.isTermView && !this.isAttributeRelationView) { if (!this.isCategoryView && !this.isTermView && !this.isAttributeRelationView) {
...@@ -207,7 +207,8 @@ define(['require', ...@@ -207,7 +207,8 @@ define(['require',
"isAssignCategoryView": that.isTermView, "isAssignCategoryView": that.isTermView,
"isAssignEntityView": that.isEntityView, "isAssignEntityView": that.isEntityView,
"isAssignAttributeRelationView": that.isAttributeRelationView, "isAssignAttributeRelationView": that.isAttributeRelationView,
"glossary": that.glossary "glossary": that.glossary,
"associatedTerms": that.associatedTerms
}, that.options))); }, that.options)));
}); });
}, },
......
...@@ -320,8 +320,10 @@ define(['require', ...@@ -320,8 +320,10 @@ define(['require',
}); });
} }
} }
var view = new AssignTermLayoutView({ var view = new AssignTermLayoutView({
categoryData: that.data, categoryData: that.data,
associatedTerms: that.data && that.data.terms && that.data.terms.length > 0 ? that.data.terms : [],
isCategoryView: that.isCategoryView, isCategoryView: that.isCategoryView,
callback: function() { callback: function() {
that.getData(); that.getData();
......
...@@ -88,7 +88,7 @@ define(['require', ...@@ -88,7 +88,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'value', 'glossaryCollection', 'glossary', 'isAssignTermView', 'isAssignCategoryView', 'isAssignEntityView', 'isAssignAttributeRelationView')); _.extend(this, _.pick(options, 'associatedTerms', 'guid', 'value', 'glossaryCollection', 'glossary', 'isAssignTermView', 'isAssignCategoryView', 'isAssignEntityView', 'isAssignAttributeRelationView'));
this.viewType = "term"; this.viewType = "term";
this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView || this.isAssignAttributeRelationView; this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView || this.isAssignAttributeRelationView;
this.bindEvents(); this.bindEvents();
...@@ -249,7 +249,9 @@ define(['require', ...@@ -249,7 +249,9 @@ define(['require',
generateData: function(opt) { generateData: function(opt) {
var that = this, var that = this,
selectedGuid = that.guid, selectedGuid = that.guid,
associatedTerms = that.associatedTerms,
type = opt.type; type = opt.type;
if (opt.type == this.viewType) { if (opt.type == this.viewType) {
this.query[opt.type].isNodeNotFoundAtLoad = true; this.query[opt.type].isNodeNotFoundAtLoad = true;
} }
...@@ -339,38 +341,39 @@ define(['require', ...@@ -339,38 +341,39 @@ define(['require',
}); });
} }
if (type == "term" && obj.terms) { if (type == "term" && obj.terms) {
var theTerm = _.find(Globals.termMeanings, function(obj, index) {
if (obj.guid == selectedGuid) {
return obj;
}
});
_.each(obj.terms, function(term) { _.each(obj.terms, function(term) {
var includedTerms = _.map(theTerm && theTerm.termLinks, function(obj, index) { if (associatedTerms) {
return obj.termGuid || obj.guid; var associatedTermFound = _.find(associatedTerms, function(obj, index) {
}); if ((obj.termGuid ? obj.termGuid : obj.guid) == term.termGuid) {
if ((!includedTerms.includes(term.termGuid))) { return obj;
var typeName = term.typeName || "GlossaryTerm",
guid = term.termGuid,
termObj = {
"text": _.escape(term.displayText),
"type": typeName,
"gType": "term",
"guid": guid,
"id": guid,
"parent": obj,
"glossaryName": obj.name,
"glossaryId": obj.guid,
"model": term,
"icon": "fa fa-file-o"
} }
termObj.state = getSelectedState({ });
index: i, if (associatedTermFound) {
node: termObj, return;
objGuid: guid }
})
parent.children.push(termObj);
} }
var typeName = term.typeName || "GlossaryTerm",
guid = term.termGuid,
termObj = {
"text": _.escape(term.displayText),
"type": typeName,
"gType": "term",
"guid": guid,
"id": guid,
"parent": obj,
"glossaryName": obj.name,
"glossaryId": obj.guid,
"model": term,
"icon": "fa fa-file-o"
}
termObj.state = getSelectedState({
index: i,
node: termObj,
objGuid: guid
})
parent.children.push(termObj);
}); });
} }
return parent; return parent;
......
...@@ -944,10 +944,12 @@ define(['require', ...@@ -944,10 +944,12 @@ define(['require',
}, },
onClickAddTermBtn: function(e) { onClickAddTermBtn: function(e) {
var that = this, var that = this,
entityGuid = $(e.currentTarget).data("guid"); entityGuid = $(e.currentTarget).data("guid"),
associatedTerms = this.searchCollection.find({ guid: entityGuid }).get('meanings');
require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) { require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) {
var view = new AssignTermLayoutView({ var view = new AssignTermLayoutView({
guid: entityGuid, guid: entityGuid,
associatedTerms: associatedTerms,
callback: function() { callback: function() {
that.fetchCollection(); that.fetchCollection();
}, },
......
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