diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-12-03 20:43:10 -0600 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-12-04 15:02:48 -0600 |
commit | f3433d8a6801d369752526c1d92a35048e263e20 (patch) | |
tree | 93f2017d1cf885ff52969c13bede20fc96b4ec32 /app/assets/javascripts/sidebar/sidebar_mediator.js | |
parent | e0f84130567dc34edf1ae75fcf595e24991d2fa9 (diff) | |
download | gitlab-ce-f3433d8a6801d369752526c1d92a35048e263e20.tar.gz |
Backport changes from refactor sidebar weight block Vue and move to Issue Boardsce-1379-update-sidebar-weight-to-vue-and-add-to-boards
See https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/3566
Diffstat (limited to 'app/assets/javascripts/sidebar/sidebar_mediator.js')
-rw-r--r-- | app/assets/javascripts/sidebar/sidebar_mediator.js | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/app/assets/javascripts/sidebar/sidebar_mediator.js b/app/assets/javascripts/sidebar/sidebar_mediator.js index 2bda5a47791..d4c07a188b3 100644 --- a/app/assets/javascripts/sidebar/sidebar_mediator.js +++ b/app/assets/javascripts/sidebar/sidebar_mediator.js @@ -5,19 +5,23 @@ import Store from './stores/sidebar_store'; export default class SidebarMediator { constructor(options) { if (!SidebarMediator.singleton) { - this.store = new Store(options); - this.service = new Service({ - endpoint: options.endpoint, - toggleSubscriptionEndpoint: options.toggleSubscriptionEndpoint, - moveIssueEndpoint: options.moveIssueEndpoint, - projectsAutocompleteEndpoint: options.projectsAutocompleteEndpoint, - }); - SidebarMediator.singleton = this; + this.initSingleton(options); } return SidebarMediator.singleton; } + initSingleton(options) { + this.store = new Store(options); + this.service = new Service({ + endpoint: options.endpoint, + toggleSubscriptionEndpoint: options.toggleSubscriptionEndpoint, + moveIssueEndpoint: options.moveIssueEndpoint, + projectsAutocompleteEndpoint: options.projectsAutocompleteEndpoint, + }); + SidebarMediator.singleton = this; + } + assignYourself() { this.store.addAssignee(this.store.currentUser); } @@ -35,17 +39,21 @@ export default class SidebarMediator { } fetch() { - this.service.get() + return this.service.get() .then(response => response.json()) .then((data) => { - this.store.setAssigneeData(data); - this.store.setTimeTrackingData(data); - this.store.setParticipantsData(data); - this.store.setSubscriptionsData(data); + this.processFetchedData(data); }) .catch(() => new Flash('Error occurred when fetching sidebar data')); } + processFetchedData(data) { + this.store.setAssigneeData(data); + this.store.setTimeTrackingData(data); + this.store.setParticipantsData(data); + this.store.setSubscriptionsData(data); + } + toggleSubscription() { this.store.setFetchingState('subscriptions', true); return this.service.toggleSubscription() |