diff options
author | Phil Hughes <me@iamphill.com> | 2017-02-07 11:56:33 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-02-17 14:29:16 +0300 |
commit | c032414b2d7b6ba75c3b202fe8791e32a0eb09e1 (patch) | |
tree | d2ca7a932e0d42551052efe271a9f1251108559e /app/assets/javascripts/boards/models | |
parent | be7d978a6a971764bec10539dbf3d4e3c63c2f2d (diff) |
Frontend updates to positioning the issue in lists
Diffstat (limited to 'app/assets/javascripts/boards/models')
-rw-r--r-- | app/assets/javascripts/boards/models/issue.js.es6 | 5 | ||||
-rw-r--r-- | app/assets/javascripts/boards/models/list.js.es6 | 27 |
2 files changed, 8 insertions, 24 deletions
diff --git a/app/assets/javascripts/boards/models/issue.js.es6 b/app/assets/javascripts/boards/models/issue.js.es6 index 2d0a295ae4d..ca5e6fa7e9d 100644 --- a/app/assets/javascripts/boards/models/issue.js.es6 +++ b/app/assets/javascripts/boards/models/issue.js.es6 @@ -15,6 +15,7 @@ class ListIssue { this.labels = []; this.selected = false; this.assignee = false; + this.position = obj.relative_position || Infinity; if (obj.assignee) { this.assignee = new ListUser(obj.assignee); @@ -27,10 +28,6 @@ class ListIssue { obj.labels.forEach((label) => { this.labels.push(new ListLabel(label)); }); - - this.priority = this.labels.reduce((max, label) => { - return (label.priority < max) ? label.priority : max; - }, Infinity); } addLabel (label) { diff --git a/app/assets/javascripts/boards/models/list.js.es6 b/app/assets/javascripts/boards/models/list.js.es6 index 4f7745e6e8d..a07fac380f7 100644 --- a/app/assets/javascripts/boards/models/list.js.es6 +++ b/app/assets/javascripts/boards/models/list.js.es6 @@ -110,17 +110,15 @@ class List { } addIssue (issue, listFrom, newIndex) { - if (!this.findIssue(issue.id)) { - let moveBeforeIid = null; - let moveAfterIid = null; + let moveBeforeIid; + let moveAfterIid; - if (newIndex !== undefined) { + if (!this.findIssue(issue.id)) { + if (newIndex) { 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; + moveBeforeIid = this.issues[newIndex - 1].id || null; + moveAfterIid = this.issues[newIndex + 1].id || null; } else { this.issues.push(issue); } @@ -139,18 +137,7 @@ 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; - + moveIssue (issue, moveBeforeIid, moveAfterIid) { gl.boardService.moveIssue(issue.id, null, null, moveAfterIid, moveBeforeIid); } |