Web Console: Fixed "Import models" dialog cleanup on exit logic.
*/
export default class ModalImportModels {
- static $inject = ['$modal', 'AgentManager', '$uiRouter'];
- constructor($modal, AgentManager, $uiRouter) {
- Object.assign(this, {$modal, AgentManager, $uiRouter});
+ static $inject = ['$modal', '$uiRouter', 'AgentManager'];
+
+ constructor($modal, $uiRouter, AgentManager) {
+ this.$modal = $modal;
+ this.$uiRouter = $uiRouter;
+ this.AgentManager = AgentManager;
}
+
_goToDynamicState() {
- if (this._state) this.$uiRouter.stateRegistry.deregister(this._state);
+ if (this._state)
+ this.$uiRouter.stateRegistry.deregister(this._state);
+
this._state = this.$uiRouter.stateRegistry.register({
name: 'importModels',
parent: this.$uiRouter.stateService.current,
@@ -29,11 +35,15 @@ export default class ModalImportModels {
this._open();
},
onExit: () => {
+ this.AgentManager.stopWatch();
+
this._modal && this._modal.hide();
}
});
+
return this.$uiRouter.stateService.go(this._state, this.$uiRouter.stateService.params);
}
+
_open() {
this._modal = this.$modal({
template: `
@@ -46,10 +56,12 @@ export default class ModalImportModels {
controllerAs: '$ctrl',
show: false
});
+
return this.AgentManager.startAgentWatch('Back', this.$uiRouter.globals.current.name)
.then(() => this._modal.$promise)
.then(() => this._modal.show());
}
+
open() {
this._goToDynamicState();
}
