debian-mirror-gitlab/app/assets/javascripts/boards/models/issue.js

100 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-12-13 13:39:08 +05:30
/* eslint-disable no-unused-vars */
2017-08-17 22:00:37 +05:30
/* global ListLabel */
/* global ListMilestone */
/* global ListAssignee */
2019-12-04 20:38:33 +05:30
import axios from '~/lib/utils/axios_utils';
2019-09-04 21:01:54 +05:30
import './label';
2019-09-30 21:07:59 +05:30
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
2018-12-13 13:39:08 +05:30
import boardsStore from '../stores/boards_store';
2021-03-11 19:13:27 +05:30
import IssueProject from './project';
2017-08-17 22:00:37 +05:30
class ListIssue {
2020-04-08 14:13:33 +05:30
constructor(obj) {
2017-08-17 22:00:37 +05:30
this.subscribed = obj.subscribed;
this.labels = [];
this.assignees = [];
this.selected = false;
2020-11-24 15:15:51 +05:30
this.position = obj.position || obj.relative_position || obj.relativePosition || Infinity;
2018-03-17 18:26:18 +05:30
this.isFetching = {
subscriptions: true,
};
2020-04-08 14:13:33 +05:30
this.closed = obj.closed;
2018-03-17 18:26:18 +05:30
this.isLoading = {};
2019-12-04 20:38:33 +05:30
2020-04-08 14:13:33 +05:30
this.refreshData(obj);
2019-12-04 20:38:33 +05:30
}
2020-04-08 14:13:33 +05:30
refreshData(obj) {
boardsStore.refreshIssueData(this, obj);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
addLabel(label) {
2020-06-23 00:09:42 +05:30
boardsStore.addIssueLabel(this, label);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
findLabel(findLabel) {
2020-06-23 00:09:42 +05:30
return boardsStore.findIssueLabel(this, findLabel);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
removeLabel(removeLabel) {
2020-06-23 00:09:42 +05:30
boardsStore.removeIssueLabel(this, removeLabel);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
removeLabels(labels) {
2020-06-23 00:09:42 +05:30
boardsStore.removeIssueLabels(this, labels);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
addAssignee(assignee) {
2020-06-23 00:09:42 +05:30
boardsStore.addIssueAssignee(this, assignee);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
findAssignee(findAssignee) {
2020-06-23 00:09:42 +05:30
return boardsStore.findIssueAssignee(this, findAssignee);
2017-08-17 22:00:37 +05:30
}
2021-03-11 19:13:27 +05:30
setAssignees(assignees) {
boardsStore.setIssueAssignees(this, assignees);
}
2018-12-13 13:39:08 +05:30
removeAssignee(removeAssignee) {
2020-06-23 00:09:42 +05:30
boardsStore.removeIssueAssignee(this, removeAssignee);
2017-08-17 22:00:37 +05:30
}
2018-12-13 13:39:08 +05:30
removeAllAssignees() {
2020-06-23 00:09:42 +05:30
boardsStore.removeAllIssueAssignees(this);
2017-08-17 22:00:37 +05:30
}
2019-07-31 22:56:46 +05:30
addMilestone(milestone) {
2020-06-23 00:09:42 +05:30
boardsStore.addIssueMilestone(this, milestone);
2019-07-31 22:56:46 +05:30
}
removeMilestone(removeMilestone) {
2020-06-23 00:09:42 +05:30
boardsStore.removeIssueMilestone(this, removeMilestone);
2019-07-31 22:56:46 +05:30
}
2018-12-13 13:39:08 +05:30
getLists() {
2021-03-08 18:12:59 +05:30
return boardsStore.state.lists.filter((list) => list.findIssue(this.id));
2017-08-17 22:00:37 +05:30
}
2018-03-17 18:26:18 +05:30
updateData(newData) {
2020-06-23 00:09:42 +05:30
boardsStore.updateIssueData(this, newData);
2018-03-17 18:26:18 +05:30
}
setFetchingState(key, value) {
2020-06-23 00:09:42 +05:30
boardsStore.setIssueFetchingState(this, key, value);
2018-03-17 18:26:18 +05:30
}
setLoadingState(key, value) {
2020-06-23 00:09:42 +05:30
boardsStore.setIssueLoadingState(this, key, value);
2018-03-17 18:26:18 +05:30
}
2018-12-13 13:39:08 +05:30
update() {
2020-05-24 23:13:21 +05:30
return boardsStore.updateIssue(this);
2017-08-17 22:00:37 +05:30
}
}
window.ListIssue = ListIssue;
2018-03-27 19:54:05 +05:30
export default ListIssue;