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