2016-06-17 13:48:33 +00:00
|
|
|
import { get } from '../api/client';
|
|
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
import { ADMIN_API } from '../config/wagtailConfig';
|
2016-06-17 13:48:33 +00:00
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
|
|
|
|
|
export const getPage = (id) => {
|
|
|
|
|
const url = `${ADMIN_API.PAGES}${id}/`;
|
|
|
|
|
|
|
|
|
|
return get(url);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getPageChildren = (id, options = {}) => {
|
2016-06-17 13:48:33 +00:00
|
|
|
let url = `${ADMIN_API.PAGES}?child_of=${id}`;
|
|
|
|
|
|
|
|
|
|
if (options.fields) {
|
|
|
|
|
url += `&fields=${global.encodeURIComponent(options.fields.join(','))}`;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
if (options.onlyWithChildren) {
|
|
|
|
|
url += '&has_children=1';
|
|
|
|
|
}
|
2016-06-17 13:48:33 +00:00
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
if (options.offset) {
|
|
|
|
|
url += `&offset=${options.offset}`;
|
|
|
|
|
}
|
2016-06-17 13:48:33 +00:00
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
url += ADMIN_API.EXTRA_CHILDREN_PARAMETERS;
|
2016-06-17 13:48:33 +00:00
|
|
|
|
2017-02-12 15:29:56 +00:00
|
|
|
return get(url);
|
2016-06-17 13:48:33 +00:00
|
|
|
};
|