Repository: atlas
Updated Branches:
  refs/heads/master cbca591de -> 3b75d56d9


ATLAS-2678: UI - term-to-term association attribute values are not saved

Signed-off-by: Madhan Neethiraj <mad...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/3b75d56d
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/3b75d56d
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/3b75d56d

Branch: refs/heads/master
Commit: 3b75d56d9e151f9ad946da0ff1bb081a784703b7
Parents: cbca591
Author: kevalbhatt <kbh...@apache.org>
Authored: Mon May 14 21:38:14 2018 +0530
Committer: Madhan Neethiraj <mad...@apache.org>
Committed: Mon May 14 10:04:52 2018 -0700

----------------------------------------------------------------------
 .../glossary/AssignTermLayoutView_tmpl.html     |  2 +-
 .../public/js/utils/CommonViewFunction.js       |  8 +--
 .../js/views/glossary/AssignTermLayoutView.js   |  3 +-
 .../views/glossary/GlossaryDetailLayoutView.js  | 31 +++++----
 .../js/views/glossary/GlossaryLayoutView.js     | 70 +++++++++++---------
 .../glossary/TermRelationAttributeLayoutView.js |  2 +-
 .../js/views/tag/TagDetailTableLayoutView.js    |  8 ++-
 7 files changed, 69 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/templates/glossary/AssignTermLayoutView_tmpl.html
----------------------------------------------------------------------
diff --git 
a/dashboardv2/public/js/templates/glossary/AssignTermLayoutView_tmpl.html 
b/dashboardv2/public/js/templates/glossary/AssignTermLayoutView_tmpl.html
index 385d809..4808ecb 100644
--- a/dashboardv2/public/js/templates/glossary/AssignTermLayoutView_tmpl.html
+++ b/dashboardv2/public/js/templates/glossary/AssignTermLayoutView_tmpl.html
@@ -27,7 +27,7 @@
             <div class="form-group">
                 <label class="control-label col-sm-2" 
for="name">{{@key}}</label>
                 <div class="col-sm-10">
-                    <input class="form-control" name="{{@key}}" value="" 
data-id="displayName" placeholder="{{@key}}" />
+                    <input class="form-control" name="{{@key}}" 
data-id="displayName" placeholder="{{@key}}" />
                 </div>
             </div>
             {{/each}}

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js 
b/dashboardv2/public/js/utils/CommonViewFunction.js
index bd99de9..3ee7609 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -622,9 +622,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
                 }
             });
             modal.on('ok', function() {
-                if (isGlossaryView) {
-                    modal.$el.find('button.ok').attr("disabled", true);
-                }
+                modal.$el.find('button.ok').attr("disabled", true);
                 
CommonViewFunction.createEditGlossaryCategoryTermSubmit(_.extend({ "ref": view, 
"modal": modal }, options));
             });
             modal.on('closeModal', function() {
@@ -669,9 +667,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
                 modal.trigger('closeModal');
             },
             cust_error: function() {
-                if (isGlossaryView) {
-                    modal.$el.find('button.ok').attr("disabled", false);
-                }
+                modal.$el.find('button.ok').attr("disabled", false);
             }
         }
         if (model) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/views/glossary/AssignTermLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/glossary/AssignTermLayoutView.js 
