stash icon indicating copy to clipboard operation
stash copied to clipboard

Add click-to-sort column headers to all entity list table views

Open slick-daddy opened this issue 6 months ago • 3 comments

This PR shouldn't be merged before #6933 gets merged.

The only thing I didn't like about this PR is reverse mapping approach. Maybe we should edit onClick instead. I am open to feedbacks.

Summary

Makes column headers clickable in list table views for Scenes, Galleries, Performers, Studios, and Tags. The sort infrastructure is generic so all entity tables benefit without per-entity duplication.

Changes

Generic sort support (ListTable.tsx)

  • Added optional sortable flag to IColumn — columns without a backend sort field (image, composite, etc.) are marked sortable: false.
  • Added onSort, sortBy, sortDirection props. Active sort column renders ▲ (ASC) or ▼ (DEC) indicator.
  • Clicking a header fires onSort(column.value) — new column starts ASC, same column toggles direction.

Per-entity wiring (*List.tsx + *ListTable.tsx)

Each entity follows the same pattern:

  1. *ListTable.tsx — accepts onSort/sortBy/sortDirection props and threads them through to ListTable. Non-sortable columns marked sortable: false.
  2. *List.tsx — Filtered*List defines a module-level columnSortMap translating column values to backend sort fields. onSort useCallback maps the column value via this map before calling filter.setSortBy(). The inner *List component derives activeSortColumn by reverse-mapping filter.sortBy back to the column value so ListTable matches correctly for arrow display.

Column mappings (value → backend field)

Entity Mappings
Studios scene_count→scenes_count, image_count→images_count, gallery_count→galleries_count
Scenes scene_code→code
Galleries images→images_count
Performers height_cm→height, penis_length_cm→penis_length, scene_count→scenes_count, gallery_count→galleries_count, image_count→images_count, age→birthdate
Tags scene_count→scenes_count, gallery_count→galleries_count, image_count→images_count, group_count→groups_count, performer_count→performers_count, studio_count→studios_count

Bug fixes

  • Active sort arrow not showing: filter.sortBy contained the backend field name (e.g. "scenes_count") but ListTable compared against column.value (e.g. "scene_count"). Fixed by reverse-mapping to column value before passing to the table.
  • TypeScript index error: filter.sortBy could be undefined, which can't be used as an object index. Fixed with ?? "" fallback.

Studio child count label

  • StudioListTable RelatedCell now shows "N Studios" (pluralized via intl.formatMessage) instead of a bare number.

Files changed (11 files)

File Changes
ui/.../List/ListTable.tsx Generic sort header support
ui/.../Studios/StudioList.tsx Sort plumbing + column map
ui/.../Studios/StudioListTable.tsx Sort props + non-sortable columns + "N Studios" label
ui/.../Scenes/SceneList.tsx Sort plumbing + column map
ui/.../Scenes/SceneListTable.tsx Sort props + non-sortable columns
ui/.../Galleries/GalleryList.tsx Sort plumbing + column map
ui/.../Galleries/GalleryListTable.tsx Sort props + non-sortable columns
ui/.../Performers/PerformerList.tsx Sort plumbing + column map
ui/.../Performers/PerformerListTable.tsx Sort props + non-sortable columns
ui/.../Tags/TagList.tsx Sort plumbing + column map
ui/.../Tags/TagListTable.tsx Sort props + non-sortable columns

slick-daddy avatar May 16 '26 02:05 slick-daddy

There's a bunch of unrelated changes to the server code.

WithoutPants avatar Jun 24 '26 05:06 WithoutPants

There's a bunch of unrelated changes to the server code.

  • Dropped unrelated 3 UI fix commits. My initial thought was it would be nice apply them on the way as well but I agree that they are out of scope, so let's drop them.

  • Commit 4193f2a has also been dropped since it came from syncing fork by mistake.

  • Rebased with cherry-picking and ready for review.

slick-daddy avatar Jun 25 '26 12:06 slick-daddy

There's still changes to server files in this PR - specifically the sqlite package.

WithoutPants avatar Jun 26 '26 00:06 WithoutPants