stump icon indicating copy to clipboard operation
stump copied to clipboard

Grid / list ordering

Open aaronleopold opened this issue 2 years ago • 0 comments

Users should be able to specify what fields to order items inside Stump grids/lists. For example, when viewing the media of a series, the Order By button in the TopBar should contain the allowed media entity fields as options for selection. When an option is selected, the media would be sorted by that field.

Additionally, the OrderDirectionToggle button should update the direction for this ordering.

The API does currently accept the required query params for a minimally viable solution, however it is not overly type safe. I’d like to look into reworking the current implementation while working on this task to make it safer between Rust and TypeScript. Maybe something like:

// Note: I am separating these options / exclusions in case I want to use either independently.
export type MediaOrderByExclusions = Extract<
	keyof Media,
	'currentPage' | 'series' | 'readProgresses' | 'tags'
>;
export type MediaOrderBy = keyof Omit<Media, MediaOrderByExclusions>;

export type SeriesOrderByExclusions = Extract<
	keyof Series,
	'library' | 'media' | 'mediaCount' | 'tags'
>;
export type SeriesOrderBy = keyof Omit<Series, SeriesOrderByExclusions>;

export type LibraryOrderByExclusions = Extract<keyof Library, 'series' | 'tags' | 'libraryOptions'>;
export type LibraryOrderBy = keyof Omit<Library, LibraryOrderByExclusions>;

Interface tasks:

Note: There are only a few queries where this is currently applicable. This will likely change as Stump grows, but this issue is more so about creating the infrastructure to make is easier to use throughout in the future.

  • [x] Use the useQueryParamStore to store query configuration, it can then output the resulting url search params for relevant API calls
  • [x] Adjust current API calls to accept optional query params (which come from the store)
    • [x] getLibrarySeries
    • [x] getSeriesMedia
  • [x] Use the useQueryParamStore in relevant common/client react-query hooks
    • [x] useLibrarySeries
    • [x] useSeriesMedia
  • [ ] Options should be based on current viewable entity (e.g. media fields, series fields, etc)

Core tasks:

  • [ ] Update API routes to match the page request interpretation from library/<id>/series

aaronleopold avatar Sep 16 '22 22:09 aaronleopold