Fossil SCM

Fix column sorting on ticket reports.

drh 2016-02-11 14:41 trunk
Commit 0e555dee63dab159b8fd5894fa1d0e208decb8a7
1 file changed +12 -14
+12 -14
--- src/report.c
+++ src/report.c
@@ -955,11 +955,11 @@
955955
** k Sort by the data-sortkey property
956956
** x This column is not sortable
957957
**
958958
** Capital letters mean sort in reverse order.
959959
** If there are fewer characters in zColumnTypes[] than their are columns,
960
-** the all extra columns assume type "t" (text).
960
+** then all extra columns assume type "t" (text).
961961
**
962962
** The third parameter is the column that was initially sorted (using 1-based
963963
** column numbers, like SQL). Make this value 0 if none of the columns are
964964
** initially sorted. Make the value negative if the column is initially sorted
965965
** in reverse order.
@@ -973,10 +973,12 @@
973973
){
974974
@ <script>
975975
@ function SortableTable(tableEl,columnTypes,initSort){
976976
@ this.tbody = tableEl.getElementsByTagName('tbody');
977977
@ this.columnTypes = columnTypes;
978
+ @ var ncols = tableEl.rows[0].cells.length;
979
+ @ for(var i = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
978980
@ this.sort = function (cell) {
979981
@ var column = cell.cellIndex;
980982
@ var sortFn;
981983
@ switch( cell.sortType ){
982984
if( strchr(zColumnTypes,'n') ){
@@ -983,13 +985,11 @@
983985
@ case "n": sortFn = this.sortNumeric; break;
984986
}
985987
if( strchr(zColumnTypes,'N') ){
986988
@ case "N": sortFn = this.sortReverseNumeric; break;
987989
}
988
- if( strchr(zColumnTypes,'t') ){
989
- @ case "t": sortFn = this.sortText; break;
990
- }
990
+ @ case "t": sortFn = this.sortText; break;
991991
if( strchr(zColumnTypes,'T') ){
992992
@ case "T": sortFn = this.sortReverseText; break;
993993
}
994994
if( strchr(zColumnTypes,'k') ){
995995
@ case "k": sortFn = this.sortKey; break;
@@ -1031,20 +1031,18 @@
10311031
@ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
10321032
@ clsName += ' sort ' + sortType;
10331033
@ hdrCell.className = clsName;
10341034
@ }
10351035
@ }
1036
- if( strchr(zColumnTypes,'t') ){
1037
- @ this.sortText = function(a,b) {
1038
- @ var i = thisObject.sortIndex;
1039
- @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1040
- @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1041
- @ if(aa<bb) return -1;
1042
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1043
- @ return 1;
1044
- @ }
1045
- }
1036
+ @ this.sortText = function(a,b) {
1037
+ @ var i = thisObject.sortIndex;
1038
+ @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1039
+ @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1040
+ @ if(aa<bb) return -1;
1041
+ @ if(aa==bb) return a.rowIndex-b.rowIndex;
1042
+ @ return 1;
1043
+ @ }
10461044
if( strchr(zColumnTypes,'T') ){
10471045
@ this.sortReverseText = function(a,b) {
10481046
@ var i = thisObject.sortIndex;
10491047
@ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
10501048
@ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
10511049
--- src/report.c
+++ src/report.c
@@ -955,11 +955,11 @@
955 ** k Sort by the data-sortkey property
956 ** x This column is not sortable
957 **
958 ** Capital letters mean sort in reverse order.
959 ** If there are fewer characters in zColumnTypes[] than their are columns,
960 ** the all extra columns assume type "t" (text).
961 **
962 ** The third parameter is the column that was initially sorted (using 1-based
963 ** column numbers, like SQL). Make this value 0 if none of the columns are
964 ** initially sorted. Make the value negative if the column is initially sorted
965 ** in reverse order.
@@ -973,10 +973,12 @@
973 ){
974 @ <script>
975 @ function SortableTable(tableEl,columnTypes,initSort){
976 @ this.tbody = tableEl.getElementsByTagName('tbody');
977 @ this.columnTypes = columnTypes;
 
 
978 @ this.sort = function (cell) {
979 @ var column = cell.cellIndex;
980 @ var sortFn;
981 @ switch( cell.sortType ){
982 if( strchr(zColumnTypes,'n') ){
@@ -983,13 +985,11 @@
983 @ case "n": sortFn = this.sortNumeric; break;
984 }
985 if( strchr(zColumnTypes,'N') ){
986 @ case "N": sortFn = this.sortReverseNumeric; break;
987 }
988 if( strchr(zColumnTypes,'t') ){
989 @ case "t": sortFn = this.sortText; break;
990 }
991 if( strchr(zColumnTypes,'T') ){
992 @ case "T": sortFn = this.sortReverseText; break;
993 }
994 if( strchr(zColumnTypes,'k') ){
995 @ case "k": sortFn = this.sortKey; break;
@@ -1031,20 +1031,18 @@
1031 @ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
1032 @ clsName += ' sort ' + sortType;
1033 @ hdrCell.className = clsName;
1034 @ }
1035 @ }
1036 if( strchr(zColumnTypes,'t') ){
1037 @ this.sortText = function(a,b) {
1038 @ var i = thisObject.sortIndex;
1039 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1040 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1041 @ if(aa<bb) return -1;
1042 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1043 @ return 1;
1044 @ }
1045 }
1046 if( strchr(zColumnTypes,'T') ){
1047 @ this.sortReverseText = function(a,b) {
1048 @ var i = thisObject.sortIndex;
1049 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1050 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1051
--- src/report.c
+++ src/report.c
@@ -955,11 +955,11 @@
955 ** k Sort by the data-sortkey property
956 ** x This column is not sortable
957 **
958 ** Capital letters mean sort in reverse order.
959 ** If there are fewer characters in zColumnTypes[] than their are columns,
960 ** then all extra columns assume type "t" (text).
961 **
962 ** The third parameter is the column that was initially sorted (using 1-based
963 ** column numbers, like SQL). Make this value 0 if none of the columns are
964 ** initially sorted. Make the value negative if the column is initially sorted
965 ** in reverse order.
@@ -973,10 +973,12 @@
973 ){
974 @ <script>
975 @ function SortableTable(tableEl,columnTypes,initSort){
976 @ this.tbody = tableEl.getElementsByTagName('tbody');
977 @ this.columnTypes = columnTypes;
978 @ var ncols = tableEl.rows[0].cells.length;
979 @ for(var i = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
980 @ this.sort = function (cell) {
981 @ var column = cell.cellIndex;
982 @ var sortFn;
983 @ switch( cell.sortType ){
984 if( strchr(zColumnTypes,'n') ){
@@ -983,13 +985,11 @@
985 @ case "n": sortFn = this.sortNumeric; break;
986 }
987 if( strchr(zColumnTypes,'N') ){
988 @ case "N": sortFn = this.sortReverseNumeric; break;
989 }
990 @ case "t": sortFn = this.sortText; break;
 
 
991 if( strchr(zColumnTypes,'T') ){
992 @ case "T": sortFn = this.sortReverseText; break;
993 }
994 if( strchr(zColumnTypes,'k') ){
995 @ case "k": sortFn = this.sortKey; break;
@@ -1031,20 +1031,18 @@
1031 @ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
1032 @ clsName += ' sort ' + sortType;
1033 @ hdrCell.className = clsName;
1034 @ }
1035 @ }
1036 @ this.sortText = function(a,b) {
1037 @ var i = thisObject.sortIndex;
1038 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1039 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1040 @ if(aa<bb) return -1;
1041 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1042 @ return 1;
1043 @ }
 
 
1044 if( strchr(zColumnTypes,'T') ){
1045 @ this.sortReverseText = function(a,b) {
1046 @ var i = thisObject.sortIndex;
1047 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1048 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1049

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button