Hi .
Found a bug in sorting order of dataobject displayed in the CMS - DOM view. (List View)
Set up:
- Any DataObjectManager with minimal configuration (one text field).
- At least 2 dataobjects items added.
- Enabled - SortableDataObject::add_sortable_class('YourSortedClass'); in _config.php.
- Default ordering configuration is -- Ascending
Behaviour:
- Click any of the items in the list, so popup window will appear.
- Close it right after. (no save needed)
- After refresh the items are in reverse order -- Descending
The order will be ok again after reloading the page in cms, but after opening the popup again, will change as before.
Revisions // Where to fix.
This bug was introduced in r419 - in DataObjectManager.php..
In the current revision r432 is on line '246' - in DataObjectManager.php
To fix it - REMOVE
&ctf[{$this->Name()}][dir]={$sort_dir}
on line 246.
another notes
- When trying to define the Sorting order in _config.php with SortableDataObject::set_sort_dir("ASC");
or DESC .. it wont change anything
- Not sure if the removed part is important in other parts of the code..
UncleCheese can you review the code, thanks also for the great work.
-- to see more cleary changes of the order add SortOrder values from the db to the view
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'GalleryImages', // Source name
'GalleryImage', // Source class
array(
'SortOrder' => 'Order',
'Title' => 'Názov'
),
'getCMSFields_forPopup'
);
$f->addFieldToTab('Root.Content.Main', $manager);
return $f;
}