2017-05-04 22:34:56 -04:00
|
|
|
import Vue from 'vue';
|
2018-01-23 07:14:29 -05:00
|
|
|
import '../../vue_shared/vue_resource_interceptor';
|
2017-05-04 22:34:56 -04:00
|
|
|
|
|
|
|
export default class GroupsService {
|
|
|
|
constructor(endpoint) {
|
|
|
|
this.groups = Vue.resource(endpoint);
|
|
|
|
}
|
|
|
|
|
2017-10-13 04:36:25 -04:00
|
|
|
getGroups(parentId, page, filterGroups, sort, archived) {
|
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) {
|
2017-10-04 10:10:24 -04:00
|
|
|
data.filter = filterGroups;
|
2017-06-01 17:47:39 -04:00
|
|
|
}
|
2017-06-06 01:06:08 -04:00
|
|
|
|
|
|
|
if (sort) {
|
|
|
|
data.sort = sort;
|
|
|
|
}
|
2017-10-13 04:36:25 -04:00
|
|
|
|
|
|
|
if (archived) {
|
|
|
|
data.archived = archived;
|
|
|
|
}
|
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
|
|
|
}
|