chg: [brood:queryIndex] Added support of pagination and filtering
parent
b9292473de
commit
3fcb58c081
|
@ -101,8 +101,14 @@ class BroodsController extends AppController
|
|||
if (!in_array($scope, $validScopes)) {
|
||||
throw new MethodNotAllowedException(__('Invalid scope. Valid options are: {0}', implode(', ', $validScopes)));
|
||||
}
|
||||
$filter = $this->request->getQuery('quickFilter');
|
||||
$data = $this->Broods->queryIndex($id, $scope, $filter, true);
|
||||
$filtering = [
|
||||
'page' => $this->request->getQuery('page', 1),
|
||||
'limit' => $this->request->getQuery('limit', 20),
|
||||
];
|
||||
if (!empty($this->request->getQuery('quickFilter'))) {
|
||||
$filtering['quickFilter'] = $this->request->getQuery('quickFilter');
|
||||
}
|
||||
$data = $this->Broods->queryIndex($id, $scope, $filtering, true);
|
||||
if (!is_array($data)) {
|
||||
$data = [];
|
||||
}
|
||||
|
|
|
@ -151,11 +151,10 @@ class BroodsTable extends AppTable
|
|||
if (empty($brood)) {
|
||||
throw new NotFoundException(__('Brood not found'));
|
||||
}
|
||||
$filterQuery = empty($filter) ? '' : '?quickFilter=' . urlencode($filter);
|
||||
if (!empty($full)) {
|
||||
$filterQuery .= (empty($filterQuery) ? '?' : '&') . 'full=1';
|
||||
$filter['full'] = 1;
|
||||
}
|
||||
$response = $this->HTTPClientGET(sprintf('/%s/index.json%s', $scope, $filterQuery), $brood);
|
||||
$response = $this->HTTPClientGET(sprintf('/%s/index.json?%s', $scope, http_build_query($filter)), $brood);
|
||||
if ($response->isOk()) {
|
||||
return $response->getJson();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue