Fixed issue where sortable header and filter could potentially get put back in when changing pages

Fixed issue when sorting cross pages with a many_many list
This commit is contained in:
UndefinedOffset 2012-05-17 16:43:29 -03:00
parent fb767a6722
commit 786af43ca9

View File

@ -89,10 +89,16 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
* @return DataList Modified Data List * @return DataList Modified Data List
*/ */
public function getManipulatedData(GridField $gridField, SS_List $dataList) { public function getManipulatedData(GridField $gridField, SS_List $dataList) {
$state = $gridField->State->GridFieldSortableHeader; $headerState = $gridField->State->GridFieldSortableHeader;
if ($state && !empty($state->SortColumn)) { $state = $gridField->State->GridFieldSortableRows;
if ((!is_bool($state->sortableToggle) || $state->sortableToggle==false) && $headerState && !empty($headerState->SortColumn)) {
return $dataList; return $dataList;
} }
if ($state->sortableToggle == true) {
$gridField->getConfig()->removeComponentsByType('GridFieldFilterHeader');
$gridField->getConfig()->removeComponentsByType('GridFieldSortableHeader');
}
return $dataList->sort($this->sortColumn); return $dataList->sort($this->sortColumn);
} }
@ -261,7 +267,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
if ($many_many) { if ($many_many) {
DB::query('UPDATE "' . $table DB::query('UPDATE "' . $table
. '" SET "' . $sortColumn.'" = ' . $targetItem->$sortColumn . '" SET "' . $sortColumn.'" = ' . $targetItem->$sortColumn
. ' WHERE "' . $componentField . '" = ' . $targetItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID); . ' WHERE "' . $componentField . '" = ' . $swapItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
} else { } else {
$swapItem->$sortColumn = $targetItem->$sortColumn; $swapItem->$sortColumn = $targetItem->$sortColumn;
$swapItem->write(); $swapItem->write();