Skip to content

Commit

Permalink
Add filtering (#7)
Browse files Browse the repository at this point in the history
* Add filtering

* Bump 0.4.4
  • Loading branch information
Henning Vogt committed Jan 12, 2019
1 parent 7cd4364 commit 9f2edf4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 24 deletions.
73 changes: 51 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ra-jsonapi-client",
"version": "0.4.3",
"version": "0.4.4",
"description": "JSON API data provider for react-admin.",
"main": "build/index.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ export default (apiUrl, userSettings = {}) => (type, resource, params) => {
switch (type) {
case GET_LIST: {
const { page, perPage } = params.pagination;
// TODO: Allow sorting, filtering etc.

// Create query with pagination params.
const query = {
'page[number]': page,
'page[size]': perPage,
};

// Add all filter params to query.
Object.keys(params.filter || {}).forEach((key) => {
query[`filter[${key}]`] = params.filter[key];
});

url = `${apiUrl}/${resource}?${stringify(query)}`;
break;
}
Expand Down

0 comments on commit 9f2edf4

Please sign in to comment.