2017-05-04 22:34:56 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
|
|
|
|
|
|
|
Vue.use(VueResource);
|
|
|
|
|
|
|
|
export default class GroupsService {
|
|
|
|
constructor(endpoint) {
|
|
|
|
this.groups = Vue.resource(endpoint);
|
|
|
|
}
|
|
|
|
|
2017-06-06 01:06:08 -04:00
|
|
|
getGroups(parentId, page, filterGroups, sort) {
|
2017-05-22 13:47:05 -04:00
|
|
|
const data = {};
|
2017-05-12 04:36:08 -04:00
|
|
|
|
|
|
|
if (parentId) {
|
2017-05-22 13:47:05 -04:00
|
|
|
data.parent_id = parentId;
|
2017-06-01 17:47:39 -04:00
|
|
|
} else {
|
|
|
|
// Do not send the following param for sub groups
|
|
|
|
if (page) {
|
|
|
|
data.page = page;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filterGroups) {
|
|
|
|
data.filter_groups = filterGroups;
|
|
|
|
}
|
2017-06-06 01:06:08 -04:00
|
|
|
|
|
|
|
if (sort) {
|
|
|
|
data.sort = sort;
|
|
|
|
}
|
2017-05-12 04:36:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.groups.get(data);
|
2017-05-04 22:34:56 -04:00
|
|
|
}
|
2017-05-30 04:12:06 -04:00
|
|
|
|
2017-05-31 21:25:23 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
2017-05-30 04:12:06 -04:00
|
|
|
leaveGroup(endpoint) {
|
|
|
|
return Vue.http.delete(endpoint);
|
|
|
|
}
|
2017-05-04 22:34:56 -04:00
|
|
|
}
|