Commit a9c717eb authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Expande ciclo de ocultación de módulos

Añade a la cadena de ocultado la posibilidad de definir lógica para
ejecutar antes de empezar a ocultar y después de haberse ocultado el
módulo.
Omite chapuza de quitar todas las cargas pendientes de un módulo.
parent fd7d7395
Loading
Loading
Loading
Loading
+49 −18
Original line number Diff line number Diff line
@@ -252,25 +252,27 @@ define([

		_prepareOnMeOrAncestorShown: function(response) {

			if (this._onMeOrAncestorShownIsDisabled) {
			if (this._meOrAncestorShownAlreadyFired) {
				return;
			}

			this._onMeOrAncestorShownIsDisabled = true;
			this._meOrAncestorShownAlreadyFired = true;

			this._emitEvt('ME_OR_ANCESTOR_SHOWN');
			this._emitEvt('ME_OR_ANCESTOR_SHOWN', response);
		},

		_restoreOnMeOrAncestorShown: function(response) {

			this._activeLoadingsPendding();
			//this._activeLoadingsPendding();

			this._onMeOrAncestorShownIsDisabled = false;
			this._meOrAncestorShownAlreadyFired = false;

			this._emitEvt('ME_OR_ANCESTOR_HIDDEN');
		},

		_activeLoadingsPendding: function() {
		// TODO este método se salta a la torera la acumulación de cargas, no es una solución sino una chapuza
		// TODO si se detecta alguna carga no resuelta, el problema lo tiene el módulo concreto y habrá que solucionarlo
		/*_activeLoadingsPendding: function() {

			if (this._activeLoadings) {
				var counts = this._activeLoadings;
@@ -278,7 +280,7 @@ define([
					this._emitEvt('LOADED');
				}
			}
		},
		},*/

		_addClass: function(className) {

@@ -305,12 +307,13 @@ define([

		_showWrapper: function(req) {

			var beforeShowDfd = this._beforeShow(req);
			var beforeShowDfd = this._beforeShow(req),
				continueShow = lang.hitch(this, this._continueShow, req);

			if (beforeShowDfd && beforeShowDfd.then) {
				beforeShowDfd.then(lang.hitch(this, this._continueShow, req));
				beforeShowDfd.then(continueShow);
			} else {
				this._continueShow(req);
				continueShow();
			}
		},

@@ -480,6 +483,18 @@ define([

		_hideWrapper: function(req) {

			var beforeHideDfd = this._beforeHide(req),
				continueHide = lang.hitch(this, this._continueHide, req);

			if (beforeHideDfd && beforeHideDfd.then) {
				beforeHideDfd.then(continueHide);
			} else {
				continueHide();
			}
		},

		_continueHide: function(req) {

			if (!this.node) {
				return;
			}
@@ -517,7 +532,19 @@ define([
			}

			this._destroyNode();
			this._emitEvt('HIDE', this._getShownOrHiddenResponseObject());
			this._emitHideEventWhenAfterHideIsDone(req);
		},

		_emitHideEventWhenAfterHideIsDone: function(req) {

			var emitHide = lang.hitch(this, this._emitEvt, 'HIDE', this._getShownOrHiddenResponseObject()),
				dfdAfterHide = this._afterHide(req);

			if (dfdAfterHide && dfdAfterHide.then) {
				dfdAfterHide.then(emitHide);
			} else {
				emitHide();
			}
		},

		_destroyNode: function() {
@@ -725,22 +752,26 @@ define([
			this._setShown(true);
			!this._getPreviouslyShown() && this._setPreviouslyShown(true);

			this._prepareOnMeOrAncestorShown();
			this._propagateActionToChildren('ANCESTOR_SHOWN', {
			var response = {
				moduleChannel: this.getChannel()
			});
			};

			this._prepareOnMeOrAncestorShown(response);
			this._propagateActionToChildren('ANCESTOR_SHOWN', response);
		},

		_onModuleHide: function() {

			this._activeLoadingsPendding();
			//this._activeLoadingsPendding();

			this._setShown(false);

			this._restoreOnMeOrAncestorShown();
			this._propagateActionToChildren('ANCESTOR_HIDDEN', {
			var response = {
				moduleChannel: this.getChannel()
			});
			};

			this._restoreOnMeOrAncestorShown(response);
			this._propagateActionToChildren('ANCESTOR_HIDDEN', response);
		},

		_getStartupStatus: function() {
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ define([
				returnDfd = new Deferred(),
				cbk = lang.hitch(this, afterOriginalDfd, returnDfd);

			if (dfd && dfd.then && !dfd.isFulfilled()) {
			if (dfd && dfd.then) {
				dfd.then(cbk);
			} else {
				cbk();
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ define([
				"_getNodeToShowLoading": {},
				"_beforeShow": {},
				"_afterShow": {},
				"_beforeHide": {},
				"_afterHide": {},
				"_reset": {},
				"_getShownOrHiddenResponseObject": {},
				"_resize": {},