Commit 4da558db authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Unifica helpers para imágenes, corrige rutas

Aglutina todas las funcionalidades de colocar imágenes (con ruta
absoluta, relativa y/o usando credenciales) en un mismo helper, con
soporte para ruta relativa a la URL de API, obtenido desde las variables
globales de web alimentadas con el entorno.
parent 11626d87
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ module.exports = function(grunt) {
						qualityControl: true,
						GroupIcon: true,
						GroupIconInspire: true,
						Image: true,
						URL: true,
						UrlWebcam: true,
						TextURL: true,
@@ -40,8 +39,6 @@ module.exports = function(grunt) {
						Translate: true,
						ChartsHierarchicalListParse: true,
						TranslateUncapitalize: true,
						ImageDetails: true,
						ImageDetailsPublic: true,
						ChkIsNull: true,
						Status: true,
						PDFHref: true,
@@ -79,6 +76,7 @@ module.exports = function(grunt) {
						ItemEnabledStatus: true,
						DocumentInternalUrlStatus: true,
						DocumentUrl: true,
						Image: true,

						// string
						Capitalize: true
+23 −0
Original line number Diff line number Diff line
@@ -221,6 +221,29 @@ define([
			}

			return new handlebars.SafeString(result);
		},

		Image: function(imagePath, useCredentials) {

			var imgSrc;
			if (!imagePath) {
				imgSrc = '/resources/images/noIMG.png';
			} else if (imagePath.indexOf('/') !== 0) {
				imgSrc = imagePath;
			} else {
				// TODO se reemplaza la terminación de la ruta al servidor porque las imágenes ya
				// la contienen. Cuando se corrija esta circunstancia, eliminar el reemplazo
				var imgSrcPrefix = envApiUrl.replace('/api', '');
				imgSrc = imgSrcPrefix + imagePath;

				if (useCredentials && Credentials.get('userRole') !== 'ROLE_GUEST') {
					imgSrc += '?access_token=' + Credentials.get('accessToken');
				}
			}

			var imgItem = '<img src="' + imgSrc + '"/><br>';

			return new handlebars.SafeString(imgItem);
		}
	};
});
+1 −43
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ define([
			return new handlebars.SafeString(content + "'></i>");
		},

		'Image': function(image, urlDefault) {
		'Imagea': function(image, urlDefault) {

			var content;
			if (image && (Credentials.get("userRole") && (Credentials.get("userRole") != "ROLE_GUEST"))) {
@@ -629,48 +629,6 @@ define([
			return new handlebars.SafeString(result);
		},

		'ImageDetails': function(image, accessToken, iconOrClass) {

			var content = "<img src='";

			if (image && (Credentials.get("userRole") && (Credentials.get("userRole") != "ROLE_GUEST"))) {
				if (accessToken && Credentials.get("accessToken")) {
					image += "?access_token=" + Credentials.get("accessToken");
				}

				content += image;
			} else {
				content += "/resources/images/noIMG.png";
			}

			if (iconOrClass && typeof iconOrClass === 'string') {
				content += "' class='" + iconOrClass;
			}

			content += "'/><br>";

			return new handlebars.SafeString(content);
		},

		'ImageDetailsPublic': function(image, iconOrClass) {

			var content = "<img src='";

			if (image) {
				content += image;
			} else {
				content += "/resources/images/noIMG.png";
			}

			if (iconOrClass && typeof iconOrClass === 'string') {
				content += "' class='" + iconOrClass;
			}

			content += "'/><br>";

			return new handlebars.SafeString(content);
		},

		'ChkIsNull': function(data) {

			if (data) {
+1 −1
Original line number Diff line number Diff line
<div class="content">
	<div class="containerImageDetails">
		{{ImageDetailsPublic data.logo}}
		{{Image data.logo}}
	</div>
	<div class="grid">
		<div class="contentGrid">
+3 −3
Original line number Diff line number Diff line
{{ImageDetailsPublic data.logo}}
{{Image data.logo}}
<span class='spanTemplate'>
	<span class='title'>{{ChkIsNull data.name}}</span>
	<span class='subtitle'>
Loading