Repository: atlas Updated Branches: refs/heads/master 86fb9da49 -> 6d8c50cca
ATLAS-2018: UI: Attribute filter does not preserve state Signed-off-by: Madhan Neethiraj <[email protected]> (cherry picked from commit db317a4708fe1f6c87a1f7674f4fb3bbf70bebb1) Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/6d8c50cc Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/6d8c50cc Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/6d8c50cc Branch: refs/heads/master Commit: 6d8c50cca95a51db509c87c73c735ea1445c3fa3 Parents: 86fb9da Author: kevalbhatt <[email protected]> Authored: Fri Aug 18 18:14:58 2017 +0530 Committer: Madhan Neethiraj <[email protected]> Committed: Fri Aug 18 15:05:09 2017 -0700 ---------------------------------------------------------------------- dashboardv2/public/js/router/Router.js | 6 +- .../public/js/utils/CommonViewFunction.js | 6 +- .../views/business_catalog/SideNavLayoutView.js | 5 +- .../public/js/views/search/QueryBuilderView.js | 4 +- .../public/js/views/search/SearchLayoutView.js | 80 +++++++++++--------- .../public/js/views/search/SearchQueryView.js | 5 +- 6 files changed, 64 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/router/Router.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/router/Router.js b/dashboardv2/public/js/router/Router.js index 4f14d4d..4fac9c9 100644 --- a/dashboardv2/public/js/router/Router.js +++ b/dashboardv2/public/js/router/Router.js @@ -54,7 +54,11 @@ define([ 'classificationDefCollection': this.classificationDefCollection } this.sharedObj = { - searchTableColumns: {} + searchTableColumns: {}, + searchTableFilters: { + tagFilters: {}, + entityFilters: {} + } } }, bindCommonEvents: function() { http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/utils/CommonViewFunction.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js index 177e052..48ee41f 100644 --- a/dashboardv2/public/js/utils/CommonViewFunction.js +++ b/dashboardv2/public/js/utils/CommonViewFunction.js @@ -408,7 +408,11 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum _.each(attrObj, function(obj) { attrQuery.push(obj.id + "::" + obj.operator + "::" + obj.value + "::" + obj.type); }); - return attrQuery.join(); + if (attrQuery.length) { + return attrQuery.join(); + } else { + return null; + } } else { return null; } http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js index 42fbc83..28a658a 100644 --- a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js +++ b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js @@ -83,7 +83,7 @@ define(['require', return events; }, initialize: function(options) { - _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'searchTableColumns')); + _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'searchTableColumns', 'searchTableFilters')); if (Globals.taxonomy) { this.tabClass = "tab col-sm-4"; } else { @@ -128,7 +128,8 @@ define(['require', entityDefCollection: that.entityDefCollection, enumDefCollection: that.enumDefCollection, classificationDefCollection: that.classificationDefCollection, - searchTableColumns: that.searchTableColumns + searchTableColumns: that.searchTableColumns, + searchTableFilters: that.searchTableFilters })); }); }, http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/views/search/QueryBuilderView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/search/QueryBuilderView.js b/dashboardv2/public/js/views/search/QueryBuilderView.js index ebef684..e94c05d 100644 --- a/dashboardv2/public/js/views/search/QueryBuilderView.js +++ b/dashboardv2/public/js/views/search/QueryBuilderView.js @@ -52,7 +52,7 @@ define(['require', * @constructs */ initialize: function(options) { - _.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag')); + _.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag', 'searchTableFilters')); this.attrObj = _.sortBy(this.attrObj, 'name'); this.filterType = this.tag ? 'tagFilters' : 'entityFilters'; }, @@ -134,7 +134,7 @@ define(['require', var that = this, filters = []; if (this.value) { - var rules_widgets = CommonViewFunction.attributeFilter.extractUrl(this.value[this.filterType]); + var rules_widgets = CommonViewFunction.attributeFilter.extractUrl(this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)]); } _.each(this.attrObj, function(obj) { var returnObj = that.getObjDef(obj, rules_widgets); http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/views/search/SearchLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js b/dashboardv2/public/js/views/search/SearchLayoutView.js index 6af9b2a..5957a46 100644 --- a/dashboardv2/public/js/views/search/SearchLayoutView.js +++ b/dashboardv2/public/js/views/search/SearchLayoutView.js @@ -81,7 +81,7 @@ define(['require', * @constructs */ initialize: function(options) { - _.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', 'searchTableColumns')); + _.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', 'searchTableColumns', 'searchTableFilters')); this.type = "basic"; var param = Utils.getUrlState.getQueryParams(); this.query = { @@ -92,8 +92,6 @@ define(['require', basic: { query: null, type: null, - typeFilter: null, - tagFilter: null, tag: null, attributes: null } @@ -133,51 +131,39 @@ define(['require', filtertype = [filtertypeParam]; } } - var typeCheck = function(filterQueryObj, type) { - var filterObj = filterQueryObj[type]; + var typeCheck = function(filterObj, type) { if (that.value.type) { if (filterObj && filterObj.length) { that.ui.typeAttrFilter.addClass('active'); } else { - filterQueryObj[type] = null; - that.value[type] = null; that.ui.typeAttrFilter.removeClass('active'); } that.ui.typeAttrFilter.prop('disabled', false); } else { - filterQueryObj[type] = null; - that.value[type] = null; that.ui.typeAttrFilter.removeClass('active'); that.ui.typeAttrFilter.prop('disabled', true); } - } - var tagCheck = function(filterQueryObj, type) { - var filterObj = filterQueryObj[type]; + var tagCheck = function(filterObj, type) { if (that.value.tag) { that.ui.tagAttrFilter.prop('disabled', false); if (filterObj && filterObj.length) { that.ui.tagAttrFilter.addClass('active'); } else { - filterQueryObj[type] = null; - that.value[type] = null; that.ui.tagAttrFilter.removeClass('active'); } } else { - filterQueryObj[type] = null; - that.value[type] = null; that.ui.tagAttrFilter.removeClass('active'); that.ui.tagAttrFilter.prop('disabled', true); } } _.each(filtertype, function(type) { - var filterObj = that.query[that.type][type], - filterQueryObj = that.query[that.type]; + var filterObj = that.searchTableFilters[type]; if (type == "entityFilters") { - typeCheck(filterQueryObj, type) + typeCheck(filterObj[that.value.type], type); } if (type == "tagFilters") { - tagCheck(filterQueryObj, type) + tagCheck(filterObj[that.value.tag], type); } }); }, @@ -191,14 +177,19 @@ define(['require', filterType = (isTagEl ? 'tagFilters' : 'entityFilters'), value = value.length ? value : null; if (this.value) { - if (this.value[key] !== value || (!value && !this.value[key]) || (!this.value[filterType])) { + //On Change handle + if (this.value[key] !== value || (!value && !this.value[key])) { var temp = {}; temp[key] = value; _.extend(this.value, temp); - this.query[this.type][filterType] = null; - this.value[filterType] = null; - this.makeFilterButtonActive(filterType); + } else { + // Initial loading handle. + var filterObj = this.searchTableFilters[filterType]; + if (filterObj && this.value[key]) { + this.searchTableFilters[filterType][this.value[key]] = this.value[filterType] ? this.value[filterType] : null; + } } + this.makeFilterButtonActive(filterType); } else { this.ui.tagAttrFilter.prop('disabled', true); this.ui.typeAttrFilter.prop('disabled', true); @@ -244,8 +235,6 @@ define(['require', query: null, type: null, tag: null, - entityFilters: null, - tagFilters: null, attributes: null }), param); }, @@ -289,7 +278,8 @@ define(['require', typeHeaders: that.typeHeaders, entityDefCollection: that.entityDefCollection, enumDefCollection: that.enumDefCollection, - classificationDefCollection: that.classificationDefCollection + classificationDefCollection: that.classificationDefCollection, + searchTableFilters: that.searchTableFilters }); that.attrModal.on('ok', function(scope, e) { that.okAttrFilterButton(e); @@ -297,11 +287,19 @@ define(['require', }); }, okAttrFilterButton: function(e) { - var filtertype = this.attrModal.tag ? 'tagFilters' : 'entityFilters', + var isTag = this.attrModal.tag ? true : false, + filtertype = isTag ? 'tagFilters' : 'entityFilters', rule = this.attrModal.RQueryBuilder.currentView.ui.builder.queryBuilder('getRules'); if (rule) { - this.query[this.type][filtertype] = CommonViewFunction.attributeFilter.generateUrl(rule.rules); + var ruleUrl = CommonViewFunction.attributeFilter.generateUrl(rule.rules); + this.searchTableFilters[filtertype][(isTag ? this.value.tag : this.value.type)] = ruleUrl; this.makeFilterButtonActive(filtertype); + if (this.value && this.searchTableColumns) { + if (!this.searchTableColumns[this.value.type]) { + this.searchTableColumns[this.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"] + } + this.searchTableColumns[this.value.type] = _.sortBy(_.union(this.searchTableColumns[this.value.type], _.pluck(rule.rules, 'id'))); + } this.attrModal.modal.close(); if ($(e.currentTarget).hasClass('search')) { this.findSearchResult(); @@ -342,9 +340,9 @@ define(['require', this.value = paramObj; } if (this.value) { - if (this.value.dslChecked == "true" && this.dsl == false) { + if (this.value.dslChecked == "true") { this.ui.searchType.prop("checked", true).trigger("change"); - } else if (this.value.dslChecked == "false" && this.dsl == true) { + } else { this.ui.searchType.prop("checked", false).trigger("change"); } this.ui.typeLov.val(this.value.type); @@ -387,6 +385,14 @@ define(['require', this.query[this.type].type = this.ui.typeLov.select2('val') || null; if (!this.dsl) { this.query[this.type].tag = this.ui.tagLov.select2('val') || null; + var entityFilterObj = this.searchTableFilters['entityFilters'], + tagFilterObj = this.searchTableFilters['tagFilters']; + if (this.value.tag) { + params['tagFilters'] = tagFilterObj[this.value.tag] + } + if (this.value.type) { + params['entityFilters'] = entityFilterObj[this.value.type] + } } if (this.dsl) { params['attributes'] = null; @@ -416,9 +422,11 @@ define(['require', this.dsl = true; this.$('.tagBox').hide(); this.$('.temFilterBtn').hide(); - this.$('.temFilter').toggleClass('col-sm-10 col-sm-12'); + this.$('.temFilter').addClass('col-sm-12'); + this.$('.temFilter').removeClass('col-sm-10'); } else { - this.$('.temFilter').toggleClass('col-sm-10 col-sm-12'); + this.$('.temFilter').addClass('col-sm-10'); + this.$('.temFilter').removeClass('col-sm-12'); this.$('.temFilterBtn').show(); this.$('.tagBox').show(); this.dsl = false; @@ -427,7 +435,7 @@ define(['require', if (paramObj && this.type == paramObj.searchType) { this.updateQueryObject(paramObj); } - if (this.type == "basic") { + if (paramObj && this.type == "basic") { this.query[this.type].attribute = paramObj.attributes ? paramObj.attributes : null; } Utils.setUrl({ @@ -448,6 +456,10 @@ define(['require', this.ui.typeLov.val("").trigger("change"); this.ui.tagLov.val("").trigger("change"); this.ui.searchInput.val(""); + if (this.dsl) { + this.searchTableFilters.tagFilters = {}; + this.searchTableFilters.entityFilters = {}; + } this.checkForButtonVisiblity(); Utils.setUrl({ url: '#!/search/searchResult', http://git-wip-us.apache.org/repos/asf/atlas/blob/6d8c50cc/dashboardv2/public/js/views/search/SearchQueryView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/search/SearchQueryView.js b/dashboardv2/public/js/views/search/SearchQueryView.js index 281e37e..b07c325 100644 --- a/dashboardv2/public/js/views/search/SearchQueryView.js +++ b/dashboardv2/public/js/views/search/SearchQueryView.js @@ -50,7 +50,7 @@ define(['require', * @constructs */ initialize: function(options) { - _.extend(this, _.pick(options, 'value', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'classificationDefCollection', 'tag')); + _.extend(this, _.pick(options, 'value', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'classificationDefCollection', 'tag', 'searchTableFilters')); this.bindEvents(); var that = this; this.modal = new Modal({ @@ -83,7 +83,8 @@ define(['require', searchVent: this.searchVent, entityDefCollection: this.entityDefCollection, enumDefCollection: this.enumDefCollection, - classificationDefCollection: this.classificationDefCollection + classificationDefCollection: this.classificationDefCollection, + searchTableFilters: this.searchTableFilters } if (this.tag) {
