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/boards_util.js')
-rw-r--r--app/assets/javascripts/boards/boards_util.js64
1 files changed, 54 insertions, 10 deletions
diff --git a/app/assets/javascripts/boards/boards_util.js b/app/assets/javascripts/boards/boards_util.js
index 384a386d69c..5c8df94ca90 100644
--- a/app/assets/javascripts/boards/boards_util.js
+++ b/app/assets/javascripts/boards/boards_util.js
@@ -1,28 +1,72 @@
+import { sortBy } from 'lodash';
import ListIssue from 'ee_else_ce/boards/models/issue';
+import { ListType } from './constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
export function getMilestone() {
return null;
}
+export function formatIssue(issue) {
+ return new ListIssue({
+ ...issue,
+ labels: issue.labels?.nodes || [],
+ assignees: issue.assignees?.nodes || [],
+ });
+}
+
export function formatListIssues(listIssues) {
- return listIssues.nodes.reduce((map, list) => {
+ const issues = {};
+
+ const listData = listIssues.nodes.reduce((map, list) => {
+ const sortedIssues = sortBy(list.issues.nodes, 'relativePosition');
return {
...map,
- [list.id]: list.issues.nodes.map(
- i =>
- new ListIssue({
- ...i,
- id: getIdFromGraphQLId(i.id),
- labels: i.labels?.nodes || [],
- assignees: i.assignees?.nodes || [],
- }),
- ),
+ [list.id]: sortedIssues.map(i => {
+ const id = getIdFromGraphQLId(i.id);
+
+ const listIssue = new ListIssue({
+ ...i,
+ id,
+ labels: i.labels?.nodes || [],
+ assignees: i.assignees?.nodes || [],
+ });
+
+ issues[id] = listIssue;
+
+ return id;
+ }),
};
}, {});
+
+ return { listData, issues };
+}
+
+export function fullBoardId(boardId) {
+ return `gid://gitlab/Board/${boardId}`;
+}
+
+export function moveIssueListHelper(issue, fromList, toList) {
+ if (toList.type === ListType.label) {
+ issue.addLabel(toList.label);
+ }
+ if (fromList && fromList.type === ListType.label) {
+ issue.removeLabel(fromList.label);
+ }
+
+ if (toList.type === ListType.assignee) {
+ issue.addAssignee(toList.assignee);
+ }
+ if (fromList && fromList.type === ListType.assignee) {
+ issue.removeAssignee(fromList.assignee);
+ }
+
+ return issue;
}
export default {
getMilestone,
+ formatIssue,
formatListIssues,
+ fullBoardId,
};