Commit 93a55b89 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Corrige confusión de nodos en los módulos

En todos los módulos mostrables (mediante _Show) se estaba realizando
una gestión de nodos deficiente. Se confundía el nodo padre (el
contenedor donde se le dice a un módulo que ha de mostrarse) con el nodo
propio (el que el propio módulo provee como su contenido principal). Se
usaba el atributo this.node indistintamente, a veces como padre y a
veces como propio, con el riesgo de desastre que esto supone.

Ahora se han diferenciado y nombrado convenientemente. El nodo padre
pasa de ser this.currentNode o this.node a ser this._moduleParentNode (y
this.parentNode es parte de Dijit, tener cuidado de no pisarlo). El nodo
propio pasa de ser this.node (en intención, porque realmente era su nodo
padre) a ser this._moduleOwnNode.

Un efecto de este problema se daba en el cambio entre la parte interna y
externa de la app, que no se mostraba correctamente.
parent 742cb286
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -40,12 +40,12 @@ define([

			var item;
			if (this.domain) {
				this.moduleNode = put('a.boxButton[href="' + this.url + '"][d-state-url=true]');
				item = put(this.moduleNode, 'div.name.mediumSolidContainer.colorWhite');
				this.appModuleBoxNode = put('a.boxButton[href="' + this.url + '"][d-state-url=true]');
				item = put(this.appModuleBoxNode, 'div.name.mediumSolidContainer.colorWhite');
				put(item, 'span', this.name);
			} else {
				this.moduleNode = put('a.module[title="' + this.name + '"][href="' + this.url + '"][d-state-url=true]');
				item = put(this.moduleNode, 'div.button.mediumSolidContainer.colorWhite');
				this.appModuleBoxNode = put('a.module[title="' + this.name + '"][href="' + this.url + '"][d-state-url=true]');
				item = put(this.appModuleBoxNode, 'div.button.mediumSolidContainer.colorWhite');
				put(item, 'i.iconModule.' + this.icon.replace(/\ /g, '.'));
				put(item, 'div.name', this.name);
			}
@@ -54,7 +54,7 @@ define([
		// TODO reemplazo de método de Dijit, eliminar si deja de usarse
		placeAt: function(node) {

			put(node, this.moduleNode);
			put(node, this.appModuleBoxNode);
		}
	});
});
+57 −58
Original line number Diff line number Diff line
@@ -262,39 +262,25 @@ define([

		_restoreOnMeOrAncestorShown: function(response) {

			//this._activeLoadingsPendding();

			this._meOrAncestorShownAlreadyFired = false;

			this._emitEvt('ME_OR_ANCESTOR_HIDDEN');
		},

		// 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;
				for (var i = 0; i < counts; i++) {
					this._emitEvt('LOADED');
				}
			}
		},*/

		_addClass: function(className) {

			this._changeNodeClasses(this.node, className, ".");
			this._changeNodeClasses(this._moduleOwnNode, className, '.');
		},

		_removeClass: function(className) {

			this._changeNodeClasses(this.node, className, "!");
			this._changeNodeClasses(this._moduleOwnNode, className, '!');
		},

		_changeNodeClasses: function(node, className, modifier) {

			if (className && node && node.firstChild) {
				var classes = className.split(" ").join(modifier);
				var classes = className.split(' ').join(modifier);
				put(node.firstChild, modifier + classes);
			}
		},
