list_render: Fix filtering/sorting.

This code has always been kind of convoluted
and buggy, starting with the first
sorting-related commit, which put filtering
before sorting for some reason:

    3706e2c6ba

This should fix bugs like the fact that
changing filter text would not respect
reversed sorts.

Now the scheme is simple:

    - external UI actions set `meta` values like
      filter_value, reverse_mode, and
      sorting_function, as needed, through
      simple setters

    - use `hard_redraw` to do a redraw and
      trigger external actions

    - all filtering/sorting/reverse logic on
      the *data* happens in a single, simple
      function called `filter_and_sort`
This commit is contained in:
Steve Howell
2020-04-13 14:13:06 +00:00
committed by Tim Abbott
parent ec854f4b12
commit eb1344c41c
2 changed files with 61 additions and 73 deletions

View File

@@ -236,7 +236,13 @@ function sort_button(opts) {
closest: lookup('.progressive-table-wrapper', {
data: lookup('list-render', opts.list_name),
}),
hasClass: lookup('active', opts.active),
hasClass: (sel) => {
if (sel === 'active') {
return opts.active;
}
assert.equal(sel, 'descend');
return false;
},
siblings: lookup('.active', {
removeClass: (sel) => {
assert.equal(sel, 'active');