debian-mirror-gitlab/app/assets/javascripts/notes/services/notes_service.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import VueResource from 'vue-resource';
2018-03-27 19:54:05 +05:30
import * as constants from '../constants';
2018-03-17 18:26:18 +05:30
Vue.use(VueResource);
export default {
fetchNotes(endpoint) {
return Vue.http.get(endpoint);
},
deleteNote(endpoint) {
return Vue.http.delete(endpoint);
},
replyToDiscussion(endpoint, data) {
return Vue.http.post(endpoint, data, { emulateJSON: true });
},
updateNote(endpoint, data) {
return Vue.http.put(endpoint, data, { emulateJSON: true });
},
createNewNote(endpoint, data) {
return Vue.http.post(endpoint, data, { emulateJSON: true });
},
2018-03-27 19:54:05 +05:30
toggleResolveNote(endpoint, isResolved) {
const { RESOLVE_NOTE_METHOD_NAME, UNRESOLVE_NOTE_METHOD_NAME } = constants;
2018-05-09 12:01:36 +05:30
const method = isResolved
? UNRESOLVE_NOTE_METHOD_NAME
: RESOLVE_NOTE_METHOD_NAME;
2018-03-27 19:54:05 +05:30
return Vue.http[method](endpoint);
},
2018-03-17 18:26:18 +05:30
poll(data = {}) {
2018-03-27 19:54:05 +05:30
const endpoint = data.notesData.notesPath;
const lastFetchedAt = data.lastFetchedAt;
2018-03-17 18:26:18 +05:30
const options = {
headers: {
2018-03-27 19:54:05 +05:30
'X-Last-Fetched-At': lastFetchedAt ? `${lastFetchedAt}` : undefined,
2018-03-17 18:26:18 +05:30
},
};
return Vue.http.get(endpoint, options);
},
toggleAward(endpoint, data) {
return Vue.http.post(endpoint, data, { emulateJSON: true });
},
2018-03-27 19:54:05 +05:30
toggleIssueState(endpoint, data) {
return Vue.http.put(endpoint, data);
},
2018-03-17 18:26:18 +05:30
};