diff options
author | Phil Hughes <me@iamphill.com> | 2016-07-25 14:37:33 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-17 17:12:47 +0100 |
commit | 63a1ec14837cd34cbb895acf3b305e0f708fee9f (patch) | |
tree | 25ee2f5a09b585ea63c7e4e5d03108ec97e48e69 | |
parent | ff7bab37606777d7a0625caa50fb9b0f5690d25e (diff) | |
download | gitlab-ce-63a1ec14837cd34cbb895acf3b305e0f708fee9f.tar.gz |
Correctly removes from boards when moved to done
Only shows options to remove from all boards if issue is in more than 1
3 files changed, 22 insertions, 5 deletions
diff --git a/app/assets/javascripts/boards/components/issue_done.js.coffee b/app/assets/javascripts/boards/components/issue_done.js.coffee index f4bf2b86179..14f441cd682 100644 --- a/app/assets/javascripts/boards/components/issue_done.js.coffee +++ b/app/assets/javascripts/boards/components/issue_done.js.coffee @@ -1,5 +1,12 @@ IssueDone = Vue.extend props: done: Object + methods: + removeFromAll: -> + BoardsStore.removeIssueFromBoards(this.done.issue, this.done.boards) + BoardsStore.clearDone() + removeFromSingle: -> + BoardsStore.removeIssueFromBoard(this.done.issue, this.done.board) + BoardsStore.clearDone() Vue.component('issue-done', IssueDone) diff --git a/app/assets/javascripts/boards/stores/boards_store.js.coffee b/app/assets/javascripts/boards/stores/boards_store.js.coffee index 077681b0227..7c123b65acf 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js.coffee +++ b/app/assets/javascripts/boards/stores/boards_store.js.coffee @@ -36,7 +36,7 @@ # Add to new boards issues boardTo.issues.splice(toIndex, 0, issue) - if boardTo.id is 'done' + if boardTo.id is 'done' and issueBoards.length > 1 Vue.set(BoardsStore.state.done, 'board', boardFrom) Vue.set(BoardsStore.state.done, 'issue', issue) Vue.set(BoardsStore.state.done, 'boards', issueBoards) @@ -45,13 +45,23 @@ label.title is boardFrom.title else if boardTo.label? - foundLabel = _.find issue.labels, (label) -> - label.title is boardTo.label.title + BoardsStore.removeIssueFromBoard(issue, boardTo) unless foundLabel? issue.labels.push(boardTo.label) + removeIssueFromBoards: (issue, boards) -> + boardLabels = _.map boards, (board) -> + board.label.title + + issue.labels = _.reject issue.labels, (label) -> + boardLabels.indexOf(label.title) != -1 + removeIssueFromBoard: (issue, board) -> + issue.labels = _.reject issue.labels, (label) -> + label.title is board.title getBoardsForIssue: (issue) -> _.filter BoardsStore.state.boards, (board) -> foundIssue = _.find board.issues, (boardIssue) -> issue?.id == boardIssue?.id foundIssue? + clearDone: -> + Vue.set(BoardsStore.state, 'done', {}) diff --git a/app/views/projects/boards/components/_board.html.haml b/app/views/projects/boards/components/_board.html.haml index d2b27e58ca5..992eb0b9746 100644 --- a/app/views/projects/boards/components/_board.html.haml +++ b/app/views/projects/boards/components/_board.html.haml @@ -31,7 +31,7 @@ {{ board.title }} %p Moving it to Done will remove it from all lists and close the issue. - %button.btn.btn-gray.btn-block.prepend-top-10{ type: "button" } + %button.btn.btn-gray.btn-block.prepend-top-10{ type: "button", "@click" => "removeFromAll" } Remove from all lists and close - %button.btn.btn-gray.btn-block{ type: "button" } + %button.btn.btn-gray.btn-block{ type: "button", "@click" => "removeFromSingle" } Remove from {{ done.board.title }} list |