From cf41aaba5ab9fb1d229807f77b2b77585d3550b0 Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Thu, 7 Jun 2018 20:54:24 +0000 Subject: Backport of "Add assignee lists to boards" --- .../javascripts/boards/components/board_list.vue | 41 +++++++++- .../boards/components/board_new_issue.vue | 4 +- .../boards/components/new_list_dropdown.js | 1 + app/assets/javascripts/boards/index.js | 2 +- app/assets/javascripts/boards/models/assignee.js | 12 --- app/assets/javascripts/boards/models/list.js | 87 ++++++++++++++-------- .../javascripts/boards/services/board_service.js | 10 ++- .../javascripts/boards/stores/boards_store.js | 24 ++++-- 8 files changed, 122 insertions(+), 59 deletions(-) delete mode 100644 app/assets/javascripts/boards/models/assignee.js (limited to 'app/assets/javascripts/boards') diff --git a/app/assets/javascripts/boards/components/board_list.vue b/app/assets/javascripts/boards/components/board_list.vue index 84a7f277227..0692c96e767 100644 --- a/app/assets/javascripts/boards/components/board_list.vue +++ b/app/assets/javascripts/boards/components/board_list.vue @@ -87,10 +87,46 @@ export default { mounted() { const options = gl.issueBoards.getBoardSortableDefaultOptions({ scroll: true, - group: 'issues', disabled: this.disabled, filter: '.board-list-count, .is-disabled', dataIdAttr: 'data-issue-id', + group: { + name: 'issues', + /** + * Dynamically determine between which containers + * items can be moved or copied as + * Assignee lists (EE feature) require this behavior + */ + pull: (to, from, dragEl, e) => { + // As per Sortable's docs, `to` should provide + // reference to exact sortable container on which + // we're trying to drag element, but either it is + // a library's bug or our markup structure is too complex + // that `to` never points to correct container + // See https://github.com/RubaXa/Sortable/issues/1037 + // + // So we use `e.target` which is always accurate about + // which element we're currently dragging our card upon + // So from there, we can get reference to actual container + // and thus the container type to enable Copy or Move + if (e.target) { + const containerEl = e.target.closest('.js-board-list') || e.target.querySelector('.js-board-list'); + const toBoardType = containerEl.dataset.boardType; + + if (toBoardType) { + const fromBoardType = this.list.type; + + if ((fromBoardType === 'assignee' && toBoardType === 'label') || + (fromBoardType === 'label' && toBoardType === 'assignee')) { + return 'clone'; + } + } + } + + return true; + }, + revertClone: true, + }, onStart: (e) => { const card = this.$refs.issue[e.oldIndex]; @@ -179,10 +215,11 @@ export default { :list="list" v-if="list.type !== 'closed' && showIssueForm"/>