Commit d561404b by Abhishek 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 a9a095e1
...@@ -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/Enums', 'moment'], function(require, Utils, Modal, Messages, Enums, moment) { define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Globals', 'utils/Enums', 'moment'], function(require, Utils, Modal, Messages, Globals, Enums, moment) {
'use strict'; 'use strict';
var CommonViewFunction = {}; var CommonViewFunction = {};
...@@ -314,6 +314,18 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -314,6 +314,18 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
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); this.generateTerm(collectionJSON.relationshipAttributes.meanings, collectionJSON);
} }
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,10 +403,23 @@ define(['require', ...@@ -403,10 +403,23 @@ define(['require',
this.ui.propagatedTagList.html(propagatedTagListData); this.ui.propagatedTagList.html(propagatedTagListData);
}, },
generateTerm: function(data) { generateTerm: function(data, obj) {
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) {
console.log(val.guid)
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>';
} }
......
...@@ -248,6 +248,7 @@ define(['require', ...@@ -248,6 +248,7 @@ define(['require',
}, },
generateData: function(opt) { generateData: function(opt) {
var that = this, var that = this,
selectedGuid = that.guid,
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;
...@@ -338,27 +339,38 @@ define(['require', ...@@ -338,27 +339,38 @@ 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 typeName = term.typeName || "GlossaryTerm", var includedTerms = _.map(theTerm && theTerm.termLinks, function(obj, index) {
guid = term.termGuid, return obj.termGuid || obj.guid;
termObj = { });
"text": term.displayText, if ((!includedTerms.includes(term.termGuid))) {
"type": typeName, var typeName = term.typeName || "GlossaryTerm",
"gType": "term", guid = term.termGuid,
"guid": guid, termObj = {
"id": guid, "text": term.displayText,
"parent": obj, "type": typeName,
"glossaryName": obj.name, "gType": "term",
"glossaryId": obj.guid, "guid": guid,
"model": term, "id": guid,
"icon": "fa fa-file-o" "parent": obj,
} "glossaryName": obj.name,
termObj.state = getSelectedState({ "glossaryId": obj.guid,
index: i, "model": term,
node: termObj, "icon": "fa fa-file-o"
objGuid: guid }
}) termObj.state = getSelectedState({
parent.children.push(termObj); index: i,
node: termObj,
objGuid: guid
})
parent.children.push(termObj);
}
}); });
} }
return parent; return parent;
...@@ -398,6 +410,7 @@ define(['require', ...@@ -398,6 +410,7 @@ define(['require',
var $termTree = this.ui.termTree, var $termTree = this.ui.termTree,
$categoryTree = this.ui.categoryTree, $categoryTree = this.ui.categoryTree,
that = this, that = this,
this_guid = that.guid,
getTreeConfig = function(options) { getTreeConfig = function(options) {
return { return {
"plugins": ["search", "themes", "core", "wholerow", "sort", "conditionalselect"], "plugins": ["search", "themes", "core", "wholerow", "sort", "conditionalselect"],
......
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