mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
WIP
This commit is contained in:
29
client/src/services/RemoteDataBinding.js
Normal file
29
client/src/services/RemoteDataBinding.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
|
||||
export default class RemoteDataBinding {
|
||||
|
||||
execute(state) {
|
||||
return this.getData(state);
|
||||
}
|
||||
|
||||
getData(state) {
|
||||
const pageQuery = `$skip=${state.skip}&$top=${state.take}`;
|
||||
let sortQuery = '';
|
||||
|
||||
if ((state.sorted || []).length) {
|
||||
sortQuery = `&$orderby=` + (state).sorted.map((obj) => {
|
||||
return obj.direction === 'descending' ? `${obj.name} desc` : obj.name;
|
||||
}).reverse().join(',');
|
||||
}
|
||||
|
||||
this.ajax.url = `${this.baseUrl}?${pageQuery}${sortQuery}&$inlinecount=allpages&$format=json`;
|
||||
|
||||
return ApiService.get(this.ajax.url).then((response) => {
|
||||
let data = JSON.parse(response);
|
||||
return {
|
||||
result: data['d']['results'],
|
||||
count: parseInt(data['d']['__count'], 10),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user