Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pre-sort WG doc table on date #5361

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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