SST-706 Ordreliste: Genfakt. sorted oldest first and reversed sort sh… - #477
SST-706 Ordreliste: Genfakt. sorted oldest first and reversed sort sh…#477sawaneh1 wants to merge 1 commit into
Conversation
…owed empty dates on top
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Bouncing for missing description before a full review: the PR body is still the unfilled template ("Provide a brief explanation of the changes you have made") — no explanation of what changed or how it was verified. This one especially needs it: it touches includes/grid.php, the shared grid framework used across many pages, not just ordreliste — a sort-order fix there could have a wider blast radius than the title suggests. Could you add:
I'll do the full review once that's in. |
There is description at the top |
ZaynSaul
left a comment
There was a problem hiding this comment.
Re-reviewed with the filled-in description — solid. Matches title (both sort defects: ignored defaultSortDirection on first click, DESC putting NULLs first) and the description accurately scopes the blast radius (grid_order.php → ordreliste.php only; grid.php → ~20 shared list pages, behavior-preserving for columns without a declared default).
Worth calling out explicitly: this also closes a real gap, not just a UX fix. The old apply_sort_sqlOverride() (and grid_order.php's inlined equivalent) put the request-sourced sort[$id] field straight into ORDER BY with zero validation — only the known columns got an sqlOverride swap, but an arbitrary field name would have passed through unchecked. The new code requires either a match against a configured column or a strict ^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$ identifier pattern, falling back to ORDER BY 1 otherwise — and the description explicitly confirms this was tested (sort[…]=foo;drop no longer reaches the query). Direction is normalized to a strict asc/desc allowlist too.
Verification narrative covers both engines across multiple real pages (debitor.php, vareliste, kontoplan, ordrestatus) with asc/desc/sqlOverride/date-null cases. Lints clean on both files, mergeable.
…owed empty dates on top
What are the changes about?
Provide a brief explanation of the changes you have made
Have you checked the following?
https://docs.google.com/document/d/1GOmomtvKf21OV2VWNOIPweDi4gJHpMCK5qXzrPrypUc/edit?usp=sharing
#477 — SST-706 Ordreliste: Genfakt. sorted oldest first, and reversed sort showed empty dates on top
Description
What are the changes about?
Two sorting defects on the "Genfakt." column (
nextfakt) of the debtor order list, and the fix for both lives in the grid engines:defaultSortDirection => 'desc'.includes/grid.php'ssetSort()ignored the column's default direction (thegrid_order.phpfork already passed it). The headeronclicknow passes the default, and the JS in both engines uses the same logic: first click on a column → its default direction, click on the current column → toggle.DESCasNULLS FIRST, so orders without a next-invoice date displaced the newest ones. Descending sorts now appendNULLS LAST(both engines).Because the
ORDER BYfield comes from the request (sort[$id]), the same helper (apply_sort_sqlOverride()ingrid.php, newprepare_grid_order_sort()ingrid_order.php) now also validates it: the field must be a configured column or a plain identifier, the direction is normalised toasc/desc, and anything else falls back toORDER BY 1. ThesqlOverridesubstitution is unchanged.Scope:
grid_order.phpis used only bydebitor/ordreliste.php.includes/grid.phpis shared by ~20 list pages (debitor.php, kreditor.php, vareliste, kontoplan, generalLedger, serialnumber, ordrestatus, …). For those the visible change is: descending sorts show empty values last instead of first, and a column that declaresdefaultSortDirection => 'desc'now opens descending on the first click. Ascending sorts and columns without a default direction behave exactly as before.How I verified: [confirm] Ordreliste (Genfakt. column): first click now newest first, rows with empty Genfakt. at the bottom, second click oldest first — before the fix the first click gave oldest first and the reversed sort started with blank dates. Grids on
includes/grid.phpchecked before/after with the same result: debitor.php, lager/lister/vareliste.php, systemdata/kontoplan.php, lager/lister/ordrestatus.php — asc/desc toggling on numeric, text and date columns, plus a column withsqlOverride. Hand-editedsort[…]=foo;dropin the request now sorts by the first column instead of reaching the query.