diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-08 11:18:38 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-17 17:12:47 +0100 |
commit | ff5fd4eb014623927b743f67ed56be5845d42ff6 (patch) | |
tree | e4510a920f43af9bdc402b98be06968c5e00974c | |
parent | 1de6467571c53778a448e10793e4aa17b2f18e5b (diff) | |
download | gitlab-ce-ff5fd4eb014623927b743f67ed56be5845d42ff6.tar.gz |
Moved some code over to underscorejs
5 files changed, 26 insertions, 30 deletions
diff --git a/app/assets/javascripts/boards/components/board_list.js.es6 b/app/assets/javascripts/boards/components/board_list.js.es6 index df64d57b5c3..ab7f6e5f00d 100644 --- a/app/assets/javascripts/boards/components/board_list.js.es6 +++ b/app/assets/javascripts/boards/components/board_list.js.es6 @@ -35,10 +35,11 @@ }, }, ready: function () { + const list = this.list; const options = _.extend({ group: 'issues', disabled: this.disabled, - onAdd: function (e) { + onAdd: (e) => { const fromListId = parseInt(e.from.getAttribute('data-board')), toListId = parseInt(e.to.getAttribute('data-board')), issueId = parseInt(e.item.getAttribute('data-issue')); diff --git a/app/assets/javascripts/boards/models/issue.js.es6 b/app/assets/javascripts/boards/models/issue.js.es6 index 49469c488d2..a1940cab91c 100644 --- a/app/assets/javascripts/boards/models/issue.js.es6 +++ b/app/assets/javascripts/boards/models/issue.js.es6 @@ -39,9 +39,7 @@ class Issue { } removeLabels (labels) { - labels.forEach((label) => { - this.removeLabel(label); - }); + _.each(labels, this.removeLabel.bind(this)); } getLists () { diff --git a/app/assets/javascripts/boards/models/list.js.es6 b/app/assets/javascripts/boards/models/list.js.es6 index 7403fef2303..c2b06e4ed73 100644 --- a/app/assets/javascripts/boards/models/list.js.es6 +++ b/app/assets/javascripts/boards/models/list.js.es6 @@ -19,7 +19,7 @@ class List { } save () { - gl.boardService.createList(this.label.id) + return gl.boardService.createList(this.label.id) .then((resp) => { const data = resp.json(); @@ -27,7 +27,7 @@ class List { this.type = data.list_type; this.position = data.position; - this.getIssues(); + return this.getIssues(); }); } @@ -80,7 +80,7 @@ class List { } createIssues (data) { - data.forEach((issue) => { + _.each(data, (issue) => { this.issues.push(new Issue(issue)); }); } diff --git a/app/assets/javascripts/boards/stores/boards_store.js.es6 b/app/assets/javascripts/boards/stores/boards_store.js.es6 index e9455ccd267..e700fb4281d 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js.es6 +++ b/app/assets/javascripts/boards/stores/boards_store.js.es6 @@ -12,12 +12,19 @@ }; }, new: function (board, persist = true) { - const doneList = this.getDoneList(), + const doneList = this.findList('type', 'done'), + backlogList = this.findList('type', 'backlog'), list = new List(board); this.state.lists.push(list); if (persist) { - list.save(); + list + .save() + .then(function () { + // Remove any new issues from the backlog + // as they will be visible in the new list + _.each(list.issues, backlogList.removeIssue.bind(backlogList)); + }); this.removeBlankState(); } @@ -29,15 +36,10 @@ }, shouldAddBlankState: function () { // Decide whether to add the blank state - let addBlankState = true; - - this.state.lists.forEach(function (list) { - if (list.type !== 'backlog' && list.type !== 'done') { - addBlankState = false; - return; - } + let addBlankState = _.find(this.state.lists, function (list) { + return list.type === 'backlog' || list.type === 'done'; }); - return addBlankState; + return !addBlankState; }, addBlankState: function () { const addBlankState = this.shouldAddBlankState(); @@ -65,9 +67,6 @@ welcomeIsHidden: function () { return $.cookie('issue_board_welcome_hidden') === 'true'; }, - getDoneList: function () { - return this.findList('type', 'done'); - }, removeList: function (id) { const list = this.findList('id', id); @@ -75,7 +74,7 @@ list.destroy(); - this.state.lists = _.reject(this.state.lists, (list) => { + this.state.lists = _.reject(this.state.lists, function (list) { return list.id === id; }); @@ -83,7 +82,7 @@ }, moveList: function (oldIndex, newIndex) { if (oldIndex === newIndex) return; - + const listFrom = this.findList('position', oldIndex), listTo = this.findList('position', newIndex); @@ -101,9 +100,9 @@ moveCardToList: function (listFromId, listToId, issueId) { const listFrom = this.findList('id', listFromId), listTo = this.findList('id', listToId), - issueTo = listTo.findIssue(issueId); - let issue = listFrom.findIssue(issueId); - const issueLists = issue.getLists(), + issueTo = listTo.findIssue(issueId), + issue = listFrom.findIssue(issueId), + issueLists = issue.getLists(), listLabels = issueLists.map(function (issue) { return issue.label; }); @@ -114,9 +113,7 @@ } if (listTo.type === 'done' && listFrom.type !== 'backlog') { - issueLists.forEach((list) => { - list.removeIssue(issue); - }); + _.each(issueLists, list.removeIssue.bind(list)); issue.removeLabels(listLabels); } else { listFrom.removeIssue(issue); diff --git a/app/assets/stylesheets/pages/boards.scss b/app/assets/stylesheets/pages/boards.scss index c3b71a81fec..1af91f001b5 100644 --- a/app/assets/stylesheets/pages/boards.scss +++ b/app/assets/stylesheets/pages/boards.scss @@ -84,8 +84,8 @@ overflow-x: scroll; @media (min-width: $screen-sm-min) { - min-height: 470px; - max-height: 470px; + min-height: 475px; + max-height: 475px; } } |