diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-13 16:33:19 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-13 16:33:19 +0100 |
commit | c922b846fee750dae855b1811d83e27f95b6dcec (patch) | |
tree | 03cb3cbbc39800de8da2787e583cd06a5f9cdbbc | |
parent | d7a527163b64fa38e46fc6195fef2f5d93e47d07 (diff) | |
download | gitlab-ce-c922b846fee750dae855b1811d83e27f95b6dcec.tar.gz |
Only increase the page number for boards when we need to
Closes #30902
-rw-r--r-- | app/assets/javascripts/boards/models/list.js | 9 | ||||
-rw-r--r-- | spec/javascripts/boards/list_spec.js | 40 |
2 files changed, 44 insertions, 5 deletions
diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js index 91e5fb2a666..d83006ebe1a 100644 --- a/app/assets/javascripts/boards/models/list.js +++ b/app/assets/javascripts/boards/models/list.js @@ -58,7 +58,9 @@ class List { nextPage () { if (this.issuesSize > this.issues.length) { - this.page += 1; + if (this.issues.length / 20 >= 1) { + this.page += 1; + } return this.getIssues(false); } @@ -145,10 +147,7 @@ class List { } updateIssueLabel(issue, listFrom, moveBeforeIid, moveAfterIid) { - gl.boardService.moveIssue(issue.id, listFrom.id, this.id, moveBeforeIid, moveAfterIid) - .then(() => { - listFrom.getIssues(false); - }); + gl.boardService.moveIssue(issue.id, listFrom.id, this.id, moveBeforeIid, moveAfterIid); } findIssue (id) { diff --git a/spec/javascripts/boards/list_spec.js b/spec/javascripts/boards/list_spec.js index a9d4c6ef76f..7c88a362fd2 100644 --- a/spec/javascripts/boards/list_spec.js +++ b/spec/javascripts/boards/list_spec.js @@ -107,4 +107,44 @@ describe('List model', () => { expect(gl.boardService.moveIssue) .toHaveBeenCalledWith(issue.id, list.id, listDup.id, undefined, undefined); }); + + describe('page number', () => { + beforeEach(() => { + spyOn(list, 'getIssues'); + }); + + it('increase page number if current issue count is more than the page size', () => { + for (let i = 0; i < 30; i+=1) { + list.issues.push(new ListIssue({ + title: 'Testing', + iid: _.random(10000) + i, + confidential: false, + labels: [list.label] + })); + } + list.issuesSize = 50; + + expect(list.issues.length).toBe(30); + + list.nextPage(); + + expect(list.page).toBe(2); + expect(list.getIssues).toHaveBeenCalled(); + }); + + it('does not increase page number if issue count is less than the page size', () => { + list.issues.push(new ListIssue({ + title: 'Testing', + iid: _.random(10000), + confidential: false, + labels: [list.label] + })); + list.issuesSize = 2; + + list.nextPage(); + + expect(list.page).toBe(1); + expect(list.getIssues).toHaveBeenCalled(); + }); + }); }); |