diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-15 18:10:02 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-17 17:17:39 +0100 |
commit | 7e7673d55ec4211b0c9817f099f1172b2c416b95 (patch) | |
tree | 3ed24dc92111cc4a64cf29880f5aa705fc3f8aa4 /app/assets | |
parent | d4387bd31799b78f8926ab94aa50656fd5eef45b (diff) | |
download | gitlab-ce-7e7673d55ec4211b0c9817f099f1172b2c416b95.tar.gz |
Fixed bug when moving lists around & then deleting
Diffstat (limited to 'app/assets')
4 files changed, 22 insertions, 12 deletions
diff --git a/app/assets/javascripts/boards/components/board.js.es6 b/app/assets/javascripts/boards/components/board.js.es6 index 07925f4abf7..213b09e6143 100644 --- a/app/assets/javascripts/boards/components/board.js.es6 +++ b/app/assets/javascripts/boards/components/board.js.es6 @@ -64,9 +64,20 @@ group: 'boards', draggable: '.is-draggable', handle: '.js-board-handle', - onUpdate: (e) => { - if (e.oldIndex !== e.newIndex) { - gl.issueBoards.BoardsStore.moveList(e.oldIndex, this.sortable.toArray()); + onEnd: (e) => { + document.body.classList.remove('is-dragging'); + + if (e.newIndex !== undefined && e.oldIndex !== e.newIndex) { + const order = this.sortable.toArray(), + $board = this.$parent.$refs.board[e.oldIndex + 1], + list = $board.list; + + $board.$destroy(true); + + this.$nextTick(() => { + gl.issueBoards.BoardsStore.state.lists.splice(e.newIndex, 0, list); + gl.issueBoards.BoardsStore.moveList(list, order); + }); } } }); @@ -78,11 +89,7 @@ this.sortable = Sortable.create(this.$el.parentNode, options); }, beforeDestroy () { - this.list.destroy(); - - if (gl.issueBoards.BoardsStore.state.lists.length === 0) { - this.sortable.destroy(); - } + gl.issueBoards.BoardsStore.state.lists.$remove(this.list); } }); })(); diff --git a/app/assets/javascripts/boards/components/board_delete.js.es6 b/app/assets/javascripts/boards/components/board_delete.js.es6 index 735789821c8..ad6a320f086 100644 --- a/app/assets/javascripts/boards/components/board_delete.js.es6 +++ b/app/assets/javascripts/boards/components/board_delete.js.es6 @@ -3,13 +3,16 @@ window.gl.issueBoards = window.gl.issueBoards || {}; gl.issueBoards.BoardDelete = Vue.extend({ + props: { + list: Object + }, methods: { deleteBoard (e) { e.stopImmediatePropagation(); $(this.$el).tooltip('hide'); if (confirm('Are you sure you want to delete this list?')) { - this.$parent.$destroy(true); + this.list.destroy(); } } } diff --git a/app/assets/javascripts/boards/models/list.js.es6 b/app/assets/javascripts/boards/models/list.js.es6 index b3fda39f499..a363868eb56 100644 --- a/app/assets/javascripts/boards/models/list.js.es6 +++ b/app/assets/javascripts/boards/models/list.js.es6 @@ -1,6 +1,7 @@ class List { constructor (obj) { this.id = obj.id; + this._uid = Math.ceil(Math.random() * 1000); this.position = obj.position; this.title = obj.title; this.type = obj.list_type; diff --git a/app/assets/javascripts/boards/stores/boards_store.js.es6 b/app/assets/javascripts/boards/stores/boards_store.js.es6 index 680d87a9b65..9564f48fdbe 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js.es6 +++ b/app/assets/javascripts/boards/stores/boards_store.js.es6 @@ -80,15 +80,14 @@ return list.id !== id; }); }, - moveList (oldIndex, orderLists) { - const listFrom = this.findList('position', oldIndex); - + moveList (listFrom, orderLists) { for (let i = 0, orderLength = orderLists.length; i < orderLength; i++) { const id = parseInt(orderLists[i]), list = this.findList('id', id); list.position = i; } + listFrom.update(); }, moveIssueToList (listFrom, listTo, issue) { const issueTo = listTo.findIssue(issue.id), |