This is an automated email from the ASF dual-hosted git repository. nixon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 7b0ecd1dcb92dad5b9a0659f7b5f2a7fa1d95f93 Author: nixonrodrigues <ni...@apache.org> AuthorDate: Wed Apr 14 16:03:00 2021 +0530 Revert "ATLAS-3903: UI - Glossary category not reflected in the tree after creation." This reverts commit af2cc7496ef4c856545a730b2e0859066b8dd4b5. --- .../js/views/glossary/GlossaryDetailLayoutView.js | 5 +- .../public/js/views/glossary/GlossaryLayoutView.js | 54 +++++----------- .../js/views/glossary/GlossaryDetailLayoutView.js | 5 +- .../js/views/search/tree/GlossaryTreeLayoutView.js | 73 +++++++--------------- 4 files changed, 42 insertions(+), 95 deletions(-) diff --git a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js index 24a8b06..bb8fe8f 100644 --- a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js +++ b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js @@ -346,8 +346,7 @@ define(['require', return terms; }, onClickAddTermBtn: function(e) { - var that = this, - glossary = this.glossaryCollection; + var glossary = this.glossaryCollection; if (this.value && this.value.gId) { var foundModel = this.glossaryCollection.find({ guid: this.value.gId }); if (foundModel) { @@ -360,7 +359,7 @@ define(['require', } var obj = { callback: function() { - that.getData(); + this.getData(); }, glossaryCollection: glossary, }, diff --git a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js index ac7435c..5d9ba74 100644 --- a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js +++ b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js @@ -344,56 +344,34 @@ 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 (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 = { - 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" + "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", }; categoryObj.state = getSelectedState({ index: i, node: categoryObj, objGuid: guid }) - if (category.parentCategoryGuid) { - catrgoryRelation.push({ parent: category.parentCategoryGuid, child: guid }) - } - categoryList.push(categoryObj); + parent.children.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) { @@ -712,7 +690,7 @@ define(['require', }), { silent: true }); } else if (that.value.gType == "category") { glossary.set('categories', _.reject(glossary.get('categories'), function(obj) { - return obj.categoryGuid == guid || obj.parentCategoryGuid == guid; + return obj.categoryGuid == 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 24bfa2a..551e229 100644 --- a/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js +++ b/dashboardv3/public/js/views/glossary/GlossaryDetailLayoutView.js @@ -361,8 +361,7 @@ define(['require', return terms; }, onClickAddTermBtn: function(e) { - var that = this, - glossary = this.glossaryCollection; + var glossary = this.glossaryCollection; if (this.value && this.value.gId) { var foundModel = this.glossaryCollection.find({ guid: this.value.gId }); if (foundModel) { @@ -375,7 +374,7 @@ define(['require', } var obj = { callback: function() { - that.getData(); + this.getData(); }, glossaryCollection: glossary, }, diff --git a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js index 421855d..4a327d8 100644 --- a/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js +++ b/dashboardv3/public/js/views/search/tree/GlossaryTreeLayoutView.js @@ -389,46 +389,36 @@ define([ var isSelected = false, parentGuid = obj.guid, parentCategoryGuid = null, - categoryList = [], - catrgoryRelation = []; + getParentCategory = function() { + var parentCategory = _.find(parent.model.categories, function(subCategory) { + return subCategory.categoryGuid === parentCategoryGuid; + }); + return parentCategory; + }; _.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 = { - 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" + "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" }; - if (category.parentCategoryGuid) { - catrgoryRelation.push({ parent: category.parentCategoryGuid, child: guid }) - } - categoryList.push(categoryObj); + parent.children.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; @@ -501,26 +491,7 @@ define([ CommonViewFunction.createEditGlossaryCategoryTerm({ "isCategoryView": true, "collection": that.glossaryCollection, - "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]; - } - } - } + "callback": function() { that.ui.termSearchTree.jstree(true).refresh(); }, "node": selectednode[0].original