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

Corrige carga de imágenes públicas/privadas

Ref #57.

Arregla la carga de imágenes públicas, eran tratadas como privadas por
error.

Emplea plantilla para mostrar el avatar del usuario en el topbar, en
lugar de replicar funcionalidades (ruta relativa y credenciales, ya
resuelto en plantillas).

Actualiza submódulos para incluir nueva plantilla y mejoras de estilo,
como el tamaño y ajuste de imágenes (usuario y listados).
parent b71f6918
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -466,16 +466,6 @@ define([
				dataType: "password"
			}, "userData");


			// TODO se reemplaza la terminación de la ruta al servidor porque las imágenes de los usuarios ya
			// la contienen. Cuando se corrija esta circunstancia, eliminar el reemplazo
			var userImageBaseTarget = envApiUrl.replace('/api', ''),
				userImagePath = data.image;

			if (userImagePath) {
				data.image = userImageBaseTarget + userImagePath;
			}

			this._injectItemList(data, "userImage");
		},

+18 −24
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ define([
	, 'redmic/modules/layout/listMenu/ListMenu'
	, 'redmic/modules/layout/templateDisplayer/TemplateDisplayer'
	, 'redmic/base/Credentials'
	, 'templates/UserTopbarImage'
	, 'templates/UserTopbarMenu'
], function(
	redmicConfig
@@ -25,6 +26,7 @@ define([
	, ListMenu
	, TemplateDisplayer
	, Credentials
	, TemplateTopbarImage
	, TemplateTopbarMenu
) {

@@ -56,7 +58,6 @@ define([
		_initialize: function() {

			put(this.domNode, '[title=$]', this.i18n.user);
			this.iconNode = put(this.domNode, 'i.fa.fa-user');
			this.listMenuDefinition = declare([ListMenu, _ShowOnEvt]).extend(_ShowInTooltip);

			this._commonItems = {
@@ -91,6 +92,8 @@ define([
			} else {
				this._initializeGuestUserArea();
			}

			this._initializeUserImage();
		},

		_initializeRegisteredUserArea: function() {
@@ -149,6 +152,20 @@ define([
			this._showMenu();
		},

		_initializeUserImage: function() {

			this.topbarImage = new TemplateDisplayer({
				parentChannel: this.getChannel(),
				omitLoading: true,
				template: TemplateTopbarImage,
				target: this.profileTarget
			});

			this._publish(this.topbarImage.getChannel('SHOW'), {
				node: this.domNode
			});
		},

		_defineSubscriptions: function () {

			this.subscriptionsConfig.push({
@@ -180,14 +197,6 @@ define([

		_subDataCredentialsGotProps: function(req) {

			var userImagePath = req.dataCredentials.image;

			if (userImagePath) {
				// TODO se reemplaza la terminación de la ruta al servidor porque las imágenes de los usuarios ya
				// la contienen. Cuando se corrija esta circunstancia, eliminar el reemplazo
				req.dataCredentials.image = envApiUrl.replace('/api', '') + userImagePath;
			}

			this._emitEvt('INJECT_DATA', {
				data: req.dataCredentials,
				target: this.profileTarget
@@ -283,24 +292,9 @@ define([
				data = data[0];
			}

			this._updateUserAreaButton(data);
			this._showMenu();
		},

		_updateUserAreaButton: function(data) {

			put('!', this.iconNode);

			if (data.image) {
				var tokenParam = '?access_token=' + Credentials.get('accessToken'),
					imageUrl = data.image + tokenParam;

				this.iconNode = put(this.domNode, 'img[src=' + imageUrl + ']');
			} else {
				this.iconNode = put(this.domNode, 'i.fa.fa-user');
			}
		},

		_beforeHide: function() {

			this._emitEvt('LOADED');
Compare 4da558db to ffe6ac7f
Original line number Diff line number Diff line
Subproject commit 4da558db3aacfda6eee67aa76a62ca88d9946581
Subproject commit ffe6ac7f551d4d9be01e8b9d847cf031e5645f58
Compare 9d6cb9ac to 8eacd7f7
Original line number Diff line number Diff line
Subproject commit 9d6cb9aca2b4ae359d595f0f65c6b93394481066
Subproject commit 8eacd7f780415fc2a66fee31bc2c945b602a4fb9