Skip to content

Commit

Permalink
fix: Pre-sort WG doc table on date (#5361)
Browse files Browse the repository at this point in the history
Fixes #5341.

Also remove some js code that was only used on the old agenda
page while I'm here.
  • Loading branch information
larseggert committed Mar 17, 2023
1 parent 28b7134 commit 57030e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
42 changes: 10 additions & 32 deletions ietf/static/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,43 +266,21 @@ $(document)
});
}
});

e.on("searchComplete", function () {
var last_show_with_children = {};
e.items.forEach((item) => {
if ($(item.elm)
.hasClass("show-with-children")) {
var kind = $(item.elm)
.attr("class")
.split(/\s+/)
.join();
last_show_with_children[kind] = item;
}

if (item.found) {
Object.entries(last_show_with_children)
.forEach(([key, val]) => {
val.found = true;
val.show();
delete last_show_with_children[key];
});
}

if ($(item.elm)
.hasClass("show-always")) {
item.found = true;
item.show();
}
});

e.update();
replace_with_internal(table, internal_table, i);
});
});

$(table.addClass("tablesorter-done"));
n++;
$(table)[0]
.dispatchEvent(new Event("tablesorter:done"));

// if there is a data-default-sort attribute on a column, pre-sort the table on that
const presort_col = $(header_row).children("[data-default-sort]:first");
if (presort_col) {
const order = presort_col.attr("data-default-sort");
$.each(list_instance, (i, e) => {
e.sort(presort_col.attr("data-sort"), { order: order, sortFunction: text_sort });
});
}
});

// if the URL contains a #, scroll to it again, since we modified the DOM
Expand Down
2 changes: 2 additions & 0 deletions ietf/templates/doc/search/search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<th scope="col" data-sort="{{ h.key }}"
{% if h.title|slugify == "ipr" or h.title|slugify == "ad-shepherd" %}
class="d-none d-sm-table-cell"
{% elif h.title|slugify == 'date' %}
data-default-sort="desc"
{% endif %}>
{% if "sort_url" in h %}
<a href="{{ h.sort_url }}">
Expand Down

0 comments on commit 57030e4

Please sign in to comment.