Fixed an issue where columns names should be visible in the order of their creation in the browser tree. Fixes #5043

This commit is contained in:
Satish V
2020-04-23 16:42:42 +05:30
committed by Akshay Joshi
parent 637c80c38b
commit 2e29f3fd6d
3 changed files with 37 additions and 19 deletions

View File

@@ -1001,12 +1001,13 @@ define('pgadmin.browser', [
while (e >= s) {
i = items.eq(s);
var d = ctx.t.itemData(i);
if (
pgAdmin.natural_sort(
d._label, _data._label
) == 1
)
return true;
if (d._type === 'column') {
if (pgAdmin.numeric_comparator(d._id, _data._id) == 1)
return true;
} else {
if (pgAdmin.natural_sort(d._label, _data._label) == 1)
return true;
}
s++;
}
if (e != items.length - 1) {
@@ -1026,24 +1027,31 @@ define('pgadmin.browser', [
while (e - s > 22) {
i = items.eq(s);
d = ctx.t.itemData(i);
if (
pgAdmin.natural_sort(
d._label, _data._label
) != -1
)
return true;
if (d._type === 'column') {
if (pgAdmin.numeric_comparator(d._id, _data._id) != -1)
return true;
} else {
if (pgAdmin.natural_sort(d._label, _data._label) != -1)
return true;
}
i = items.eq(e);
d = ctx.t.itemData(i);
if (
pgAdmin.natural_sort(
d._label, _data._label
) != 1
)
return true;
if (d._type === 'column') {
if (pgAdmin.numeric_comparator(d._id, _data._id) != -1)
return true;
} else {
if (pgAdmin.natural_sort(d._label, _data._label) != 1)
return true;
}
m = s + Math.round((e - s) / 2);
i = items.eq(m);
d = ctx.t.itemData(i);
res = pgAdmin.natural_sort(d._label, _data._label);
if(d._type === 'column'){
res = pgAdmin.numeric_comparator(d._id, _data._id);
} else {
res = pgAdmin.natural_sort(d._label, _data._label);
}
if (res == 0)
return true;

View File

@@ -115,6 +115,15 @@ define([], function() {
return 0;
};
pgAdmin.numeric_comparator = function(a, b) {
a = parseInt(a);
b = parseInt(b);
if (a < b)
return -1 ;
else
return 1 ;
};
/**
* Decimal adjustment of a number.
*