This commit is contained in:
Ahmed Bouhuolia
2020-03-16 00:06:15 +02:00
parent 56701951b7
commit 73711384f6
7925 changed files with 18478 additions and 959 deletions

View 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),
};
});
}
}