Add sort by date added to Series list page#3630
Open
iBeech wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a library with a few hundred series, the alphabetical-only Series page makes it hard to spot what's been added recently. My wife (an avid user who gets through new series faster than the default landing page surfaces them) asked whether there was a way to see the most recently added series first, so this PR adds that option.
A third sort button (calendar + sort-by-order icons) on /series sorts series descending by the latest book timestamp in each series, with Series.sort as a tiebreaker for determinism. The preference persists via the existing set_view_property mechanism like the asc/desc buttons.
While implementing this I hit a latent bug in filter_grid.js: the #asc and #desc handlers use
sortBy: "name"with no corresponding key ingetSortData, so isotope silently fell back to "original DOM order" for the sort. This worked by accident because the server renders the DOM in the correct order at init, and the asc/desc handlers toggled between original and reversed. But once the new button re-sorts the DOM client-side by timestamp, subsequent asc/desc clicks toggled between timestamp order and its reverse instead of A-Z / Z-A. The fix is small: addname: "[data-name]"to getSortData, and replace the!sortAscendingtoggle with explicit true/false. Asc/desc behaviour on non-series pages that share this JS (authors, categories, ratings, etc.) is observably unchanged. They were already producing correct results via the fallback, and the explicit values produce the same output.Default behaviour is unchanged. The new button follows the same ajax pattern as the existing sort buttons, and other list routes are untouched.
calibre-web has been central to how we share books as a family, and we're glad to contribute back.
Suggested addition to test/test_list_orders.py::test_series_sort if you'd like coverage: