diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-01 21:41:01 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-02-17 14:29:16 +0300 |
commit | ac868482a7780a332045ef270a409ff70bcf8efd (patch) | |
tree | 99ff605262028f08718f04ac0c9e42c516d38693 /app/assets/javascripts/boards/models | |
parent | 5d8f5328baca93b9134f10ae593e71834578a9f8 (diff) |
Allow issues in boards to be ordered
Diffstat (limited to 'app/assets/javascripts/boards/models')
-rw-r--r-- | app/assets/javascripts/boards/models/list.js.es6 | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/app/assets/javascripts/boards/models/list.js.es6 b/app/assets/javascripts/boards/models/list.js.es6 index 5152be56b66..4f7745e6e8d 100644 --- a/app/assets/javascripts/boards/models/list.js.es6 +++ b/app/assets/javascripts/boards/models/list.js.es6 @@ -111,8 +111,16 @@ class List { addIssue (issue, listFrom, newIndex) { if (!this.findIssue(issue.id)) { + let moveBeforeIid = null; + let moveAfterIid = null; + if (newIndex !== undefined) { this.issues.splice(newIndex, 0, issue); + + const issueBefore = this.issues[newIndex - 1]; + if (issueBefore) moveAfterIid = issueBefore.id; + const issueAfter = this.issues[newIndex + 1]; + if (issueAfter) moveBeforeIid = issueAfter.id; } else { this.issues.push(issue); } @@ -123,7 +131,7 @@ class List { if (listFrom) { this.issuesSize += 1; - gl.boardService.moveIssue(issue.id, listFrom.id, this.id) + gl.boardService.moveIssue(issue.id, listFrom.id, this.id, moveAfterIid, moveBeforeIid) .then(() => { listFrom.getIssues(false); }); @@ -131,6 +139,21 @@ class List { } } + moveIssue (issue, oldIndex, newIndex) { + let moveBeforeIid = null; + let moveAfterIid = null; + + this.issues.splice(oldIndex, 1); + this.issues.splice(newIndex, 0, issue); + + const issueBefore = this.issues[newIndex - 1]; + if (issueBefore) moveAfterIid = issueBefore.id; + const issueAfter = this.issues[newIndex + 1]; + if (issueAfter) moveBeforeIid = issueAfter.id; + + gl.boardService.moveIssue(issue.id, null, null, moveAfterIid, moveBeforeIid); + } + findIssue (id) { return this.issues.filter(issue => issue.id === id)[0]; } |