@@ -314,7 +300,7 @@ define([
			};

			if (node) {
				if (node !== this.currentNode) {
				if (node !== this._moduleParentNode) {
					return true;
				} else {
					if (!this._getShown()) {
@@ -324,7 +310,7 @@ define([
					}
				}
			} else {
				if (this.currentNode) {
				if (this._moduleParentNode) {
					if (!this._getShown()) {
						return true;
					} else {
@@ -381,18 +367,11 @@ define([

		_show: function(req) {

			var node = req ? req.node : null,
				data = req ? req.data : null,
			var data = req ? req.data : null,
				inFront = req ? req.inFront : null;

			// Si no le pasamos nodo, utiliza el último
			if (node) {
				this.currentNode = node;
			} else {
				node = this.currentNode;
			}

			if (!node) {
			this._moduleParentNode = this._getCurrentParentNode(req);
			if (!this._moduleParentNode) {
				return;
			}

@@ -406,25 +385,48 @@ define([
				this.currentData = null;
			}

			var nodeToShow = this._getNodeToShow() || this.domNode;
			if (!nodeToShow) {
			this._moduleOwnNode = this._getNodeToShowWrapper();
			if (!this._moduleOwnNode) {
				console.error('Node to show not found at module "%s"', this.getChannel());
				return;
			}

			if (node.domNode) {
				this._addToNode(node.domNode, nodeToShow, inFront);
			} else {
				this._addToNode(node, nodeToShow, inFront);
			this._addToNode(this._moduleParentNode, this._moduleOwnNode, inFront);
		},

		_getCurrentParentNode: function(req) {

			var parentNode = req ? req.node : null;

			// Si no le pasamos nodo, utiliza el último
			if (!parentNode) {
				if (!this._moduleParentNode) {
					console.error('Tried to show module "%s" with no parent node', this.getChannel());
				}
				return this._moduleParentNode;
			}

			return parentNode.domNode || parentNode;
		},

		_addToNode: function(node, nodeToShow, inFront) {
		_getNodeToShowWrapper: function() {

			var nodeToShow = this._moduleOwnNode || this._getNodeToShow() || this.domNode;

			if (!nodeToShow) {
				console.error('Node to show not found at module "%s"', this.getChannel());
				return;
			}

			if (inFront && node.firstChild) {
				this.node = put(node.firstChild, "-", nodeToShow);
			return nodeToShow;
		},

		_addToNode: function(parentNode, nodeToShow, inFront) {

			if (inFront && parentNode.firstChild) {
				put(parentNode.firstChild, '-', nodeToShow);
			} else {
				this.node = put(node, nodeToShow);
				put(parentNode, nodeToShow);
			}
		},

@@ -437,7 +439,7 @@ define([
			this._removeClass(previousAnimationClass);

			if (this._afterAnimationCallback) {
				this.node.firstChild.removeEventListener('animationend',
				this._moduleOwnNode.firstChild.removeEventListener('animationend',
					this._afterAnimationCallback);
			}
			this._afterAnimationCallback = lang.hitch(this, function(nestedDfd) {
@@ -453,7 +455,7 @@ define([
				dfd.resolve();
			}), this.animationSafetyTimeout);

			this.node.firstChild.addEventListener('animationend', this._afterAnimationCallback);
			this._moduleOwnNode.firstChild.addEventListener('animationend', this._afterAnimationCallback);

			this._addClass(currentAnimationClass);

@@ -496,7 +498,7 @@ define([

		_continueHide: function(req) {

			if (!this.node) {
			if (!this._moduleOwnNode) {
				return;
			}

@@ -539,17 +541,16 @@ define([

		_destroyNode: function() {

			if (!this.node) {
			if (!this._moduleOwnNode) {
				return;
			}

			//TODO revisar la manera de guardar el nodo padre y el propio, el padre se esta duplicando en dos variables

			var node = this._getNodeToShow() || this.node,
				nodeToShow = node.domNode || node;

			put(nodeToShow, '!');
			this.node = null;
			if (this._moduleOwnNode.id === 'rootContainer') {
				console.log('me voy a cargar', this._moduleOwnNode, this.getChannel());
				return;
			}
			put(this._moduleOwnNode, '!');
			this._moduleOwnNode = null;
		},

		_subToggleShow: function(req) {
@@ -575,7 +576,7 @@ define([

		_chkModuleCanResize: function(req) {

			return !!this.node;
			return !!this._moduleOwnNode;
		},

		_subResize: function(req) {
@@ -605,9 +606,9 @@ define([

			var evt = {};

			if (this.node) {
				evt.width = this.node.offsetWidth;
				evt.height = this.node.offsetHeight;
			if (this._moduleOwnNode) {
				evt.width = this._moduleOwnNode.offsetWidth;
				evt.height = this._moduleOwnNode.offsetHeight;
			}

			this._emitEvt('RESIZE', evt);
@@ -621,7 +622,7 @@ define([
		_lock: function() {

			if (!this._lockedContainer) {
				this._lockedContainer = this._getNodeToShow() || this.domNode;
				this._lockedContainer = this._getNodeToShowWrapper();
			}

			this._setLockStatus(true);
@@ -699,7 +700,7 @@ define([
				this._activeLoadings = 1;

				if (!this._loadingContainer) {
					this._loadingContainer = this._getNodeToShowLoading() || this._getNodeToShow() || this.domNode;
					this._loadingContainer = this._getNodeToShowLoading() || this._getNodeToShowWrapper();
				}

				objToPub.node = this._loadingContainer;
@@ -775,8 +776,6 @@ define([

		_onModuleHide: function() {

			//this._activeLoadingsPendding();

			this._setShown(false);

			var response = {
+10 −7
Original line number Diff line number Diff line
@@ -54,9 +54,12 @@ define([
		_createContainer: function() {

			this.popupBody = new ContentPane();
			put(this.popupBody.domNode, '.flex');
		},

		_getCurrentParentNode: function(req) {

			this.currentNode = this.popupBody.domNode;
			put(this.currentNode, '.flex');
			return this.popupBody.domNode;
		},

		_beforeShow: function(req) {
@@ -78,15 +81,15 @@ define([

		_afterShow: function(req) {

			var afterOriginalDfd = function(returnDfd) {
			var afterOriginalDfd = function(innerReturnDfd) {

				var dfdPopup = this._popupInstance.show();

				dfdPopup.then(lang.hitch(this, function(returnDfd) {
				dfdPopup.then(lang.hitch(this, function(innerInnerReturnDfd) {

					this._popupInstance.set('centerContent', this.popupBody);
					returnDfd.resolve();
				}, returnDfd));
					innerInnerReturnDfd.resolve();
				}, innerReturnDfd));
			};

			var dfd = this.inherited(arguments),
+9 −7
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ define([
			if (req && req.node) {
				node = req.node.domNode || req.node;
			} else {
				node = this.currentNode;
				node = this._moduleOwnNode;
			}

			if (node) {
@@ -331,7 +331,7 @@ define([

			this._validSizeIntervalHandler = setInterval(lang.hitch(this, function(dfd) {

				if (this.node && this.node.offsetWidth) {
				if (this._moduleOwnNode && this._moduleOwnNode.offsetWidth) {
					clearInterval(this._validSizeIntervalHandler);
					dfd.resolve();
				}
@@ -398,7 +398,7 @@ define([
				this._minimizeButton.onclick = lang.hitch(this, this._minimizeModuleReturn);
			}

			domStyle.set(this.node, 'height', 0);
			domStyle.set(this._moduleOwnNode, 'height', 0);
			domStyle.set(this._windowNode.parentNode, 'height', this.titleHeight + 'rem');
		},

@@ -412,7 +412,7 @@ define([

			var contentHeightReduction = this.titleHeight;

			domStyle.set(this.node, 'height', 'calc(100% - ' + contentHeightReduction + 'rem)');
			domStyle.set(this._moduleOwnNode, 'height', 'calc(100% - ' + contentHeightReduction + 'rem)');
			domStyle.set(this._windowNode.parentNode, 'height', '');
		},

@@ -529,18 +529,20 @@ define([
				this._limitMaxHeightToAvailableHeight();
			}

			if (this.node && !this._getResizedByUser()) {
			if (this._moduleOwnNode && !this._getResizedByUser()) {
				this._autoMaximizeOnLowWidth();
			}
		},

		_autoMaximizeOnLowWidth: function() {

			if (!this.node.offsetWidth || (this.resizable && this.node.offsetWidth === this._resizableForcedMinWidth)) {
			if (!this._moduleOwnNode.offsetWidth || (this.resizable &&
				this._moduleOwnNode.offsetWidth === this._resizableForcedMinWidth)) {

				return;
			}

			if (this.node.offsetWidth < this.minWidth) {
			if (this._moduleOwnNode.offsetWidth < this.minWidth) {
				this._setAutoMaximized(true);
				this._maximizeModule();
			} else if (this._getAutoMaximized()) {
+0 −16
Original line number Diff line number Diff line
@@ -346,22 +346,6 @@ define([
			return this.domNode;
		},

		/*_beforeShow: function(req) {

			if (req && req.node) {
				put(req.node.domNode || req.node, ".flex");
				this._addFlexInNode = true;
			}
		},

		_afterHide: function() {

			if (this._addFlexInNode) {
				put(this.currentNode.domNode || this.currentNode, "!flex");
				this._addFlexInNode = false;
			}
		},*/

		_getData: function() {

			var data = [];
Loading