Add click-to-sort column headers to all entity list table views
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
sortableflag toIColumn— columns without a backend sort field (image, composite, etc.) are markedsortable: false. - Added
onSort,sortBy,sortDirectionprops. 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:
*ListTable.tsx— acceptsonSort/sortBy/sortDirectionprops and threads them through toListTable. Non-sortable columns markedsortable: false.*List.tsx—Filtered*Listdefines a module-levelcolumnSortMaptranslating column values to backend sort fields.onSortuseCallback maps the column value via this map before callingfilter.setSortBy(). The inner*Listcomponent derivesactiveSortColumnby reverse-mappingfilter.sortByback to the column value soListTablematches 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.sortBycontained the backend field name (e.g."scenes_count") butListTablecompared againstcolumn.value(e.g."scene_count"). Fixed by reverse-mapping to column value before passing to the table. - TypeScript index error:
filter.sortBycould beundefined, which can't be used as an object index. Fixed with?? ""fallback.
Studio child count label
StudioListTableRelatedCellnow shows "N Studios" (pluralized viaintl.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 |
There's a bunch of unrelated changes to the server code.
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.
There's still changes to server files in this PR - specifically the sqlite package.