2017-05-04 12:11:15 +00:00
|
|
|
export default class SidebarStore {
|
|
|
|
constructor(store) {
|
|
|
|
if (!SidebarStore.singleton) {
|
|
|
|
const { currentUser, rootPath, editable } = store;
|
|
|
|
this.currentUser = currentUser;
|
|
|
|
this.rootPath = rootPath;
|
|
|
|
this.editable = editable;
|
|
|
|
this.timeEstimate = 0;
|
|
|
|
this.totalTimeSpent = 0;
|
|
|
|
this.humanTimeEstimate = '';
|
|
|
|
this.humanTimeSpent = '';
|
|
|
|
this.assignees = [];
|
2017-05-17 09:50:40 +00:00
|
|
|
this.isFetching = {
|
|
|
|
assignees: true,
|
|
|
|
};
|
2017-05-04 12:11:15 +00:00
|
|
|
|
|
|
|
SidebarStore.singleton = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SidebarStore.singleton;
|
|
|
|
}
|
|
|
|
|
2017-05-05 18:23:31 +00:00
|
|
|
setAssigneeData(data) {
|
2017-05-17 09:50:40 +00:00
|
|
|
this.isFetching.assignees = false;
|
2017-05-04 12:11:15 +00:00
|
|
|
if (data.assignees) {
|
|
|
|
this.assignees = data.assignees;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
addAssignee(assignee) {
|
|
|
|
if (!this.findAssignee(assignee)) {
|
|
|
|
this.assignees.push(assignee);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
findAssignee(findAssignee) {
|
|
|
|
return this.assignees.filter(assignee => assignee.id === findAssignee.id)[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
removeAssignee(removeAssignee) {
|
|
|
|
if (removeAssignee) {
|
|
|
|
this.assignees = this.assignees.filter(assignee => assignee.id !== removeAssignee.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
removeAllAssignees() {
|
|
|
|
this.assignees = [];
|
|
|
|
}
|
|
|
|
}
|