2017-05-05 02:34:56 +00: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-01 21:47:39 +00:00
|
|
|
getGroups(parentId, page, filterGroups) {
|
2017-05-22 17:47:05 +00:00
|
|
|
const data = {};
|
2017-05-12 08:36:08 +00:00
|
|
|
|
|
|
|
if (parentId) {
|
2017-05-22 17:47:05 +00:00
|
|
|
data.parent_id = parentId;
|
2017-06-01 21:47:39 +00:00
|
|
|
} else {
|
|
|
|
// Do not send the following param for sub groups
|
|
|
|
if (page) {
|
|
|
|
data.page = page;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filterGroups) {
|
|
|
|
data.filter_groups = filterGroups;
|
|
|
|
}
|
2017-05-12 08:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.groups.get(data);
|
2017-05-05 02:34:56 +00:00
|
|
|
}
|
2017-05-30 08:12:06 +00:00
|
|
|
|
2017-06-01 01:25:23 +00:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
2017-05-30 08:12:06 +00:00
|
|
|
leaveGroup(endpoint) {
|
|
|
|
return Vue.http.delete(endpoint);
|
|
|
|
}
|
2017-05-05 02:34:56 +00:00
|
|
|
}
|