diff options
author | Idan Amit <ia096e@intl.att.com> | 2018-04-15 19:19:08 +0300 |
---|---|---|
committer | Idan Amit <ia096e@intl.att.com> | 2018-04-15 19:19:08 +0300 |
commit | 6187c942bedebeb2f452ed0856652f90cd5c5772 (patch) | |
tree | 9c3463873e34d9097f2119b9ed35900f6ecab733 /catalog-ui/src/app/view-models/workspace | |
parent | 821b76c6b81ebf96e8fd8340ac5f6ed79f8ed22a (diff) |
New observable notify design in pubsub
Implemented the new subscription mechanism for the pub sub notify function
Change-Id: I5e6484adf1a0413d48b54b55048cda1a59b387ee
Issue-ID: SDC-1178
Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/view-models/workspace')
-rw-r--r-- | catalog-ui/src/app/view-models/workspace/workspace-view-model.ts | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts index 5d83c34db8..7fa25177f5 100644 --- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts @@ -283,15 +283,14 @@ export class WorkspaceViewModel { version: this.$scope.changeVersion.selectedVersion.versionNumber }; - this.eventBusService.notify("VERSION_CHANGED", eventData); - - this.$state.go(this.$state.current.name, { - id: selectedId, - type: this.$scope.componentType.toLowerCase(), - mode: WorkspaceMode.VIEW, - components: this.$state.params['components'] - }, {reload: true}); - + this.eventBusService.notify("VERSION_CHANGED", eventData).subscribe(() => { + this.$state.go(this.$state.current.name, { + id: selectedId, + type: this.$scope.componentType.toLowerCase(), + mode: WorkspaceMode.VIEW, + components: this.$state.params['components'] + }, {reload: true}); + }); }; this.$scope.getLatestVersion = ():void => { @@ -472,36 +471,38 @@ export class WorkspaceViewModel { switch (url) { case 'lifecycleState/CHECKOUT': - // only checkOut get the full component from server - // this.$scope.component = component; - // Work around to change the csar version - if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { - (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG); - } - - //when checking out a minor version uuid remains - const bcIdx = _.findIndex(this.components, (item) => { - return item.uuid === component.uuid; - }); - if (bcIdx !== -1) { - this.components[bcIdx] = component; - } else { - //when checking out a major(certified) version - this.components.unshift(component); - } - // this.$state.go(this.$state.current.name, { - // id: component.uniqueId, - // type: component.componentType.toLowerCase(), - // components: this.components - // }); - this.$scope.mode = this.initViewMode(); - this.initChangeLifecycleStateButtons(); - this.initVersionObject(); - this.$scope.isLoading = false; - this.EventListenerService.notifyObservers(EVENTS.ON_CHECKOUT, component); - this.Notification.success({ - message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE") + this.eventBusService.notify("CHECK_OUT", eventData).subscribe(() => { + // only checkOut get the full component from server + // this.$scope.component = component; + // Work around to change the csar version + if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { + (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + } + + //when checking out a minor version uuid remains + const bcIdx = _.findIndex(this.components, (item) => { + return item.uuid === component.uuid; + }); + if (bcIdx !== -1) { + this.components[bcIdx] = component; + } else { + //when checking out a major(certified) version + this.components.unshift(component); + } + // this.$state.go(this.$state.current.name, { + // id: component.uniqueId, + // type: component.componentType.toLowerCase(), + // components: this.components + // }); + this.$scope.mode = this.initViewMode(); + this.initChangeLifecycleStateButtons(); + this.initVersionObject(); + this.$scope.isLoading = false; + this.EventListenerService.notifyObservers(EVENTS.ON_CHECKOUT, component); + this.Notification.success({ + message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE") + }); }); break; case 'lifecycleState/CHECKIN': @@ -512,7 +513,7 @@ export class WorkspaceViewModel { }); break; case 'lifecycleState/UNDOCHECKOUT': - setTimeout(() => { + this.eventBusService.notify("UNDO_CHECK_OUT", eventData).subscribe(() => { defaultActionAfterChangeLifecycleState(); this.Notification.success({ message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"), |