You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ni...@apache.org on 2021/04/14 10:08:27 UTC
[atlas] branch branch-2.0 updated: ATLAS-3903: UI - Glossary
category not reflected in the tree after creation.
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
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 6c259a6 ATLAS-3903: UI - Glossary category not reflected in the tree after creation.
6c259a6 is described below
commit 6c259a61875e9110208b993824d45493a0e44468
Author: prasad pawar <pr...@freestoneinfotech.com>
AuthorDate: Fri Apr 9 19:45:26 2021 +0530
ATLAS-3903: UI - Glossary category not reflected in the tree after creation.
Signed-off-by: nixonrodrigues <ni...@apache.org>
(cherry picked from 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, 95 insertions(+), 42 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..ac7435c 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) {
@@ -690,7 +712,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