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 2020/12/16 08:43:21 UTC

[atlas] 01/02: Atlas-4073: UI Column sorting not working in BusinessMetadata details page Fix

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 b1cc951d9c2dfeb971e342006fcf6680b982a8fb
Author: prasad pawar <pr...@freestoneinfotech.com>
AuthorDate: Tue Dec 15 13:04:55 2020 +0530

    Atlas-4073: UI Column sorting not working in BusinessMetadata details page Fix
---
 dashboardv2/public/js/utils/TableLayout.js         | 43 ++++++++++++++-------
 .../js/views/audit/AdminAuditTableLayoutView.js    |  1 +
 .../BusinessMetadataAttrTableLayoutView.js         |  3 +-
 dashboardv3/public/js/utils/TableLayout.js         | 44 +++++++++++++++-------
 .../js/views/audit/AdminAuditTableLayoutView.js    |  1 +
 .../BusinessMetadataAttrTableLayoutView.js         |  3 +-
 6 files changed, 67 insertions(+), 28 deletions(-)

diff --git a/dashboardv2/public/js/utils/TableLayout.js b/dashboardv2/public/js/utils/TableLayout.js
index 89216bd..377abca 100644
--- a/dashboardv2/public/js/utils/TableLayout.js
+++ b/dashboardv2/public/js/utils/TableLayout.js
@@ -209,19 +209,36 @@ define(['require',
                         val.fullCollection.sort();
                         this.comparator = function(next, previous, data) {
                             var getValue = function(options) {
-                                var next = options.next,
-                                    previous = options.previous,
-                                    order = options.order;
-                                if (next === previous) {
-                                    return null;
-                                } else {
-                                    if (order === -1) {
-                                        return next < previous ? -1 : 1;
+                                    var next = options.next,
+                                        previous = options.previous,
+                                        order = options.order;
+                                    if (next === previous) {
+                                        return null;
                                     } else {
-                                        return next < previous ? 1 : -1;
+                                        if (order === -1) {
+                                            return next < previous ? -1 : 1;
+                                        } else {
+                                            return next < previous ? 1 : -1;
+                                        }
                                     }
-                                }
-                            }
+                                },
+                                getKeyVal = function(model, key) {
+                                    //for nested obj
+                                    var value = null;
+                                    if (model && key) {
+                                        value = model[key];
+                                        if (!value) {
+                                            _.each(model, function(modalValue) {
+                                                if (typeof(modalValue) == "object") {
+                                                    if (!value) {
+                                                        value = getKeyVal(modalValue, key);
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    }
+                                    return Number(value) || value;
+                                };
                             if (val.state && (!_.isNull(val.state.sortKey))) {
                                 var nextValue,
                                     previousValue;
@@ -229,8 +246,8 @@ define(['require',
                                     nextValue = next.get("attributes")[val.state.sortKey];
                                     previousValue = previous.get("attributes")[val.state.sortKey];
                                 } else {
-                                    nextValue = next.attributes[val.state.sortKey];
-                                    previousValue = previous.attributes[val.state.sortKey];
+                                    nextValue = getKeyVal(next.attributes, val.state.sortKey);
+                                    previousValue = getKeyVal(previous.attributes, val.state.sortKey);
                                 }
                                 nextValue = (typeof nextValue === 'string') ? nextValue.toLowerCase() : nextValue;
                                 previousValue = (typeof previousValue === 'string') ? previousValue.toLowerCase() : previousValue;
diff --git a/dashboardv2/public/js/views/audit/AdminAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/AdminAuditTableLayoutView.js
index e8babde..dcfd82a 100644
--- a/dashboardv2/public/js/views/audit/AdminAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/AdminAuditTableLayoutView.js
@@ -315,6 +315,7 @@ define(['require',
                         cell: "html",
                         renderable: false,
                         editable: false,
+                        sortable: false,
                         formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
                             fromRaw: function(rawValue, model) {
                                 var startTime = model.get('startTime') ? parseInt(model.get('startTime')) : null,
diff --git a/dashboardv2/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js b/dashboardv2/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
index 12cc710..37058bb 100644
--- a/dashboardv2/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
+++ b/dashboardv2/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
@@ -186,6 +186,7 @@ define(['require',
                         label: "Enable Multivalues",
                         cell: "html",
                         editable: false,
+                        sortable: false,
                         formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
                             fromRaw: function(rawValue, model) {
                                 var enableMultipleValue = '';
@@ -210,7 +211,7 @@ define(['require',
                             }
                         })
                     },
-                    options: {
+                    applicableEntityTypes: {
                         label: "Entity Type(s)",
                         cell: "html",
                         editable: false,
diff --git a/dashboardv3/public/js/utils/TableLayout.js b/dashboardv3/public/js/utils/TableLayout.js
index 89216bd..487851e 100644
--- a/dashboardv3/public/js/utils/TableLayout.js
+++ b/dashboardv3/public/js/utils/TableLayout.js
@@ -209,19 +209,36 @@ define(['require',
                         val.fullCollection.sort();
                         this.comparator = function(next, previous, data) {
                             var getValue = function(options) {
-                                var next = options.next,
-                                    previous = options.previous,
-                                    order = options.order;
-                                if (next === previous) {
-                                    return null;
-                                } else {
-                                    if (order === -1) {
-                                        return next < previous ? -1 : 1;
+                                    var next = options.next,
+                                        previous = options.previous,
+                                        order = options.order;
+                                    if (next === previous) {
+                                        return null;
                                     } else {
-                                        return next < previous ? 1 : -1;
+                                        if (order === -1) {
+                                            return next < previous ? -1 : 1;
+                                        } else {
+                                            return next < previous ? 1 : -1;
+                                        }
                                     }
-                                }
-                            }
+                                },
+                                getKeyVal = function(model, key) {
+                                    //for nested obj
+                                    var value = null;
+                                    if (model && key) {
+                                        value = model[key];
+                                        if (!value) {
+                                            _.each(model, function(modalValue) {
+                                                if (typeof(modalValue) == "object") {
+                                                    if (!value) {
+                                                        value = getKeyVal(modalValue, key);
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    }
+                                    return Number(value) || value;
+                                };
                             if (val.state && (!_.isNull(val.state.sortKey))) {
                                 var nextValue,
                                     previousValue;
@@ -229,8 +246,8 @@ define(['require',
                                     nextValue = next.get("attributes")[val.state.sortKey];
                                     previousValue = previous.get("attributes")[val.state.sortKey];
                                 } else {
-                                    nextValue = next.attributes[val.state.sortKey];
-                                    previousValue = previous.attributes[val.state.sortKey];
+                                    nextValue = getKeyVal(next.attributes, val.state.sortKey);
+                                    previousValue = getKeyVal(previous.attributes, val.state.sortKey);
                                 }
                                 nextValue = (typeof nextValue === 'string') ? nextValue.toLowerCase() : nextValue;
                                 previousValue = (typeof previousValue === 'string') ? previousValue.toLowerCase() : previousValue;
@@ -246,6 +263,7 @@ define(['require',
                 }
                 this.bindEvents();
             },
+
             /** all events binding here */
             bindEvents: function() {
                 this.listenTo(this.collection, 'request', function() {
diff --git a/dashboardv3/public/js/views/audit/AdminAuditTableLayoutView.js b/dashboardv3/public/js/views/audit/AdminAuditTableLayoutView.js
index e8babde..dcfd82a 100644
--- a/dashboardv3/public/js/views/audit/AdminAuditTableLayoutView.js
+++ b/dashboardv3/public/js/views/audit/AdminAuditTableLayoutView.js
@@ -315,6 +315,7 @@ define(['require',
                         cell: "html",
                         renderable: false,
                         editable: false,
+                        sortable: false,
                         formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
                             fromRaw: function(rawValue, model) {
                                 var startTime = model.get('startTime') ? parseInt(model.get('startTime')) : null,
diff --git a/dashboardv3/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js b/dashboardv3/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
index ff2c02c..dd1e470 100644
--- a/dashboardv3/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
+++ b/dashboardv3/public/js/views/business_metadata/BusinessMetadataAttrTableLayoutView.js
@@ -186,6 +186,7 @@ define(['require',
                         label: "Enable Multivalues",
                         cell: "html",
                         editable: false,
+                        sortable: false,
                         formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
                             fromRaw: function(rawValue, model) {
                                 var enableMultipleValue = '';
@@ -210,7 +211,7 @@ define(['require',
                             }
                         })
                     },
-                    options: {
+                    applicableEntityTypes: {
                         label: "Entity Type(s)",
                         cell: "html",
                         editable: false,