Commit 63a1ec14 authored by Phil Hughes's avatar Phil Hughes

Correctly removes from boards when moved to done

Only shows options to remove from all boards if issue is in more than 1
parent ff7bab37
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)
......@@ -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', {})
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment