mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 15:05:39 +00:00
ENH applies default sort order to CMS ordering (#325)
* (cms interface) applies default sort order to CMS ordering This allows secondary sort ordering to be applied when it exists and when the objects have not been sorted manually * (sort logic) adds additional checks for non DataList or unsorted cases * Update src/GridFieldOrderableRows.php Co-authored-by: Michal Kleiner <mk@011.nz> Co-authored-by: Michal Kleiner <mk@011.nz>
This commit is contained in:
parent
baa6a8d147
commit
6d6cf4a225
@ -8,6 +8,7 @@ use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
|
||||
use SilverStripe\Forms\GridField\GridField_DataManipulator;
|
||||
@ -360,7 +361,17 @@ class GridFieldOrderableRows extends RequestHandler implements
|
||||
$sortterm .= $this->getSortTable($list).'.'.$this->getSortField();
|
||||
} else {
|
||||
$sortterm .= '"'.$this->getSortTable($list).'"."'.$this->getSortField().'"';
|
||||
|
||||
if ($list instanceof DataList) {
|
||||
$classname = $list->dataClass();
|
||||
if ($defaultSort = Config::inst()->get($classname, 'default_sort')) {
|
||||
// Append the default sort to the end of the sort string
|
||||
// This may result in redundancy... but it seems to work
|
||||
$sortterm .= ($sortterm ? ', ' : '') . $defaultSort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list->sort($sortterm);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user