Commit 3b0aea51 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Remodela leyendas como desplegable de atlas

parent fa841dd1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ define([
					rowConfig: {
						buttonsConfig: {
							listButton: [{
								icon: "fa-list-alt",
								icon: "fa-map-o",
								btnId: "legend",
								title: "legend",
								returnItem: true
@@ -607,7 +607,7 @@ define([

		_createSubsAndPubsForLayer: function(layerInstance) {

			this._createLegendSubAndPubsForLayer(layerInstance);
			this._createLegendSubsAndPubsForLayer(layerInstance);
		},

		_deactivateLayer: function(/*Object*/ item, order) {
@@ -630,7 +630,7 @@ define([

		_removeSubsAndPubsForLayer: function(layerInstance) {

			this._removeLegendSubAndPubsForLayer(layerInstance);
			this._removeLegendSubsAndPubsForLayer(layerInstance);

			this._publish(layerInstance.getChannel('DISCONNECT'));
		},
@@ -648,7 +648,7 @@ define([

				this._emitEvt('DESELECT', [path]);
			} else if (btnId === "legend") {
				this._showLayerLegend(this._createLayerId(item.originalItem));
				this._showLayerLegend(objReceived);
			} else if (btnId === "fitBounds") {
				this._fitBounds(item);
			}
+37 −46
Original line number Diff line number Diff line
@@ -2,14 +2,10 @@ define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'put-selector/put'
	, 'redmic/modules/base/_ShowInPopup'
	, 'redmic/modules/layout/dataDisplayer/DataDisplayer'
], function(
	declare
	, lang
	, put
	, _ShowInPopup
	, DataDisplayer
) {

	return declare(null, {
@@ -19,8 +15,9 @@ define([
		constructor: function(args) {

			this.config = {
				_layersDataContainers: {}, // contenedores de info y legend de las capas
				_legendInstances: {} // instancias de módulo visualizador de leyendas
				legendClass: 'legendContainer',
				_legendByLayerId: {},
				_legendShownByLayerId: {}
			};

			lang.mixin(this, this.config, args);
@@ -28,14 +25,15 @@ define([

		_removeLegendOfRemovedLayer: function(layerId) {

			var infoContainer = this._layersDataContainers[layerId],
				legendContent = infoContainer ? infoContainer.legend : null;
			var legend = this._legendByLayerId[layerId];

			legendContent && put('!', legendContent);
			delete this._layersDataContainers[layerId];
			if (legend) {
				put('!', legend);
				delete this._legendByLayerId[layerId];
			}
		},

		_createLegendSubAndPubsForLayer: function(layerInstance) {
		_createLegendSubsAndPubsForLayer: function(layerInstance) {

			this._setSubscription({
				channel : layerInstance.getChannel('LAYER_LEGEND'),
@@ -43,7 +41,7 @@ define([
			});
		},

		_removeLegendSubAndPubsForLayer: function(layerInstance) {
		_removeLegendSubsAndPubsForLayer: function(layerInstance) {

			this._removeSubscription(layerInstance.getChannel('LAYER_LEGEND'));
		},
@@ -51,50 +49,43 @@ define([
		_subLayerLegend: function(response) {

			var layerId = response.layerId,
				layerLabel = response.layerLabel,
				layerLegend = response.legend,
				container = this._layersDataContainers[layerId];
				layerLegend = response.legend;

			if (!container) {
				container = this._layersDataContainers[layerId] = {};
			}
			if (!this._legendByLayerId[layerId]) {
				var legend = put('span.' + this.legendClass);
				legend.innerHTML = layerLegend;

			if (container.legend) {
				put('!', container.legend);
				this._legendByLayerId[layerId] = legend;
			}

			container.legend = put('div.atlasLayerInfoMessage');

			var legendContent = put(container.legend, 'div.layerLegend');
			put(legendContent, 'div.layerLegendTitle', layerLabel);

			var legendContentImg = put(legendContent, 'div.imageContainer');
			legendContentImg.innerHTML = layerLegend;
		},

		_showLayerLegend: function(layerId) {
		_showLayerLegend: function(browserButtonObj) {

			var container = this._layersDataContainers[layerId],
				legend = container ? container.legend : null;
			var container = browserButtonObj.node,
				legendContainer = container.children[1],
				item = browserButtonObj.item.originalItem,
				layerId = this._createLayerId(item),
				legend = this._legendByLayerId[layerId],
				legendShown = this._legendShownByLayerId[layerId];

			if (legend) {
				if (!this._legendInstances[layerId]) {
					this._legendInstances[layerId] = new declare(DataDisplayer).extend(_ShowInPopup)({
						parentChannel: this.getChannel(),
						ownChannel: 'legend' + layerId,
						title: this.i18n.legend,
						width: 5,
						height: 'sm'
					});
			if (legendShown === undefined) {
				legendShown = this._legendShownByLayerId[layerId] = false;
			}

				this._publish(this._legendInstances[layerId].getChannel('TOGGLE_SHOW'), {
					data: legend.innerHTML
				});
			} else {
			if (!legend) {
				this._emitEvt('COMMUNICATION', {
					description: this.i18n.noLegendAvailable
				});

				return;
			}

			if (!legendShown) {
				put(legendContainer, legend);
				this._legendShownByLayerId[layerId] = true;
			} else {
				put('!', legend);
				this._legendShownByLayerId[layerId] = false;
			}
		}
	});
Compare 8fb639fd to 069372ba
Original line number Diff line number Diff line
Subproject commit 8fb639fd10c58a249b3696ac7505bf02a9bd8748
Subproject commit 069372ba5b8aa640ff7eaf1ee70f0685c284886b