diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-07 17:29:06 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-08-07 17:29:06 +0000 |
commit | ddb14e4098c9b16023cdd25743cb2dfb52481e5a (patch) | |
tree | 8e05a389dacf30ec13eb59e975e0c3dfff79003f /app | |
parent | 21c18070283041fb016777493d61b42edac600e5 (diff) | |
download | gitlab-ce-ddb14e4098c9b16023cdd25743cb2dfb52481e5a.tar.gz |
Backport issue board milestone lists EE changes
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/boards/components/board_list.vue | 15 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/boards_store.js | 15 | ||||
-rw-r--r-- | app/models/list.rb | 6 | ||||
-rw-r--r-- | app/views/shared/boards/components/_board.html.haml | 3 |
4 files changed, 31 insertions, 8 deletions
diff --git a/app/assets/javascripts/boards/components/board_list.vue b/app/assets/javascripts/boards/components/board_list.vue index 5c7565234d8..3e610a4088c 100644 --- a/app/assets/javascripts/boards/components/board_list.vue +++ b/app/assets/javascripts/boards/components/board_list.vue @@ -112,12 +112,20 @@ export default { if (e.target) { const containerEl = e.target.closest('.js-board-list') || e.target.querySelector('.js-board-list'); const toBoardType = containerEl.dataset.boardType; + const cloneActions = { + label: ['milestone', 'assignee'], + assignee: ['milestone', 'label'], + milestone: ['label', 'assignee'], + }; if (toBoardType) { const fromBoardType = this.list.type; + // For each list we check if the destination list is + // a the list were we should clone the issue + const shouldClone = Object.entries(cloneActions).some(entry => ( + fromBoardType === entry[0] && entry[1].includes(toBoardType))); - if ((fromBoardType === 'assignee' && toBoardType === 'label') || - (fromBoardType === 'label' && toBoardType === 'assignee')) { + if (shouldClone) { return 'clone'; } } @@ -145,7 +153,8 @@ export default { }); }, onUpdate: (e) => { - const sortedArray = this.sortable.toArray().filter(id => id !== '-1'); + const sortedArray = this.sortable.toArray() + .filter(id => id !== '-1'); gl.issueBoards.BoardsStore .moveIssueInList(this.list, Store.moving.issue, e.oldIndex, e.newIndex, sortedArray); }, diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js index 76467564608..957114cf420 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js +++ b/app/assets/javascripts/boards/stores/boards_store.js @@ -108,6 +108,16 @@ gl.issueBoards.BoardsStore = { issue.findAssignee(listTo.assignee)) { const targetIssue = listTo.findIssue(issue.id); targetIssue.removeAssignee(listFrom.assignee); + } else if (listTo.type === 'milestone') { + const currentMilestone = issue.milestone; + const currentLists = this.state.lists + .filter(list => (list.type === 'milestone' && list.id !== listTo.id)) + .filter(list => list.issues.some(listIssue => issue.id === listIssue.id)); + + issue.removeMilestone(currentMilestone); + issue.addMilestone(listTo.milestone); + currentLists.forEach(currentList => currentList.removeIssue(issue)); + listTo.addIssue(issue, listFrom, newIndex); } else { // Add to new lists issues if it doesn't already exist listTo.addIssue(issue, listFrom, newIndex); @@ -125,6 +135,9 @@ gl.issueBoards.BoardsStore = { } else if (listTo.type === 'backlog' && listFrom.type === 'assignee') { issue.removeAssignee(listFrom.assignee); listFrom.removeIssue(issue); + } else if (listTo.type === 'backlog' && listFrom.type === 'milestone') { + issue.removeMilestone(listFrom.milestone); + listFrom.removeIssue(issue); } else if (this.shouldRemoveIssue(listFrom, listTo)) { listFrom.removeIssue(issue); } @@ -144,7 +157,7 @@ gl.issueBoards.BoardsStore = { }, findList (key, val, type = 'label') { const filteredList = this.state.lists.filter((list) => { - const byType = type ? (list.type === type) || (list.type === 'assignee') : true; + const byType = type ? (list.type === type) || (list.type === 'assignee') || (list.type === 'milestone') : true; return list[key] === val && byType; }); diff --git a/app/models/list.rb b/app/models/list.rb index eabe3ffccbb..1a30acc83cf 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -4,7 +4,7 @@ class List < ActiveRecord::Base belongs_to :board belongs_to :label - enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3 } + enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3, milestone: 4 } validates :board, :list_type, presence: true validates :label, :position, presence: true, if: :label? @@ -27,11 +27,11 @@ class List < ActiveRecord::Base end def destroyable? - label? + self.class.destroyable_types.include?(list_type&.to_sym) end def movable? - label? + self.class.movable_types.include?(list_type&.to_sym) end def title diff --git a/app/views/shared/boards/components/_board.html.haml b/app/views/shared/boards/components/_board.html.haml index b35877e5518..e26f5260e5b 100644 --- a/app/views/shared/boards/components/_board.html.haml +++ b/app/views/shared/boards/components/_board.html.haml @@ -6,12 +6,13 @@ %i.fa.fa-fw.board-title-expandable-toggle{ "v-if": "list.isExpandable", ":class": "{ \"fa-caret-down\": list.isExpanded, \"fa-caret-right\": !list.isExpanded }", "aria-hidden": "true" } + = render_if_exists "shared/boards/components/list_milestone" %a.user-avatar-link.js-no-trigger{ "v-if": "list.type === \"assignee\"", ":href": "list.assignee.path" } -# haml-lint:disable AltText %img.avatar.s20.has-tooltip{ height: "20", width: "20", ":src": "list.assignee.avatar", ":alt": "list.assignee.name" } - %span.board-title-text.has-tooltip{ "v-if": "list.type !== \"label\"", + %span.board-title-text.has-tooltip.block-truncated{ "v-if": "list.type !== \"label\"", ":title" => '((list.label && list.label.description) || list.title || "")', data: { container: "body" } } {{ list.title }} |