Skip to content

Commit

Permalink
Add support for ReferenceField and ReferenceInput
Browse files Browse the repository at this point in the history
  • Loading branch information
tb committed Mar 12, 2017
1 parent 5d46647 commit f7d2122
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { queryParameters, fetchJson } from 'admin-on-rest/lib/util/fetch';

import {
GET_MANY,
GET_MANY_REFERENCE,
GET_LIST,
GET_ONE,
CREATE,
Expand Down Expand Up @@ -31,9 +33,11 @@ export default (apiUrl, httpClient = fetchJson) => {
const options = {};
let query = {};
switch (type) {
case GET_LIST: {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
case GET_MANY:
case GET_MANY_REFERENCE:
case GET_LIST:
const { page, perPage } = params.pagination || {};
const { field, order } = params.sort || {};

let sortKey = '$sort[' + field + ']';
let sortVal = (order === 'DESC') ? -1 : 1;
Expand All @@ -49,7 +53,6 @@ export default (apiUrl, httpClient = fetchJson) => {

url = `${apiUrl}/${resource}?${queryParameters(query)}`;
break;
}
case GET_ONE:
url = `${apiUrl}/${resource}/${params.id}`;
break;
Expand Down Expand Up @@ -83,6 +86,9 @@ export default (apiUrl, httpClient = fetchJson) => {
const convertHTTPResponseToREST = (response, type, resource, params) => {
const { headers, json } = response;
switch (type) {
case GET_MANY:
case GET_MANY_REFERENCE:
return json.data;
case GET_LIST:
return {
data: json.data,
Expand Down

0 comments on commit f7d2122

Please sign in to comment.