From 4ba8f4830bcdd8a9085b212a853a2075c288566b Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Wed, 14 Sep 2016 11:13:50 +0100 Subject: [PATCH] Don't sort columns (tables, views, matviews, catalogs etc) on the treeview by name, but by ordinal. Fixes #1687 --- web/pgadmin/browser/templates/browser/js/browser.js | 10 +++++----- web/pgadmin/static/js/pgadmin.js | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js index b91eefd30..6146f5d70 100644 --- a/web/pgadmin/browser/templates/browser/js/browser.js +++ b/web/pgadmin/browser/templates/browser/js/browser.js @@ -35,7 +35,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { var processTreeData = function(payload) { var data = JSON.parse(payload).data.sort(function(a, b) { - return pgAdmin.natural_sort(a.label, b.label, {}); + return pgAdmin.natural_sort(a.label, b.label, {'_type': a._type}); }); _.each(data, function(d){ d._label = d.label; @@ -855,7 +855,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { d = ctx.t.itemData(i); if ( pgAdmin.natural_sort( - d._label, _data._label, {} + d._label, _data._label, {'_type': d._type} ) == 1 ) return true; @@ -880,7 +880,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { d = ctx.t.itemData(i); if ( pgAdmin.natural_sort( - d._label, _data._label, {} + d._label, _data._label, {'_type': d._type} ) != -1 ) return true; @@ -888,7 +888,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { d = ctx.t.itemData(i); if ( pgAdmin.natural_sort( - d._label, _data._label, {} + d._label, _data._label, {'_type': d._type} ) != 1 ) return true; @@ -897,7 +897,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { d = ctx.t.itemData(i); if ( pgAdmin.natural_sort( - d._label, _data._label, {} + d._label, _data._label, {'_type': d._type} ) == 1 ) { s = m + 1; diff --git a/web/pgadmin/static/js/pgadmin.js b/web/pgadmin/static/js/pgadmin.js index 7ab1e3fc8..89da45d6c 100644 --- a/web/pgadmin/static/js/pgadmin.js +++ b/web/pgadmin/static/js/pgadmin.js @@ -40,6 +40,11 @@ oFxNcL, oFyNcL, mult = options.desc ? -1 : 1; + // If object is of column type then do not sort + if (options.hasOwnProperty("_type") && options._type && + (options._type != 'column' || options._type != 'catalog_object_column')) + return 0; + // first try and sort Hex codes or Dates if (yD) if ( xD < yD ) return -1 * mult;