Commit 7a5f37d2 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Destruye módulos globales al salir de App

Una vez dentro de la aplicación, si el usuario vuelve a la página de
login y vuelve a entrar, se crea de nuevo todo App, repitiendo módulos.
Ahora se limpia en el momento en que se oculta App, de manera que la
próxima vez ya no existirán instancias antiguas.
Además, esto evita que módulos importantes, como RestManager, repitan
sus tareas tantas veces como instancias se hayan creado.
parent 3b64ece4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ define([

		_doEvtFacade: function() {

			this._onEvt('HIDE', lang.hitch(this, this._onAppHide));

			// TODO puede que no sea necesario, se puede eliminar de aquí y de '_Show' si no se va a usar,
			// o bien implementarse directamente en _Show sin necesidad de publicar (todos los módulos pueden acceder
			// al elemento window)
+2 −1
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ define([

			return lang.mixin(this.inherited(arguments), {
				"_doResize": {},
				"_getNode": {}
				"_getNode": {},
				"_onAppHide": {}
			});
		}
	});
+20 −0
Original line number Diff line number Diff line
@@ -231,6 +231,26 @@ define([
			if (this._getNodeToShow()) {
				this.resize(arguments);
			}
		},

		_onAppHide: function() {

			// TODO reemplazo a destroy de todo 'app', eliminar cuando router no comparta canal y destruir solo 'app'
			this._publish(this.sidebar.getChannel('DESTROY'));
			this._publish(this.languageSelector.getChannel('DESTROY'));
			this._publish(this.userArea.getChannel('DESTROY'));

			this._publish(this._buildChannel(this.storeChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.selectorChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.managerChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.queryStoreChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.taskChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.socketChannel, this.actions.DESTROY));
			this._publish(this._buildChannel(this.notificationChannel, this.actions.DESTROY));

			this.sidebarNode.destroy();
			this.topbar.destroy();
			this.bc.destroy();
		}
	});
});
+7 −3
Original line number Diff line number Diff line
@@ -25,8 +25,12 @@ define([

		_setSubscriptionChecker: function(subscription) {

			if ((Credentials.get("userRole") === "ROLE_GUEST") &&
				(subscription.channel.indexOf(this.ownChannel) > -1)) {
			// TODO esta manera de bloquear acciones a los invitados es un poco chapucera, por ahora se permite
			// pasar a 'destroy', pero habrá que replantearlo para hacerlo bien
			if (Credentials.get("userRole") === "ROLE_GUEST" &&
				subscription.channel.indexOf(this.ownChannel) !== -1 &&
				subscription.channel.indexOf('destroy') === -1) {

				subscription.callback = "_subAuthFailed";
			}

+5 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ define([
			//	response: Object
			//		Respuesta de la petición que contiene los módulos permitidos.

			this._createPrimaryNavMenu();
			this._addItems(res.data);
		},

@@ -162,6 +163,10 @@ define([
			//	tags:
			//		private

			if (this.primaryNavMenuNode) {
				return;
			}

			var primaryNav = 'nav.' + this.primaryClass;

			this.primaryNavNode = put(this.domNode, primaryNav);