diff options
Diffstat (limited to 'app/assets/javascripts/sidebar/stores/sidebar_store.js')
-rw-r--r-- | app/assets/javascripts/sidebar/stores/sidebar_store.js | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/app/assets/javascripts/sidebar/stores/sidebar_store.js b/app/assets/javascripts/sidebar/stores/sidebar_store.js index 095f93b72a9..d53393052eb 100644 --- a/app/assets/javascripts/sidebar/stores/sidebar_store.js +++ b/app/assets/javascripts/sidebar/stores/sidebar_store.js @@ -18,8 +18,10 @@ export default class SidebarStore { this.humanTimeSpent = ''; this.timeTrackingLimitToHours = timeTrackingLimitToHours; this.assignees = []; + this.reviewers = []; this.isFetching = { assignees: true, + reviewers: true, participants: true, subscriptions: true, }; @@ -31,17 +33,29 @@ export default class SidebarStore { this.projectEmailsDisabled = false; this.subscribeDisabledDescription = ''; this.subscribed = null; + this.changing = false; SidebarStore.singleton = this; } - setAssigneeData(data) { + setAssigneeData({ assignees }) { this.isFetching.assignees = false; - if (data.assignees) { - this.assignees = data.assignees; + if (assignees) { + this.assignees = assignees; } } + setReviewerData({ reviewers }) { + this.isFetching.reviewers = false; + if (reviewers) { + this.reviewers = reviewers; + } + } + + resetChanging() { + this.changing = false; + } + setTimeTrackingData(data) { this.timeEstimate = data.time_estimate; this.totalTimeSpent = data.total_time_spent; @@ -71,24 +85,47 @@ export default class SidebarStore { addAssignee(assignee) { if (!this.findAssignee(assignee)) { + this.changing = true; this.assignees.push(assignee); } } + addReviewer(reviewer) { + if (!this.findReviewer(reviewer)) { + this.reviewers.push(reviewer); + } + } + findAssignee(findAssignee) { - return this.assignees.find(assignee => assignee.id === findAssignee.id); + return this.assignees.find(({ id }) => id === findAssignee.id); } - removeAssignee(removeAssignee) { - if (removeAssignee) { - this.assignees = this.assignees.filter(assignee => assignee.id !== removeAssignee.id); + findReviewer(findReviewer) { + return this.reviewers.find(({ id }) => id === findReviewer.id); + } + + removeAssignee(assignee) { + if (assignee) { + this.changing = true; + this.assignees = this.assignees.filter(({ id }) => id !== assignee.id); + } + } + + removeReviewer(reviewer) { + if (reviewer) { + this.reviewers = this.reviewers.filter(({ id }) => id !== reviewer.id); } } removeAllAssignees() { + this.changing = true; this.assignees = []; } + removeAllReviewers() { + this.reviewers = []; + } + setAssigneesFromRealtime(data) { this.assignees = data; } |