Skip to content

Commit

Permalink
Merge pull request #68 from chialab/fix-ordering-2
Browse files Browse the repository at this point in the history
chore: clean code
  • Loading branch information
nicolocarpignoli authored Jan 4, 2023
2 parents 8c5b63a + 5f2bad2 commit 218c2ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Traits/GenericActionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ protected function loadFilteredChildren(Folder $folder): array
$order = ['Trees.tree_left'];
}

$sortAllowlist = $this->paginate['sortWhitelist'] ?? (array)$this->request->getQuery('sort');
$this->paginate['sortWhitelist'] = array_merge($sortAllowlist, array_keys($order));

$children = $this->Objects->loadRelatedObjects($folder['uname'], 'folders', 'children', $this->Filters->fromQuery());

return $this->paginate($children, ['order' => $order])->toList();
return $this->paginate($children->order([], true), ['order' => $order])->toList();
}

/**
Expand Down

0 comments on commit 218c2ed

Please sign in to comment.