2017-05-04 12:11:15 +00:00
|
|
|
export default class SidebarStore {
|
2017-12-07 17:37:33 +00:00
|
|
|
constructor(options) {
|
2017-05-04 12:11:15 +00:00
|
|
|
if (!SidebarStore.singleton) {
|
2017-12-07 17:37:33 +00:00
|
|
|
this.initSingleton(options);
|
2017-05-04 12:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return SidebarStore.singleton;
|
|
|
|
}
|
|
|
|
|
2017-12-07 17:37:33 +00:00
|
|
|
initSingleton(options) {
|
2019-06-11 10:40:01 +00:00
|
|
|
const { currentUser, rootPath, editable, timeTrackingLimitToHours } = options;
|
2017-12-07 17:37:33 +00:00
|
|
|
this.currentUser = currentUser;
|
|
|
|
this.rootPath = rootPath;
|
|
|
|
this.editable = editable;
|
|
|
|
this.timeEstimate = 0;
|
|
|
|
this.totalTimeSpent = 0;
|
|
|
|
this.humanTimeEstimate = '';
|
|
|
|
this.humanTimeSpent = '';
|
2019-06-11 10:40:01 +00:00
|
|
|
this.timeTrackingLimitToHours = timeTrackingLimitToHours;
|
2017-12-07 17:37:33 +00:00
|
|
|
this.assignees = [];
|
2020-09-29 09:09:49 +00:00
|
|
|
this.reviewers = [];
|
2017-12-07 17:37:33 +00:00
|
|
|
this.isFetching = {
|
|
|
|
assignees: true,
|
2020-09-29 09:09:49 +00:00
|
|
|
reviewers: true,
|
2017-12-07 17:37:33 +00:00
|
|
|
participants: true,
|
|
|
|
subscriptions: true,
|
|
|
|
};
|
|
|
|
this.isLoading = {};
|
|
|
|
this.autocompleteProjects = [];
|
|
|
|
this.moveToProjectId = 0;
|
|
|
|
this.isLockDialogOpen = false;
|
|
|
|
this.participants = [];
|
2019-11-18 12:06:03 +00:00
|
|
|
this.projectEmailsDisabled = false;
|
|
|
|
this.subscribeDisabledDescription = '';
|
2017-12-07 17:37:33 +00:00
|
|
|
this.subscribed = null;
|
2020-10-14 12:08:58 +00:00
|
|
|
this.changing = false;
|
2017-12-07 17:37:33 +00:00
|
|
|
|
|
|
|
SidebarStore.singleton = this;
|
|
|
|
}
|
|
|
|
|
2020-10-08 09:08:40 +00:00
|
|
|
setAssigneeData({ assignees }) {
|
2017-05-17 09:50:40 +00:00
|
|
|
this.isFetching.assignees = false;
|
2020-10-08 09:08:40 +00:00
|
|
|
if (assignees) {
|
|
|
|
this.assignees = assignees;
|
2017-05-04 12:11:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 09:08:40 +00:00
|
|
|
setReviewerData({ reviewers }) {
|
2020-09-29 09:09:49 +00:00
|
|
|
this.isFetching.reviewers = false;
|
2020-10-08 09:08:40 +00:00
|
|
|
if (reviewers) {
|
|
|
|
this.reviewers = reviewers;
|
2020-09-29 09:09:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
resetChanging() {
|
|
|
|
this.changing = false;
|
|
|
|
}
|
|
|
|
|
2017-05-05 18:23:31 +00:00
|
|
|
setTimeTrackingData(data) {
|
2017-05-04 12:11:15 +00:00
|
|
|
this.timeEstimate = data.time_estimate;
|
|
|
|
this.totalTimeSpent = data.total_time_spent;
|
|
|
|
this.humanTimeEstimate = data.human_time_estimate;
|
|
|
|
this.humanTotalTimeSpent = data.human_total_time_spent;
|
|
|
|
}
|
|
|
|
|
2017-10-31 16:15:03 +00:00
|
|
|
setParticipantsData(data) {
|
|
|
|
this.isFetching.participants = false;
|
|
|
|
this.participants = data.participants || [];
|
|
|
|
}
|
|
|
|
|
|
|
|
setSubscriptionsData(data) {
|
2019-11-18 12:06:03 +00:00
|
|
|
this.projectEmailsDisabled = data.project_emails_disabled || false;
|
|
|
|
this.subscribeDisabledDescription = data.subscribe_disabled_description;
|
2017-10-31 16:15:03 +00:00
|
|
|
this.isFetching.subscriptions = false;
|
|
|
|
this.subscribed = data.subscribed || false;
|
|
|
|
}
|
|
|
|
|
|
|
|
setFetchingState(key, value) {
|
|
|
|
this.isFetching[key] = value;
|
|
|
|
}
|
|
|
|
|
2017-12-04 02:43:10 +00:00
|
|
|
setLoadingState(key, value) {
|
|
|
|
this.isLoading[key] = value;
|
|
|
|
}
|
|
|
|
|
2017-05-04 12:11:15 +00:00
|
|
|
addAssignee(assignee) {
|
|
|
|
if (!this.findAssignee(assignee)) {
|
2020-10-14 12:08:58 +00:00
|
|
|
this.changing = true;
|
2017-05-04 12:11:15 +00:00
|
|
|
this.assignees.push(assignee);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
addReviewer(reviewer) {
|
|
|
|
if (!this.findReviewer(reviewer)) {
|
|
|
|
this.reviewers.push(reviewer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 12:11:15 +00:00
|
|
|
findAssignee(findAssignee) {
|
2020-10-08 09:08:40 +00:00
|
|
|
return this.assignees.find(({ id }) => id === findAssignee.id);
|
2017-05-04 12:11:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
findReviewer(findReviewer) {
|
2020-10-08 09:08:40 +00:00
|
|
|
return this.reviewers.find(({ id }) => id === findReviewer.id);
|
2020-09-29 09:09:49 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 09:08:40 +00:00
|
|
|
removeAssignee(assignee) {
|
|
|
|
if (assignee) {
|
2020-10-14 12:08:58 +00:00
|
|
|
this.changing = true;
|
2020-10-08 09:08:40 +00:00
|
|
|
this.assignees = this.assignees.filter(({ id }) => id !== assignee.id);
|
2017-05-04 12:11:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 09:08:40 +00:00
|
|
|
removeReviewer(reviewer) {
|
|
|
|
if (reviewer) {
|
|
|
|
this.reviewers = this.reviewers.filter(({ id }) => id !== reviewer.id);
|
2020-09-29 09:09:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 12:11:15 +00:00
|
|
|
removeAllAssignees() {
|
2020-10-14 12:08:58 +00:00
|
|
|
this.changing = true;
|
2017-05-04 12:11:15 +00:00
|
|
|
this.assignees = [];
|
|
|
|
}
|
2017-08-14 07:26:19 +00:00
|
|
|
|
2020-09-29 09:09:49 +00:00
|
|
|
removeAllReviewers() {
|
|
|
|
this.reviewers = [];
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:09:46 +00:00
|
|
|
setAssigneesFromRealtime(data) {
|
|
|
|
this.assignees = data;
|
|
|
|
}
|
|
|
|
|
2017-08-14 07:26:19 +00:00
|
|
|
setAutocompleteProjects(projects) {
|
|
|
|
this.autocompleteProjects = projects;
|
|
|
|
}
|
|
|
|
|
2017-10-31 16:15:03 +00:00
|
|
|
setSubscribedState(subscribed) {
|
|
|
|
this.subscribed = subscribed;
|
|
|
|
}
|
|
|
|
|
2017-08-14 07:26:19 +00:00
|
|
|
setMoveToProjectId(moveToProjectId) {
|
|
|
|
this.moveToProjectId = moveToProjectId;
|
|
|
|
}
|
2017-05-04 12:11:15 +00:00
|
|
|
}
|