Skip to content

Commit

Permalink
Merge pull request #2491 from fecgov/feature/sort-nulls-last
Browse files Browse the repository at this point in the history
Sort nulls last in data tables
  • Loading branch information
johnnyporkchops authored Nov 8, 2018
2 parents 143ec0d + 3b5d79a commit 4b19c75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fec/fec/static/js/modules/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,10 @@ DataTable.prototype.isPending = function() {
};

DataTable.prototype.buildUrl = function(data, paginate) {
var query = _.extend({ sort_hide_null: false }, this.filters || {});
var query = _.extend(
{ sort_hide_null: false, sort_nulls_last: true },
this.filters || {}
);
paginate = typeof paginate === 'undefined' ? true : paginate;
query.sort = mapSort(data.order, this.opts.columns);

Expand Down
3 changes: 2 additions & 1 deletion fec/fec/tests/js/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ describe('data table', function() {
var url = this.table.buildUrl(data);
var expected = helpers.buildUrl(
['path', 'to', 'endpoint'],
{sort_hide_null: 'false', party: 'DFL', sort: '-office', per_page: 30, page: 3, extra: 'true'}
{sort_hide_null: 'false', sort_nulls_last: 'true', party: 'DFL',
sort: '-office', per_page: 30, page: 3, extra: 'true'}
);
expect(URI(url).equals(expected)).to.be.true;
});
Expand Down

0 comments on commit 4b19c75

Please sign in to comment.