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 2018/01/03 13:20:53 UTC

[2/3] atlas git commit: ATLAS-2272 : UI - Save the state of dragged columns using save search API.

ATLAS-2272 : UI - Save the state of dragged columns using save search API.


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

Branch: refs/heads/master
Commit: 9abc89bf8f55e073b43b86a7ba5ce6917e2f7a6d
Parents: 4516418
Author: pratik24mac <pr...@gmail.com>
Authored: Fri Dec 29 16:29:42 2017 +0530
Committer: nixonrodrigues <ni...@apache.org>
Committed: Wed Jan 3 18:49:49 2018 +0530

----------------------------------------------------------------------
 dashboardv2/public/css/scss/search.scss         |   9 ++
 .../public/js/utils/CommonViewFunction.js       | 126 ++++++++++---------
 dashboardv2/public/js/utils/Enums.js            |  25 ++--
 .../public/js/views/search/SearchLayoutView.js  |   2 +-
 .../js/views/search/SearchResultLayoutView.js   |  26 +++-
 .../js/views/search/save/SaveSearchView.js      |   2 +-
 6 files changed, 116 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/dashboardv2/public/css/scss/search.scss
----------------------------------------------------------------------
diff --git a/dashboardv2/public/css/scss/search.scss b/dashboardv2/public/css/scss/search.scss
index d3df2b7..9500558 100644
--- a/dashboardv2/public/css/scss/search.scss
+++ b/dashboardv2/public/css/scss/search.scss
@@ -112,9 +112,18 @@ $color_celeste_approx: #1D1F2B;
         }
     }
 }
