Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/boards/models')
-rw-r--r--app/assets/javascripts/boards/models/issue.js39
-rw-r--r--app/assets/javascripts/boards/models/list.js66
2 files changed, 22 insertions, 83 deletions
diff --git a/app/assets/javascripts/boards/models/issue.js b/app/assets/javascripts/boards/models/issue.js
index 878f49cc6be..98eac35b2ed 100644
--- a/app/assets/javascripts/boards/models/issue.js
+++ b/app/assets/javascripts/boards/models/issue.js
@@ -30,56 +30,43 @@ class ListIssue {
}
addLabel(label) {
- if (!this.findLabel(label)) {
- this.labels.push(new ListLabel(label));
- }
+ boardsStore.addIssueLabel(this, label);
}
findLabel(findLabel) {
- return this.labels.find(label => label.id === findLabel.id);
+ return boardsStore.findIssueLabel(this, findLabel);
}
removeLabel(removeLabel) {
- if (removeLabel) {
- this.labels = this.labels.filter(label => removeLabel.id !== label.id);
- }
+ boardsStore.removeIssueLabel(this, removeLabel);
}
removeLabels(labels) {
- labels.forEach(this.removeLabel.bind(this));
+ boardsStore.removeIssueLabels(this, labels);
}
addAssignee(assignee) {
- if (!this.findAssignee(assignee)) {
- this.assignees.push(new ListAssignee(assignee));
- }
+ boardsStore.addIssueAssignee(this, assignee);
}
findAssignee(findAssignee) {
- return this.assignees.find(assignee => assignee.id === findAssignee.id);
+ return boardsStore.findIssueAssignee(this, findAssignee);
}
removeAssignee(removeAssignee) {
- if (removeAssignee) {
- this.assignees = this.assignees.filter(assignee => assignee.id !== removeAssignee.id);
- }
+ boardsStore.removeIssueAssignee(this, removeAssignee);
}
removeAllAssignees() {
- this.assignees = [];
+ boardsStore.removeAllIssueAssignees(this);
}
addMilestone(milestone) {
- const miletoneId = this.milestone ? this.milestone.id : null;
- if (IS_EE && milestone.id !== miletoneId) {
- this.milestone = new ListMilestone(milestone);
- }
+ boardsStore.addIssueMilestone(this, milestone);
}
removeMilestone(removeMilestone) {
- if (IS_EE && removeMilestone && removeMilestone.id === this.milestone.id) {
- this.milestone = {};
- }
+ boardsStore.removeIssueMilestone(this, removeMilestone);
}
getLists() {
@@ -87,15 +74,15 @@ class ListIssue {
}
updateData(newData) {
- Object.assign(this, newData);
+ boardsStore.updateIssueData(this, newData);
}
setFetchingState(key, value) {
- this.isFetching[key] = value;
+ boardsStore.setIssueFetchingState(this, key, value);
}
setLoadingState(key, value) {
- this.isLoading[key] = value;
+ boardsStore.setIssueLoadingState(this, key, value);
}
update() {
diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js
index 31c372b7a75..0bd606c6297 100644
--- a/app/assets/javascripts/boards/models/list.js
+++ b/app/assets/javascripts/boards/models/list.js
@@ -1,4 +1,4 @@
-/* eslint-disable no-underscore-dangle, class-methods-use-this, consistent-return */
+/* eslint-disable no-underscore-dangle, class-methods-use-this */
import ListIssue from 'ee_else_ce/boards/models/issue';
import { __ } from '~/locale';
@@ -8,8 +8,6 @@ import flash from '~/flash';
import boardsStore from '../stores/boards_store';
import ListMilestone from './milestone';
-const PER_PAGE = 20;
-
const TYPES = {
backlog: {
isPreset: true,
@@ -83,30 +81,15 @@ class List {
}
destroy() {
- const index = boardsStore.state.lists.indexOf(this);
- boardsStore.state.lists.splice(index, 1);
- boardsStore.updateNewListDropdown(this.id);
-
- boardsStore.destroyList(this.id).catch(() => {
- // TODO: handle request error
- });
+ boardsStore.destroy(this);
}
update() {
- const collapsed = !this.isExpanded;
- return boardsStore.updateList(this.id, this.position, collapsed).catch(() => {
- // TODO: handle request error
- });
+ return boardsStore.updateListFunc(this);
}
nextPage() {
- if (this.issuesSize > this.issues.length) {
- if (this.issues.length / PER_PAGE >= 1) {
- this.page += 1;
- }
-
- return this.getIssues(false);
- }
+ return boardsStore.goToNextPage(this);
}
getIssues(emptyIssues = true) {
@@ -114,13 +97,7 @@ class List {
}
newIssue(issue) {
- this.addIssue(issue, null, 0);
- this.issuesSize += 1;
-
- return boardsStore
- .newIssue(this.id, issue)
- .then(res => res.data)
- .then(data => this.onNewIssueResponse(issue, data));
+ return boardsStore.newListIssue(this, issue);
}
createIssues(data) {
@@ -138,12 +115,7 @@ class List {
}
moveIssue(issue, oldIndex, newIndex, moveBeforeId, moveAfterId) {
- this.issues.splice(oldIndex, 1);
- this.issues.splice(newIndex, 0, issue);
-
- boardsStore.moveIssue(issue.id, null, null, moveBeforeId, moveAfterId).catch(() => {
- // TODO: handle request error
- });
+ boardsStore.moveListIssues(this, issue, oldIndex, newIndex, moveBeforeId, moveAfterId);
}
moveMultipleIssues({ issues, oldIndicies, newIndex, moveBeforeId, moveAfterId }) {
@@ -182,35 +154,15 @@ class List {
}
findIssue(id) {
- return this.issues.find(issue => issue.id === id);
+ return boardsStore.findListIssue(this, id);
}
removeMultipleIssues(removeIssues) {
- const ids = removeIssues.map(issue => issue.id);
-
- this.issues = this.issues.filter(issue => {
- const matchesRemove = ids.includes(issue.id);
-
- if (matchesRemove) {
- this.issuesSize -= 1;
- issue.removeLabel(this.label);
- }
-
- return !matchesRemove;
- });
+ return boardsStore.removeListMultipleIssues(this, removeIssues);
}
removeIssue(removeIssue) {
- this.issues = this.issues.filter(issue => {
- const matchesRemove = removeIssue.id === issue.id;
-
- if (matchesRemove) {
- this.issuesSize -= 1;
- issue.removeLabel(this.label);
- }
-
- return !matchesRemove;
- });
+ return boardsStore.removeListIssues(this, removeIssue);
}
getTypeInfo(type) {