b/dashboardv2/public/js/views/glossary/AssignTermLayoutView.js
index b15a175..69aa4d0 100644
--- a/dashboardv2/public/js/views/glossary/AssignTermLayoutView.js
+++ b/dashboardv2/public/js/views/glossary/AssignTermLayoutView.js
@@ -47,7 +47,6 @@ define(['require',
 
             /** ui selector cache */
             ui: {
-                termAttributeForm: '[data-id="termAttributeForm"]',
                 wizard: '[data-id="wizard"]'
             },
             /** ui events hash */
@@ -178,7 +177,7 @@ define(['require',
                     }
                     model.assignCategoryToTerm(_.extend(ajaxOptions, { data: 
JSON.stringify(data), guid: data.guid }));
                 } else if (this.isAttributeRelationView) {
-                    termAttributeFormData = 
this.ui.termAttributeForm.serializeArray().reduce(function(obj, item) {
+                    termAttributeFormData = 
this.$('[data-id="termAttributeForm"]').serializeArray().reduce(function(obj, 
item) {
                             obj[item.name] = item.value;
                             return obj;
                         }, {}),

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js 
b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
index c301ad2..70ec849 100644
--- a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
+++ b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
@@ -78,12 +78,13 @@ define(['require',
                         this.onClickRemoveAssociationBtn(e);
                     } else {
                         var guid = $(e.currentTarget).data('guid'),
+                            gId = this.data.anchor && 
this.data.anchor.glossaryGuid,
                             categoryObj = _.find(this.data.categories, { 
"categoryGuid": guid });
                         this.glossary.selectedItem = { "type": 
"GlossaryCategory", "guid": guid, "model": categoryObj };
                         Utils.setUrl({
                             url: '#!/glossary/' + guid,
                             mergeBrowserUrl: false,
-                            urlParams: { gType: "category", viewType: 
"category", fromView: "glossary" },
+                            urlParams: { gType: "category", viewType: 
"category", fromView: "glossary", gId: gId },
                             trigger: true,
                             updateTabState: true
                         });
@@ -94,12 +95,13 @@ define(['require',
                         this.onClickRemoveAssociationBtn(e);
                     } else {
                         var guid = $(e.currentTarget).data('guid'),
+                            gId = this.data.anchor && 
this.data.anchor.glossaryGuid,
                             termObj = _.find(this.data.terms, { "termGuid": 
guid });
                         this.glossary.selectedItem = { "type": "GlossaryTerm", 
"guid": guid, "model": termObj };
                         Utils.setUrl({
                             url: '#!/glossary/' + guid,
                             mergeBrowserUrl: false,
-                            urlParams: { gType: "term", viewType: "term", 
fromView: "glossary" },
+                            urlParams: { gType: "term", viewType: "term", 
fromView: "glossary", gId: gId },
                             trigger: true,
                             updateTabState: true
                         });
@@ -427,15 +429,18 @@ define(['require',
             renderTagTableLayoutView: function(options) {
                 var that = this;
                 require(['views/tag/TagDetailTableLayoutView'], 
function(TagDetailTableLayoutView) {
-                    that.RTagTableLayoutView.show(new 
TagDetailTableLayoutView(_.extend({}, options, {
-                        "entityName": that.ui.title.text(),
-                        "fetchCollection": that.getData.bind(that),
-                        "entity": that.data
-                    })));
+                    if (that.RTagTableLayoutView) {
+                        that.RTagTableLayoutView.show(new 
TagDetailTableLayoutView(_.extend({}, options, {
+                            "entityName": that.ui.title.text(),
+                            "fetchCollection": that.getData.bind(that),
+                            "entity": that.data
+                        })));
+                    }
                 });
             },
             renderSearchResultLayoutView: function(options) {
                 var that = this;
+
                 require(['views/search/SearchResultLayoutView'], 
function(SearchResultLayoutView) {
                     var value = {
                         'tag': "PII",
@@ -452,11 +457,13 @@ define(['require',
             renderRelationLayoutView: function(options) {
                 var that = this;
                 require(['views/glossary/TermRelationAttributeLayoutView'], 
function(TermRelationAttributeLayoutView) {
-                    that.RRelationLayoutView.show(new 
TermRelationAttributeLayoutView(_.extend({}, options, {
-                        "entityName": that.ui.title.text(),
-                        "fetchCollection": that.getData.bind(that),
-                        "data": that.data
-                    })));
+                    if (that.RRelationLayoutView) {
+                        that.RRelationLayoutView.show(new 
TermRelationAttributeLayoutView(_.extend({}, options, {
+                            "entityName": that.ui.title.text(),
+                            "fetchCollection": that.getData.bind(that),
+                            "data": that.data
+                        })));
+                    }
                 });
             },
         });

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js 
b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
index 28b79e3..d36afe0 100644
--- a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
+++ b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
@@ -120,6 +120,7 @@ define(['require',
                         var $tree = this.ui[this.viewType == "term" ? 
"termTree" : "categoryTree"];
                         if ($tree.jstree(true).refresh) {
                             $tree.jstree(true).refresh();
+                            this.setValues({ trigger: false });
                         }
                     }
                 }, this);
@@ -141,18 +142,18 @@ define(['require',
                     this.getGlossary();
                 }
             },
-            setValues: function() {
+            setValues: function(options) {
                 if (this.viewType == "category") {
                     if (!this.ui.glossaryView.prop("checked")) {
-                        this.ui.glossaryView.prop("checked", 
true).trigger("change");
+                        this.ui.glossaryView.prop("checked", 
true).trigger("change", options);
                     }
                 } else {
                     if (this.ui.glossaryView.prop("checked")) {
-                        this.ui.glossaryView.prop("checked", 
false).trigger("change");
+                        this.ui.glossaryView.prop("checked", 
false).trigger("change", options);
                     }
                 }
             },
-            glossaryViewToggle: function(e) {
+            glossaryViewToggle: function(e, options) {
                 var that = this;
                 if (e.currentTarget.checked) {
                     this.$('.category-view').show();
@@ -179,6 +180,7 @@ define(['require',
                         guid: model.guid,
                         id: model.guid,
                         model: model,
+                        text: model.displayName,
                         gType: "glossary"
                     }
                 }
@@ -188,22 +190,20 @@ define(['require',
                     if (obj.guid) {
                         var node = $tree.jstree(true).get_node(obj.guid);
                         if (node) {
-                            $tree.jstree('activate_node', obj.guid);
                             this.glossary.selectedItem = node.original;
-                        } else {
-                            setDefaultSelector();
+                            $tree.jstree('activate_node', obj.guid);
                         }
                     } else {
                         setDefaultSelector();
                         $tree.jstree('activate_node', 
that.glossary.selectedItem.guid);
                     }
-                    this.query[this.viewType] = _.extend(obj, 
_.pick(this.glossary.selectedItem, 'model', 'guid', 'gType'), { "viewType": 
this.viewType, "isNodeNotFoundAtLoad": 
this.query[this.viewType].isNodeNotFoundAtLoad });
+                    this.query[this.viewType] = _.extend(obj, 
_.pick(this.glossary.selectedItem, 'model', 'guid', 'gType', 'type'), { 
"viewType": this.viewType, "isNodeNotFoundAtLoad": 
this.query[this.viewType].isNodeNotFoundAtLoad });
                     var url = _.isEmpty(this.glossary.selectedItem) ? 
'#!/glossary' : '#!/glossary/' + this.glossary.selectedItem.guid;
                     Utils.setUrl({
                         "url": url,
                         "urlParams": _.extend({}, _.omit(obj, 'guid', 'model', 
'type', 'isNodeNotFoundAtLoad')),
                         "mergeBrowserUrl": false,
-                        "trigger": false,
+                        "trigger": (options && !_.isUndefined(options.trigger) 
? options.trigger : true),
                         "updateTabState": true
                     });
                 }
@@ -369,10 +369,11 @@ define(['require',
                     var $tree = this.ui[this.viewType == "term" ? "termTree" : 
"categoryTree"],
                         node = $tree.jstree(true).get_node(this.guid);
                     if (node) {
-                        $tree.jstree('activate_node', this.guid);
+                        $tree.jstree('activate_node', this.guid, { 
skipTrigger: true });
                         delete this.value.fromView;
                         delete this.value.updateView;
                         this.glossary.selectedItem = node.original;
+                        this.query[this.viewType] = _.extend({}, 
_.pick(this.glossary.selectedItem, 'model', 'guid', 'gType', 'type'), { 
"viewType": this.viewType });
                         Utils.setUrl({
                             url: '#!/glossary/' + this.guid,
                             urlParams: this.value,
@@ -458,21 +459,29 @@ define(['require',
                                 createAction(_.extend({}, options, data));
                             })
                             .on("select_node.jstree", function(e, data) {
-                                that.glossary.selectedItem = 
data.node.original;
-                                var popoverClassName = (type == "term" ? 
'.termPopover' : '.categoryPopover'),
-                                    currentClickedPopoverEl = "";
-                                if (data.event) {
-                                    if 
($(data.event.currentTarget).parent().hasClass('jstree-leaf')) {
-                                        currentClickedPopoverEl = 
$(data.event.currentTarget).parent().find(popoverClassName);
-                                    } else {
-                                        currentClickedPopoverEl = 
$(data.event.currentTarget).parent().find(">div " + popoverClassName);
+                                if (that.isAssignView) {
+                                    that.glossary.selectedItem = 
data.node.original;
+                                } else {
+                                    var popoverClassName = (type == "term" ? 
'.termPopover' : '.categoryPopover'),
+                                        currentClickedPopoverEl = "";
+                                    if (data.event) {
+                                        if 
($(data.event.currentTarget).parent().hasClass('jstree-leaf')) {
+                                            currentClickedPopoverEl = 
$(data.event.currentTarget).parent().find(popoverClassName);
+                                        } else {
+                                            currentClickedPopoverEl = 
$(data.event.currentTarget).parent().find(">div " + popoverClassName);
+                                        }
+                                        
$(popoverClassName).not(currentClickedPopoverEl).popover('hide');
+                                    }
+                                    if (that.query[type].isNodeNotFoundAtLoad 
== true) {
+                                        that.query[type].isNodeNotFoundAtLoad 
= false;
+                                    } else if (type == that.viewType) {
+                                        if (data && data.event && 
data.event.skipTrigger) {
+                                            return;
+                                        } else if 
(that.glossary.selectedItem.guid !== data.node.original.guid) {
+                                            that.glossary.selectedItem = 
data.node.original;
+                                            that.triggerUrl();
+                                        }
                                     }
-                                    
$(popoverClassName).not(currentClickedPopoverEl).popover('hide');
-                                }
-                                if (that.query[type].isNodeNotFoundAtLoad == 
true) {
-                                    that.query[type].isNodeNotFoundAtLoad = 
false;
-                                } else if (type == that.viewType) {
-                                    that.triggerUrl();
                                 }
                             }).on("search.jstree", function(e, data) {
                                 createAction(_.extend({}, options, data));
@@ -530,7 +539,7 @@ define(['require',
                     contentClass: 'termPopoverOptions',
                     popoverOptions: {
                         content: function() {
-                            var node = that.glossary.selectedItem,
+                            var node = that.query[that.viewType],
                                 liString = "";
                             if (node.type == "Glossary") {
                                 liString = "<li data-type=" + node.type + " 
class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' 
data-fn='createSubNode'>Create Term</a></li>" +
@@ -550,7 +559,7 @@ define(['require',
                     contentClass: 'categoryPopoverOptions',
                     popoverOptions: {
                         content: function() {
-                            var node = that.glossary.selectedItem,
+                            var node = that.query[that.viewType],
                                 liString = "";
                             if (node.type == "Glossary") {
                                 liString = "<li data-type=" + node.type + " 
class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' 
data-fn='createSubNode'>Create Category</a></li>" +
@@ -678,16 +687,17 @@ define(['require',
                 var selectedItem = this.glossary.selectedItem;
                 if (this.glossaryCollection.length && (_.isEmpty(selectedItem) 
|| this.query[this.viewType].isNodeNotFoundAtLoad)) {
                     var model = selectedItem.model
-                    if (model && !(model.parentCategory || 
model.parentCategoryGuid)) {
+                    if (model && !_.isUndefined(model.parentCategory || 
model.parentCategoryGuid)) {
                         selectedItem = { "model": 
this.glossaryCollection.first().toJSON() };
                         selectedItem.guid = selectedItem.model.guid;
                         selectedItem.type = "Glossary";
+                        selectedItem.gType = "glossary";
+                        selectedItem.text = model.displayName;
                         this.glossary.selectedItem = selectedItem;
                         this.query[this.viewType].model = selectedItem.model;
-                        this.query[this.viewType].gType = "glossary"
+                        this.query[this.viewType].gType = "glossary";
+                        this.query[this.viewType].type = "Glossary";
                         delete this.query[this.viewType].gId;
-                    } else {
-                        this.query[this.viewType].isNodeNotFoundAtLoad = false;
                     }
                 }
                 if (_.isEmpty(selectedItem)) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/views/glossary/TermRelationAttributeLayoutView.js
----------------------------------------------------------------------
diff --git 
a/dashboardv2/public/js/views/glossary/TermRelationAttributeLayoutView.js 
b/dashboardv2/public/js/views/glossary/TermRelationAttributeLayoutView.js
index 3c22b5f..bf9757b 100644
--- a/dashboardv2/public/js/views/glossary/TermRelationAttributeLayoutView.js
+++ b/dashboardv2/public/js/views/glossary/TermRelationAttributeLayoutView.js
@@ -231,7 +231,7 @@ define(['require',
                     getTerms: function(key) {
                         var terms = _.map(that.data[key], function(obj) {
                                 var name = _.escape(obj.displayText);
-                                return '<span class="btn btn-action btn-sm 
btn-icon btn-blue" title=' + _.escape(name) + ' data-id="termClick"><span>' + 
name + '</span><i class="fa fa-close" data-id="deleteAttribute" 
data-attributename="' + key + '" data-termguid="' + obj.termGuid + '" 
data-type="term" title="Remove Term"></i></span>';
+                                return '<span data-guid="' + obj.termGuid + '" 
class="btn btn-action btn-sm btn-icon btn-blue" title=' + _.escape(name) + ' 
data-id="termClick"><span>' + name + '</span><i class="fa fa-close" 
data-id="deleteAttribute" data-attributename="' + key + '" data-termguid="' + 
obj.termGuid + '" data-type="term" title="Remove Term"></i></span>';
                             }).join(""),
                             attributeButtons = "";
                         if (terms.length) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/3b75d56d/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js 
b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
index bc2fc42..35e0f87 100644
--- a/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagDetailTableLayoutView.js
@@ -102,9 +102,11 @@ define(['require',
                 var that = this;
                 require(['utils/TableLayout'], function(TableLayout) {
                     var cols = new 
Backgrid.Columns(that.getSchemaTableColumns());
-                    that.RTagTableLayoutView.show(new TableLayout(_.extend({}, 
that.commonTableOptions, {
-                        columns: cols
-                    })));
+                    if (that.RTagTableLayoutView) {
+                        that.RTagTableLayoutView.show(new 
TableLayout(_.extend({}, that.commonTableOptions, {
+                            columns: cols
+                        })));
+                    }
                 });
             },
             getSchemaTableColumns: function(options) {

Reply via email to