+.table-responsive{
+    position: relative;
+}
 
 .sindu_dragger {
     @extend .gu-mirror;
+    &.sindu_column {
+        li {
+            float: none !important;
+            display: table-cell !important;
+        }
+    }
     .gu-transit {
         box-shadow: 0px 1px 15px inset;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js
index 08437ac..6cba9c0 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -296,26 +296,34 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
     CommonViewFunction.generateObjectForSaveSearchApi = function(options) {
         var obj = {
             name: options.name,
-            guid: options.guid,
-            searchParameters: {}
+            guid: options.guid
         };
         var value = options.value;
         if (value) {
-            _.each(Enums.extractFromUrlForSearch, function(v, k) {
-                var val = value[k];
-                if (!_.isUndefinedNull(val)) {
-                    if (k == "attributes") {
-                        val = val.split(',');
-                    } else if (_.contains(["tagFilters","entityFilters"],k)) {
-                        val = CommonViewFunction.attributeFilter.generateAPIObj(val);
-                    } else if (_.contains(["includeDE","excludeST","excludeSC"],k)) {
-                        val = val ? false : true;
-                    }
-                }
-                if (_.contains(["includeDE","excludeST","excludeSC"],k)) {
-                    val = _.isUndefinedNull(val) ? true : val;
+            _.each(Enums.extractFromUrlForSearch, function(svalue, skey) {
+                if (_.isObject(svalue)) {
+                    _.each(svalue, function(v, k) {
+                        var val = value[k];
+                        if (!_.isUndefinedNull(val)) {
+                            if (k == "attributes") {
+                                val = val.split(',');
+                            } else if (_.contains(["tagFilters", "entityFilters"], k)) {
+                                val = CommonViewFunction.attributeFilter.generateAPIObj(val);
+                            } else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
+                                val = val ? false : true;
+                            }
+                        }
+                        if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
+                            val = _.isUndefinedNull(val) ? true : val;
+                        }
+                        if (!obj[skey]) {
+                            obj[skey] = {};
+                        }
+                        obj[skey][v] = val;
+                    });
+                } else {
+                    obj[skey] = value[skey];
                 }
-                obj.searchParameters[v] = val;
             });
             return obj;
         }
@@ -326,50 +334,56 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
             entityDefCollection = options.entityDefCollection,
             obj = {};
         if (value) {
-            _.each(Enums.extractFromUrlForSearch, function(v, k) {
-                var val = value[v];
-                if (!_.isUndefinedNull(val)) {
-                    if (k == "attributes") {
-                        val = val.join(',');
-                    } else if (k == "tagFilters") {
-                        if (classificationDefCollection) {
-                            var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value.classification })
-                            attributeDefs = Utils.getNestedSuperTypeObj({
-                                collection: classificationDefCollection,
-                                attrMerge: true,
-                                data: classificationDef.toJSON()
-                            });
-                            _.each(val.criterion, function(obj) {
-                                var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
-                                if (attributeDef) {
-                                    obj.attributeValue = obj.attributeValue;
-                                    obj['attributeType'] = attributeDef.typeName;
+            _.each(Enums.extractFromUrlForSearch, function(svalue, skey) {
+                if(_.isObject(svalue)) {
+                    _.each(svalue, function(v, k) {
+                        var val = value[skey][v];
+                        if (!_.isUndefinedNull(val)) {
+                            if (k == "attributes") {
+                                val = val.join(',');
+                            } else if (k == "tagFilters") {
+                                if (classificationDefCollection) {
+                                    var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification })
+                                    attributeDefs = Utils.getNestedSuperTypeObj({
+                                        collection: classificationDefCollection,
+                                        attrMerge: true,
+                                        data: classificationDef.toJSON()
+                                    });
+                                    _.each(val.criterion, function(obj) {
+                                        var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
+                                        if (attributeDef) {
+                                            obj.attributeValue = obj.attributeValue;
+                                            obj['attributeType'] = attributeDef.typeName;
+                                        }
+                                    });
                                 }
-                            });
-                        }
-                        val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
-                    } else if (k == "entityFilters") {
-                        if (entityDefCollection) {
-                            var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value.typeName }),
-                                attributeDefs = Utils.getNestedSuperTypeObj({
-                                    collection: entityDefCollection,
-                                    attrMerge: true,
-                                    data: entityDef.toJSON()
-                                });
-                            _.each(val.criterion, function(obj) {
-                                var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
-                                if (attributeDef) {
-                                    obj.attributeValue = obj.attributeValue;
-                                    obj['attributeType'] = attributeDef.typeName;
+                                val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
+                            } else if (k == "entityFilters") {
+                                if (entityDefCollection) {
+                                    var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }),
+                                        attributeDefs = Utils.getNestedSuperTypeObj({
+                                            collection: entityDefCollection,
+                                            attrMerge: true,
+                                            data: entityDef.toJSON()
+                                        });
+                                    _.each(val.criterion, function(obj) {
+                                        var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
+                                        if (attributeDef) {
+                                            obj.attributeValue = obj.attributeValue;
+                                            obj['attributeType'] = attributeDef.typeName;
+                                        }
+                                    });
                                 }
-                            });
+                                val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
+                            } else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
+                                val = val ? false : true;
+                            }
                         }
-                        val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
-                    } else if (_.contains(["includeDE","excludeST","excludeSC"],k)) {
-                        val = val ? false : true;
-                    }
+                        obj[k] = val;
+                    });
+                }else{
+                    obj[skey] = value[skey];
                 }
-                obj[k] = val;
             });
             return obj;
         }

http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/dashboardv2/public/js/utils/Enums.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/Enums.js b/dashboardv2/public/js/utils/Enums.js
index 94010ed..7aca247 100644
--- a/dashboardv2/public/js/utils/Enums.js
+++ b/dashboardv2/public/js/utils/Enums.js
@@ -57,17 +57,20 @@ define(['require'], function(require) {
         'annual': "Annual Distribution"
     }
     Enums.extractFromUrlForSearch = {
-        "pageLimit": "limit",
-        "type": "typeName",
-        "tag": "classification",
-        "query": "query",
-        "pageOffset": "offset",
-        "includeDE": "excludeDeletedEntities",
-        "excludeST": "includeSubTypes",
-        "excludeSC": "includeSubClassifications",
-        "tagFilters": "tagFilters",
-        "entityFilters": "entityFilters",
-        "attributes": "attributes"
+        "searchParameters": {
+            "pageLimit": "limit",
+            "type": "typeName",
+            "tag": "classification",
+            "query": "query",
+            "pageOffset": "offset",
+            "includeDE": "excludeDeletedEntities",
+            "excludeST": "includeSubTypes",
+            "excludeSC": "includeSubClassifications",
+            "tagFilters": "tagFilters",
+            "entityFilters": "entityFilters",
+            "attributes": "attributes"
+        },
+        "uiParameters": "uiParameters"
     }
 
     return Enums;

http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/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 b0d4558..255cf74 100644
--- a/dashboardv2/public/js/views/search/SearchLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchLayoutView.js
@@ -161,7 +161,7 @@ define(['require',
                         },
                         applyValue: function(model, searchType) {
                             that.manualRender(_.extend(searchType, CommonViewFunction.generateUrlFromSaveSearchObject({
-                                value: model.get('searchParameters'),
+                                value: { "searchParameters": model.get('searchParameters'), 'uiParameters': model.get('uiParameters') },
                                 classificationDefCollection: that.classificationDefCollection,
                                 entityDefCollection: that.entityDefCollection
                             })));

http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/dashboardv2/public/js/views/search/SearchResultLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SearchResultLayoutView.js b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
index 7b909e2..81816f3 100644
--- a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
@@ -211,6 +211,7 @@ define(['require',
                                 this.ui.columnEmptyInfo.hide();
                             }
                         }
+                        this.columnOrder = this.getColumnOrder(this.REntityTableLayoutView.$el.find('.colSort th.renderable'));
                         this.triggerUrl();
                         var attributes = this.searchCollection.filterObj.attributes;
                         if ((excludeDefaultColumn && attributes) && (excludeDefaultColumn.length > attributes.length || _.difference(excludeDefaultColumn, attributes).length)) {
@@ -297,10 +298,16 @@ define(['require',
                     }
                 }
             },
+            getColumnOrderWithPosition: function() {
+                var that = this;
+                return _.map(that.columnOrder, function(value, key) {
+                    return key + "::" + value;
+                }).join(",");
+            },
             triggerUrl: function(options) {
                 Utils.setUrl(_.extend({
                     url: Utils.getUrlState.getQueryUrl().queyParams[0],
-                    urlParams: this.value,
+                    urlParams: this.columnOrder ? _.extend(this.value, { 'uiParameters': this.getColumnOrderWithPosition() }) : this.value,
                     mergeBrowserUrl: false,
                     trigger: false,
                     updateTabState: true
@@ -502,6 +509,11 @@ define(['require',
                 var that = this;
                 require(['utils/TableLayout'], function(TableLayout) {
                     // displayOrder added for column manager
+                    if (that.value.uiParameters) {
+                        var savedColumnOrder = _.object(that.value.uiParameters.split(',').map(function(a) {
+                            return a.split('::');
+                        })); // get Column position from string to object
+                    }
                     var columnCollection = Backgrid.Columns.extend({
                         sortKey: "displayOrder",
                         comparator: function(item) {
@@ -509,24 +521,28 @@ define(['require',
                         },
                         setPositions: function() {
                             _.each(this.models, function(model, index) {
-                                model.set("displayOrder", (that.columnOrder == null ? index : that.columnOrder[model.get('label')]) + 1, { silent: true });
+                                model.set("displayOrder", (savedColumnOrder == null ? index : parseInt(savedColumnOrder[model.get('label')])) + 1, { silent: true });
                             });
                             return this;
                         }
                     });
                     var columns = new columnCollection((that.searchCollection.dynamicTable ? that.getDaynamicColumns(that.searchCollection.toJSON()) : that.getFixedDslColumn()));
                     columns.setPositions().sort();
-                    that.REntityTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
+                    var table = new TableLayout(_.extend({}, that.commonTableOptions, {
                         columns: columns
-                    })));
+                    }));
+                    that.REntityTableLayoutView.show(table);
                     if (that.value.searchType !== "dsl") {
                         that.ui.containerCheckBox.show();
                     } else {
                         that.ui.containerCheckBox.hide();
                     }
                     that.$(".ellipsis .inputAssignTag").hide();
+                    table.trigger("grid:refresh"); /*Event fire when table rendered*/
                     tableDragger(document.querySelector(".colSort")).on('drop', function(from, to, el) {
-                        that.columnOrder = that.getColumnOrder(el.querySelectorAll('th'));
+                        that.columnOrder = that.getColumnOrder(el.querySelectorAll('th.renderable'));
+                        table.trigger("grid:refresh:update");
+                        that.triggerUrl();
                     });
                     that.checkTableFetch();
                 });

http://git-wip-us.apache.org/repos/asf/atlas/blob/9abc89bf/dashboardv2/public/js/views/search/save/SaveSearchView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/save/SaveSearchView.js b/dashboardv2/public/js/views/search/save/SaveSearchView.js
index ec0c81f..5d135ce 100644
--- a/dashboardv2/public/js/views/search/save/SaveSearchView.js
+++ b/dashboardv2/public/js/views/search/save/SaveSearchView.js
@@ -147,7 +147,7 @@ define(['require',
             if (options && options.model) {
                 var searchParameters = options.model.toJSON().searchParameters,
                     params = CommonViewFunction.generateUrlFromSaveSearchObject({
-                        value: searchParameters,
+                        value: {"searchParameters" : searchParameters, "uiParameters": options.model.get('uiParameters')},
                         classificationDefCollection: this.classificationDefCollection,
                         entityDefCollection: this.entityDefCollection
                     });