Commit 6bfe46fe authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'Remove-addMultipleIssues-function-logic-from-list.js' into 'master'

Remove addMultipleIssues function logic from list model

See merge request gitlab-org/gitlab!21404
parents 1fe4fdc9 ece8b1eb
...@@ -161,50 +161,7 @@ class List { ...@@ -161,50 +161,7 @@ class List {
} }
addMultipleIssues(issues, listFrom, newIndex) { addMultipleIssues(issues, listFrom, newIndex) {
let moveBeforeId = null; boardsStore.addMultipleListIssues(this, issues, listFrom, newIndex);
let moveAfterId = null;
const listHasIssues = issues.every(issue => this.findIssue(issue.id));
if (!listHasIssues) {
if (newIndex !== undefined) {
if (this.issues[newIndex - 1]) {
moveBeforeId = this.issues[newIndex - 1].id;
}
if (this.issues[newIndex]) {
moveAfterId = this.issues[newIndex].id;
}
this.issues.splice(newIndex, 0, ...issues);
} else {
this.issues.push(...issues);
}
if (this.label) {
issues.forEach(issue => issue.addLabel(this.label));
}
if (this.assignee) {
if (listFrom && listFrom.type === 'assignee') {
issues.forEach(issue => issue.removeAssignee(listFrom.assignee));
}
issues.forEach(issue => issue.addAssignee(this.assignee));
}
if (IS_EE && this.milestone) {
if (listFrom && listFrom.type === 'milestone') {
issues.forEach(issue => issue.removeMilestone(listFrom.milestone));
}
issues.forEach(issue => issue.addMilestone(this.milestone));
}
if (listFrom) {
this.issuesSize += issues.length;
this.updateMultipleIssues(issues, listFrom, moveBeforeId, moveAfterId);
}
}
} }
addIssue(issue, listFrom, newIndex) { addIssue(issue, listFrom, newIndex) {
......
...@@ -131,6 +131,53 @@ const boardsStore = { ...@@ -131,6 +131,53 @@ const boardsStore = {
listFrom.update(); listFrom.update();
}, },
addMultipleListIssues(list, issues, listFrom, newIndex) {
let moveBeforeId = null;
let moveAfterId = null;
const listHasIssues = issues.every(issue => list.findIssue(issue.id));
if (!listHasIssues) {
if (newIndex !== undefined) {
if (list.issues[newIndex - 1]) {
moveBeforeId = list.issues[newIndex - 1].id;
}
if (list.issues[newIndex]) {
moveAfterId = list.issues[newIndex].id;
}
list.issues.splice(newIndex, 0, ...issues);
} else {
list.issues.push(...issues);
}
if (list.label) {
issues.forEach(issue => issue.addLabel(list.label));
}
if (list.assignee) {
if (listFrom && listFrom.type === 'assignee') {
issues.forEach(issue => issue.removeAssignee(listFrom.assignee));
}
issues.forEach(issue => issue.addAssignee(list.assignee));
}
if (IS_EE && list.milestone) {
if (listFrom && listFrom.type === 'milestone') {
issues.forEach(issue => issue.removeMilestone(listFrom.milestone));
}
issues.forEach(issue => issue.addMilestone(list.milestone));
}
if (listFrom) {
list.issuesSize += issues.length;
list.updateMultipleIssues(issues, listFrom, moveBeforeId, moveAfterId);
}
}
},
startMoving(list, issue) { startMoving(list, issue) {
Object.assign(this.moving, { list, issue }); Object.assign(this.moving, { list, issue });
}, },
......
---
title: removes store logic from issue board models
merge_request: 21404
author: nuwe1
type: other
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment