2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
import request from '../utils/request';
|
2015-05-18 18:00:12 +02:00
|
|
|
|
2016-06-13 16:25:56 +02:00
|
|
|
import { safeMerge } from '../utils/general';
|
2016-06-13 14:35:02 +02:00
|
|
|
import { generateOrderingQueryParams } from '../utils/url';
|
2015-05-20 16:44:45 +02:00
|
|
|
|
2015-05-19 17:16:01 +02:00
|
|
|
let PieceListFetcher = {
|
2015-05-19 17:01:28 +02:00
|
|
|
/**
|
|
|
|
* Fetches a list of pieces from the API.
|
|
|
|
* Can be called with all supplied queryparams the API.
|
|
|
|
*/
|
2016-01-18 10:53:01 +01:00
|
|
|
fetch({ page, pageSize, search, orderBy, orderAsc, filterBy }) {
|
|
|
|
const ordering = generateOrderingQueryParams(orderBy, orderAsc);
|
2015-08-04 11:39:33 +02:00
|
|
|
|
|
|
|
// filterBy is an object of acl key-value pairs.
|
|
|
|
// The values are booleans
|
2016-06-14 16:53:18 +02:00
|
|
|
const query = safeMerge(
|
2015-08-04 11:39:33 +02:00
|
|
|
{
|
|
|
|
page,
|
|
|
|
pageSize,
|
|
|
|
search,
|
|
|
|
ordering
|
|
|
|
},
|
|
|
|
filterBy
|
|
|
|
);
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('pieces_list', { query });
|
2015-07-01 19:05:47 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
fetchRequestActions() {
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('pieces_list_request_actions');
|
2015-05-18 18:00:12 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-20 16:44:45 +02:00
|
|
|
export default PieceListFetcher;
|