Drag to sort, as an opt-in list view
2026年7月29日
The Phlo CMS gained a sortable list view. One declaration on the model and the rows are draggable:
static listView = 'sort'
Sorting looks like a small feature and turns out to be an interesting one, because the obvious implementation assumes something that is rarely true: that the rows on screen are all the rows. Renumbering from one across the ids the browser sent is correct for a short flat list and for nothing else. Add a filter, a search, a second page or grouping and the browser is holding a subset, while the numbers belong to the whole set.
So the reorder works within the group the records belong to, closes gaps rather than assuming positions are contiguous, and treats an empty group as a real value rather than as no group. A record dragged into another group lands at the end, because the position it held in its old group means nothing in its new one.
Two things came with it that are easy to skip. Every renumbered record is checked against the same permission rules a single edit would be, because a reorder writes to all of them. And the reorder moved out of the route into a method of its own, so it can be tested without a request; the route is now the request part only, which is token, known model, call, report.
Phlo CMS 1.0.1. See the CMS handbook.