This is an automated email from the ASF dual-hosted git repository. nixon pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 0527a3cfafbaa17e848a14489f2934b8b2f16552 Author: prasad pawar <prasad.pa...@freestoneinfotech.com> AuthorDate: Mon Apr 12 11:11:23 2021 +0530 ATLAS-3903:UI Glossary category not reflected in the tree after creation. --- .../js/views/glossary/GlossaryDetailLayoutView.js | 5 +- .../public/js/views/glossary/GlossaryLayoutView.js | 79 ++++++++++++++++------ .../js/views/glossary/GlossaryDetailLayoutView.js | 5 +- .../js/views/search/tree/GlossaryTreeLayoutView.js | 73 ++++++++++++++------ 4 files changed, 115 insertions(+), 47 deletions(-) diff --git a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js index bb8fe8f..24a8b06 100644 --- a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js +++ b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js @@ -346,7 +346,8 @@ define(['require', return terms; }, onClickAddTermBtn: function(e) { - var glossary = this.glossaryCollection; + var that = this, + glossary = this.glossaryCollection; if (this.value && this.value.gId) { var foundModel = this.glossaryCollection.find({ guid: this.value.gId }); if (foundModel) { @@ -359,7 +360,7 @@ define(['require', } var obj = { callback: function() { - this.getData(); + that.getData(); }, glossaryCollection: glossary, }, diff --git a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js index 5d9ba74..0de5c35 100644 --- a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js +++ b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js @@ -344,34 +344,56 @@ define(['require', node: parent, objGuid: obj.guid }); - if (type == "category" && obj.categories) { + var isSelected = false, + parentGuid = obj.guid, + parentCategoryGuid = null, + categoryList = [], + catrgoryRelation = []; _.each(obj.categories, function(category) { - if (category.parentCategoryGuid) { - return; + if (that.options.value) { + isSelected = that.options.value.guid ? that.options.value.guid == category.categoryGuid : false; } + var typeName = category.typeName || "GlossaryCategory", guid = category.categoryGuid, categoryObj = { - "text": _.escape(category.displayText), - "type": typeName, - "gType": "category", - "guid": guid, - "id": guid, - "parent": obj, - "glossaryId": obj.guid, - "glossaryName": obj.name, - "model": category, - "children": true, - "icon": "fa fa-files-o", + id: guid, + guid: guid, + text: _.escape(category.displayText), + type: typeName, + gType: "category", + glossaryId: obj.guid, + glossaryName: obj.name, + children: [], + model: category, + icon: "fa fa-files-o" }; categoryObj.state = getSelectedState({ index: i, node: categoryObj, objGuid: guid }) - parent.children.push(categoryObj) + if (category.parentCategoryGuid) { + catrgoryRelation.push({ parent: category.parentCategoryGuid, child: guid }) + } + categoryList.push(categoryObj); }); + _.each(categoryList, function(category) { + var getRelation = _.find(catrgoryRelation, function(catrgoryObj) { + if (catrgoryObj.child == category.guid) return catrgoryObj; + }) + if (getRelation) { + _.map(categoryList, function(catrgoryObj) { + if (catrgoryObj.guid == getRelation.parent) { + catrgoryObj["children"].push(category); + }; + }) + } else { + parent.children.push(category) + } + }) + } if (type == "term" && obj.terms) { _.each(obj.terms, function(term) { @@ -651,12 +673,27 @@ define(['require', CommonViewFunction.createEditGlossaryCategoryTerm({ "isCategoryView": true, "collection": that.glossaryCollection, - "callback": function() { - if (that.value.gType == "glossary") { - that.getGlossary(); - } else { - that.ui.categoryTree.jstree(true).refresh(); + "callback": function(updateCollection) { + var updatedObj = { + categoryGuid: updateCollection.guid, + displayText: updateCollection.name, + relationGuid: updateCollection.anchor ? updateCollection.anchor.relationGuid : null + }, + glossary = that.glossaryCollection.fullCollection.findWhere({ guid: updateCollection.anchor.glossaryGuid }); + if (updateCollection.parentCategory) { + updatedObj["parentCategoryGuid"] = updateCollection.parentCategory.categoryGuid; + } + if (glossary) { + var glossaryAttributes = glossary.attributes || null; + if (glossaryAttributes) { + if (glossaryAttributes.categories) { + glossaryAttributes['categories'].push(updatedObj); + } else { + glossaryAttributes['categories'] = [updatedObj]; + } + } } + that.ui.categoryTree.jstree(true).refresh(); }, "node": this.glossary.selectedItem }) @@ -690,7 +727,7 @@ define(['require', }), { silent: true }); } else if (that.value.gType == "category") { glossary.set('categories', _.reject(glossary.get('categories'), function(obj) { - return obj.categoryGuid == guid; + return obj.categoryGuid == guid || obj.parentCategoryGuid == guid; }), { silent: true }); } else { glossary = that.glossaryCollection.fullCollection.first(); diff --git a/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js b/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js index 551e229..24bfa2a 100644 --- a/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js +++ b/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js @@ -361,7 +361,8 @@ define(['require', return terms; }, onClickAddTermBtn: function(e) { - var glossary = this.glossaryCollection; + var that = this, + glossary = this.glossaryCollection; if (this.value && this.value.gId) { var foundModel = this.glossaryCollection.find({ guid: this.value.gId }); if (foundModel) { @@ -374,7 +375,7 @@ define(['require', } var obj = { callback: function() { - this.getData(); + that.getData(); }, glossaryCollection: glossary, }, diff --git a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js index 4a327d8..421855d 100644 --- a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js +++ b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js @@ -389,36 +389,46 @@ define([ var isSelected = false, parentGuid = obj.guid, parentCategoryGuid = null, - getParentCategory = function() { - var parentCategory = _.find(parent.model.categories, function(subCategory) { - return subCategory.categoryGuid === parentCategoryGuid; - }); - return parentCategory; - }; + categoryList = [], + catrgoryRelation = []; _.each(obj.categories, function(category) { if (that.options.value) { isSelected = that.options.value.guid ? that.options.value.guid == category.categoryGuid : false; } - if (category.parentCategoryGuid) { - return; - } + var typeName = category.typeName || "GlossaryCategory", guid = category.categoryGuid, categoryObj = { - "text": _.escape(category.displayText), - "type": typeName, - "gType": "category", - "guid": guid, - "id": guid, - "parent": obj, - "glossaryId": obj.guid, - "glossaryName": obj.name, - "model": category, - "children": true, - "icon": "fa fa-files-o" + id: guid, + guid: guid, + text: _.escape(category.displayText), + type: typeName, + gType: "category", + glossaryId: obj.guid, + glossaryName: obj.name, + children: [], + model: category, + icon: "fa fa-files-o" }; - parent.children.push(categoryObj) + if (category.parentCategoryGuid) { + catrgoryRelation.push({ parent: category.parentCategoryGuid, child: guid }) + } + categoryList.push(categoryObj); }); + _.each(categoryList, function(category) { + var getRelation = _.find(catrgoryRelation, function(catrgoryObj) { + if (catrgoryObj.child == category.guid) return catrgoryObj; + }) + if (getRelation) { + _.map(categoryList, function(catrgoryObj) { + if (catrgoryObj.guid == getRelation.parent) { + catrgoryObj["children"].push(category); + }; + }) + } else { + parent.children.push(category) + } + }) } if (that.isTermView && obj.terms) { var isSelected = false; @@ -491,7 +501,26 @@ define([ CommonViewFunction.createEditGlossaryCategoryTerm({ "isCategoryView": true, "collection": that.glossaryCollection, - "callback": function() { + "callback": function(updateCollection) { + var updatedObj = { + categoryGuid: updateCollection.guid, + displayText: updateCollection.name, + relationGuid: updateCollection.anchor ? updateCollection.anchor.relationGuid : null + }, + glossary = that.glossaryCollection.fullCollection.findWhere({ guid: updateCollection.anchor.glossaryGuid }); + if (updateCollection.parentCategory) { + updatedObj["parentCategoryGuid"] = updateCollection.parentCategory.categoryGuid; + } + if (glossary) { + var glossaryAttributes = glossary.attributes || null; + if (glossaryAttributes) { + if (glossaryAttributes.categories) { + glossaryAttributes['categories'].push(updatedObj); + } else { + glossaryAttributes['categories'] = [updatedObj]; + } + } + } that.ui.termSearchTree.jstree(true).refresh(); }, "node": selectednode[0].original