Winter CMS Build
1.1
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
There is an issue where sorting from the backend reorder list view does not work when records all contain the same/duplicate sort order value since the winter.reorder.js file does not recalculate the sort order value and re-uses the existing sort order values from the DB and just switches what record that value is applied to. This is a problem if you add sorting functionality to an existing table with records already created and then the migration assigns a default sort order value of 0 to every record and when you create a new record, it will contain the sort order of 0 which will also cause sorting for that record to stop working if it conflicts with another.


Steps to replicate
- Create records in a table without sorting functionality.
- Add new
sort_order column to table and have the migration assign default sort_order value of 0 to every record.
- Implement Reorder Controller functionality
- Try to re-order list of records from backend, but notice the new order of the records is not reflected in the DB / after reloading the page.
Workaround
- During migration, loop through every record and adjust the
sort_order to be the same as the primary key.
- When creating new records, override default
sort_order so it matches the primary key as well so we don't run into duplicates.
Winter CMS Build
1.1
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
There is an issue where sorting from the backend reorder list view does not work when records all contain the same/duplicate sort order value since the
winter.reorder.jsfile does not recalculate the sort order value and re-uses the existing sort order values from the DB and just switches what record that value is applied to. This is a problem if you add sorting functionality to an existing table with records already created and then the migration assigns a default sort order value of 0 to every record and when you create a new record, it will contain the sort order of 0 which will also cause sorting for that record to stop working if it conflicts with another.Steps to replicate
sort_ordercolumn to table and have the migration assign defaultsort_ordervalue of 0 to every record.Workaround
sort_orderto be the same as the primary key.sort_orderso it matches the primary key as well so we don't run into duplicates.