Merge lp:~wallyworld/launchpad/sortable-dates-fix-918892 into lp:launchpad

Proposed by Ian Booth on 2012-01-20
Status: Merged
Approved by: William Grant on 2012-01-20
Approved revision: no longer in the source branch.
Merged at revision: 14705
Proposed branch: lp:~wallyworld/launchpad/sortable-dates-fix-918892
Merge into: lp:launchpad
Diff against target: 30 lines (+7/-7)
1 file modified
lib/lp/app/javascript/sorttable/sorttable.js (+7/-7)
To merge this branch: bzr merge lp:~wallyworld/launchpad/sortable-dates-fix-918892
Reviewer Review Type Date Requested Status
William Grant code 2012-01-20 Approve on 2012-01-20
Review via email: mp+89380@code.launchpad.net

Commit Message

Fix sorttable.js so that the correct column values are used for the guessType() method.

Description of the Change

== Implementation ==

The third party sorttable.js needed to be patched to support tables with colspans. The patch wasn't quite done correctly. The adjustment to the column index needed to be moved up a bit so that the guessType() method, which determines whether a
column is a string, int or date, operates on the correct column.

== Tests ==

Manually test the code index page eg code.launchpad.dev/firefox
Ensure branches are correctly sorted by Last Modified Date

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/sorttable/sorttable.js'
2--- lib/lp/app/javascript/sorttable/sorttable.js 2012-01-18 06:24:25 +0000
3+++ lib/lp/app/javascript/sorttable/sorttable.js 2012-01-20 05:20:30 +0000
4@@ -89,12 +89,6 @@
5 if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
6 mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
7 if (mtch) { override = mtch[1]; }
8- if (mtch && typeof sorttable["sort_"+override] == 'function') {
9- headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
10- } else {
11- headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
12- }
13- // Make it clickable to sort.
14 // If some previous column contains a colspan, we need to
15 // increase the column index to compensate for it.
16 var colspan_offset = 0;
17@@ -110,7 +104,13 @@
18 }
19 }
20 headrow[i].sorttable_columnindex = i + colspan_offset;
21-
22+ if (mtch && typeof sorttable["sort_"+override] == 'function') {
23+ headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
24+ } else {
25+ headrow[i].sorttable_sortfunction = sorttable.guessType(
26+ table, i + colspan_offset);
27+ }
28+ // Make it clickable to sort.
29 headrow[i].sorttable_tbody = table.tBodies[0];
30 dean_addEvent(headrow[i],"click", function(e) {
31