debian-mirror-gitlab/app/assets/javascripts/boards/services/board_service.js.es6

68 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-09-13 17:45:13 +05:30
class BoardService {
2016-11-03 12:29:30 +05:30
constructor (root, boardId) {
2016-09-13 17:45:13 +05:30
Vue.http.options.root = root;
2016-11-03 12:29:30 +05:30
this.lists = Vue.resource(`${root}/${boardId}/lists{/id}`, {}, {
2016-09-13 17:45:13 +05:30
generate: {
method: 'POST',
2016-11-03 12:29:30 +05:30
url: `${root}/${boardId}/lists/generate.json`
2016-09-13 17:45:13 +05:30
}
});
2016-11-03 12:29:30 +05:30
this.issue = Vue.resource(`${root}/${boardId}/issues{/id}`, {});
this.issues = Vue.resource(`${root}/${boardId}/lists{/id}/issues`, {});
2016-09-13 17:45:13 +05:30
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
next();
});
}
all () {
return this.lists.get();
}
generateDefaultLists () {
return this.lists.generate({});
}
createList (label_id) {
return this.lists.save({}, {
list: {
label_id
}
});
}
updateList (id, position) {
return this.lists.update({ id }, {
list: {
position
}
});
}
destroyList (id) {
return this.lists.delete({ id });
}
getIssuesForList (id, filter = {}) {
let data = { id };
Object.keys(filter).forEach((key) => { data[key] = filter[key]; });
return this.issues.get(data);
}
moveIssue (id, from_list_id, to_list_id) {
return this.issue.update({ id }, {
from_list_id,
to_list_id
});
}
2016-11-03 12:29:30 +05:30
newIssue (id, issue) {
return this.issues.save({ id }, {
issue
});
}
2016-09-13 17:45:13 +05:30
};