feat(client): enable sorting the chore admin tables - #183
Conversation
|
This PR looks solid and I'd have no problem with merging it in. However, could you take a quick pass and see if its yucky to instead make all chores and chore schedules' table headers clickable to sort by that column? e.g. can click on Clams once to sort by clam value asc. And a 2nd time to sort by clam value dsc. Or click on Assigned To, Next Occurrence, etc. If we can do that without being a massive amount of bloat, I'd love to go that route, possibly with the default sorting to be client side by title/ID as you proposed here. |
|
Clickable headers sounds even better. We can default to sort by title ASC. |
`GET /api/chores` and `GET /api/chore-schedules` declare no `ORDER BY`, so rows arrived in insertion order, which stops being scannable at around thirty chores. Both tables now open sorted by title ascending and re-sort on a header click. A column is sortable only where its order answers a question: Title, Clams and Schedules on definitions, Chore, Assigned To, Next Occurrence and Clams on the schedule. Description is free text and usually blank, Duration is four modes rather than a length, and Visible is a live Switch, so sorting by it would slide the row out from under the click that toggled it. Next Occurrence sorts on the parsed date, not the rendered label, which would order "Apr" before "Jan"; `getNextOccurrence` is split so the label and the key share one parse. Schedules with no occurrence, one-time or unparseable, sort last in both directions rather than crowding out the soonest one. Keys are computed once per row rather than inside the comparator, which would reparse a crontab on every comparison. The chore pickers keep their own alphabetical list, so a dropdown does not reorder because the table above was sorted by clam value. Below the mobile cutoff `stackableTableSx` hides the header row, so phones get the default order and no control.
0aa80bf to
149bd21
Compare
|
Both tables now have clickable headers via MUI I did not make every header sortable, though. Seven of twelve, on the rule that a header which invites a click should answer a question someone actually asks:
Left alone, and happy to add any of them if you disagree:
Three things worth calling out in the diff. Next Occurrence sorts on the parsed date, not the rendered label. The cell renders a localized Rows with no occurrence sort last in both directions. A one-time task, or a crontab that fails to parse, has no next occurrence at all. Reversing the arrow to find the soonest one should not march those to the top, so a null key is always last and only the real dates reverse. The chore pickers needed their own list. The filter
One known limit: below the mobile cutoff, No new translation keys. |
The Chore Definitions and Chore Schedules tables in Settings render rows in whatever order the API returns them. Neither
/api/choresnor/api/chore-schedulesdeclares anORDER BY, andChoreSchedulesTabfilters without sorting, so the order is whatever SQLite's plan yields. In practice that is insertion order, which is hard to scan past a handful of chores, and it is not a guarantee: an added index or anANALYZEcould reorder both tables with no code change.Sorts by title in the client rather than adding
ORDER BYto the endpoints, since the dashboard widget consumes the same two and its ordering is a separate question. The two chore pickers on the tab, the filter and the schedule form's chore select, follow the same order. Widget ordering is unchanged.compareByTitlefolds case and accents so one chore does not sort into a second alphabet, and breaks ties onidso equal titles keep a deterministic order rather than depending on an input order that is itself unspecified.Six unit tests on the comparator.