gitlab-org--gitlab-foss/app/assets/javascripts/boards/models/issue.js

100 lines
2.2 KiB
JavaScript
Raw Normal View History

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