2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
|
|
|
|
|
|
|
Vue.use(VueResource);
|
|
|
|
|
|
|
|
export default class SidebarService {
|
2018-03-17 18:26:18 +05:30
|
|
|
constructor(endpointMap) {
|
2017-08-17 22:00:37 +05:30
|
|
|
if (!SidebarService.singleton) {
|
2018-03-17 18:26:18 +05:30
|
|
|
this.endpoint = endpointMap.endpoint;
|
|
|
|
this.toggleSubscriptionEndpoint = endpointMap.toggleSubscriptionEndpoint;
|
|
|
|
this.moveIssueEndpoint = endpointMap.moveIssueEndpoint;
|
|
|
|
this.projectsAutocompleteEndpoint = endpointMap.projectsAutocompleteEndpoint;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
SidebarService.singleton = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SidebarService.singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
get() {
|
|
|
|
return Vue.http.get(this.endpoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(key, data) {
|
|
|
|
return Vue.http.put(this.endpoint, {
|
|
|
|
[key]: data,
|
|
|
|
}, {
|
|
|
|
emulateJSON: true,
|
|
|
|
});
|
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
getProjectsAutocomplete(searchTerm) {
|
|
|
|
return Vue.http.get(this.projectsAutocompleteEndpoint, {
|
|
|
|
params: {
|
|
|
|
search: searchTerm,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleSubscription() {
|
|
|
|
return Vue.http.post(this.toggleSubscriptionEndpoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
moveIssue(moveToProjectId) {
|
|
|
|
return Vue.http.post(this.moveIssueEndpoint, {
|
|
|
|
move_to_project_id: moveToProjectId,
|
|
|
|
});
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|