diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-06-04 09:15:55 +0200 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-07-01 15:36:03 +0200 |
commit | cb7a294b05d4d9776aa7b12f268d438aa002b22b (patch) | |
tree | 06c6c9a0bad0c432c6561626044680930f18dfcc | |
parent | ddc2702a4a4b2cd8276003a734e27a7df81a18e9 (diff) | |
download | gitlab-ce-winh-move-BoardService-to-boardsStore.tar.gz |
Make BoardService proxy to boardsStorewinh-move-BoardService-to-boardsStore
(cherry picked from commit 38fb56063ec5cd14189f89b47b807ee901b2b123)
-rw-r--r-- | app/assets/javascripts/boards/services/board_service.js | 67 |
1 files changed, 15 insertions, 52 deletions
diff --git a/app/assets/javascripts/boards/services/board_service.js b/app/assets/javascripts/boards/services/board_service.js index 925017e54ee..580d04a3649 100644 --- a/app/assets/javascripts/boards/services/board_service.js +++ b/app/assets/javascripts/boards/services/board_service.js @@ -1,103 +1,66 @@ /* eslint-disable class-methods-use-this */ -import axios from '../../lib/utils/axios_utils'; -import { mergeUrlParams } from '../../lib/utils/url_utility'; import boardsStore from '~/boards/stores/boards_store'; export default class BoardService { generateBoardsPath(id) { - return `${boardsStore.state.endpoints.boardsEndpoint}${id ? `/${id}` : ''}.json`; + return boardsStore.generateBoardsPath(id); } generateIssuesPath(id) { - return `${boardsStore.state.endpoints.listsEndpoint}${id ? `/${id}` : ''}/issues`; + return boardsStore.generateIssuesPath(id); } static generateIssuePath(boardId, id) { - return `${gon.relative_url_root}/-/boards/${boardId ? `${boardId}` : ''}/issues${ - id ? `/${id}` : '' - }`; + return boardsStore.generateIssuePath(boardId, id); } all() { - return axios.get(boardsStore.state.endpoints.listsEndpoint); + return boardsStore.all(); } generateDefaultLists() { - return axios.post(boardsStore.state.endpoints.listsEndpointGenerate, {}); + return boardsStore.generateDefaultLists(); } createList(entityId, entityType) { - const list = { - [entityType]: entityId, - }; - - return axios.post(boardsStore.state.endpoints.listsEndpoint, { - list, - }); + return boardsStore.createList(entityId, entityType); } updateList(id, position) { - return axios.put(`${boardsStore.state.endpoints.listsEndpoint}/${id}`, { - list: { - position, - }, - }); + return boardsStore.updateList(id, position); } destroyList(id) { - return axios.delete(`${boardsStore.state.endpoints.listsEndpoint}/${id}`); + return boardsStore.destroyList(id); } getIssuesForList(id, filter = {}) { - const data = { id }; - Object.keys(filter).forEach(key => { - data[key] = filter[key]; - }); - - return axios.get(mergeUrlParams(data, this.generateIssuesPath(id))); + return boardsStore.getIssuesForList(id, filter); } moveIssue(id, fromListId = null, toListId = null, moveBeforeId = null, moveAfterId = null) { - return axios.put(BoardService.generateIssuePath(boardsStore.state.endpoints.boardId, id), { - from_list_id: fromListId, - to_list_id: toListId, - move_before_id: moveBeforeId, - move_after_id: moveAfterId, - }); + return boardsStore.moveIssue(id, fromListId, toListId, moveBeforeId, moveAfterId); } newIssue(id, issue) { - return axios.post(this.generateIssuesPath(id), { - issue, - }); + return boardsStore.newIssue(id, issue); } getBacklog(data) { - return axios.get( - mergeUrlParams( - data, - `${gon.relative_url_root}/-/boards/${boardsStore.state.endpoints.boardId}/issues.json`, - ), - ); + return boardsStore.getBacklog(data); } bulkUpdate(issueIds, extraData = {}) { - const data = { - update: Object.assign(extraData, { - issuable_ids: issueIds.join(','), - }), - }; - - return axios.post(boardsStore.state.endpoints.bulkUpdatePath, data); + return boardsStore.bulkUpdate(issueIds, extraData); } static getIssueInfo(endpoint) { - return axios.get(endpoint); + return boardsStore.getIssueInfo(endpoint); } static toggleIssueSubscription(endpoint) { - return axios.post(endpoint); + return boardsStore.toggleIssueSubscription(endpoint); } } |