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

Impide mostrar elevación y leyenda sin cargar capa

Si el usuario intenta mostrar la leyenda de una capa o desplegar su
listado de valores de elevación, se le informa de que antes debe cargar
la capa.
parent d1d04d93
Loading
Loading
Loading
Loading
+31 −3
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'dojo/dom-class'
	, 'src/component/layout/TagList'
], function(
	declare
	, lang
	, aspect
	, domClass
	, TagList
) {
@@ -23,6 +25,8 @@ define([
			};

			lang.mixin(this, this.config, args);

			aspect.before(this, '_deactivateLayer', lang.hitch(this, this._atlasDimensionsDeactivateLayer));
		},

		_getAtlasLayerDimensions: function(atlasItem) {
@@ -50,11 +54,20 @@ define([

		_showLayerElevation: function(browserButtonObj) {

			var atlasLayerItem = browserButtonObj.item,
				layerId = atlasLayerItem.mapLayerId;

			if (!this._activeLayers[layerId]) {
				this._emitEvt('COMMUNICATION', {
					description: this.i18n.addLayerFirst
				});

				return;
			}

			var container = browserButtonObj.node,
				elevationContainer = container.children[1],
				atlasLayerItem = browserButtonObj.item,
				item = atlasLayerItem.atlasItem,
				layerId = atlasLayerItem.mapLayerId,
				elevationTagListInstance = this._getLayerElevationTagList(layerId, item),
				elevationShown = this._elevationShownByLayerId[layerId] || false;

@@ -63,7 +76,6 @@ define([
				this._elevationShownByLayerId[layerId] = true;
			} else {
				this._hideLayerElevationTagList(layerId);
				this._elevationShownByLayerId[layerId] = false;
			}
		},

@@ -119,6 +131,7 @@ define([
			}

			this._publish(elevationTagListInstance.getChannel('HIDE'));
			this._elevationShownByLayerId[layerId] = false;
		},

		_onElevationTagClicked: function(layerId, res) {
@@ -135,6 +148,21 @@ define([
					label: res.label
				}
			});
		},

		_atlasDimensionsDeactivateLayer: function(atlasLayerItem) {

			if (!atlasLayerItem) {
				return;
			}

			var mapLayerId = atlasLayerItem.mapLayerId;

			if (!this._elevationShownByLayerId[mapLayerId]) {
				return;
			}

			this._hideLayerElevationTagList(mapLayerId);
		}
	});
});
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ define([
				layerIdSeparator: '_',
				themeSeparator: '-',
				_layerInstances: {}, // capas de las que hemos creado instancia (no se borran, se reciclan)
				_activeLayers: {}, // indicador sobre si la capa está activada en el mapa o no
				defaultLayerItemState: true
			};

@@ -376,6 +377,8 @@ define([
				atlasItem: atlasLayerItem.atlasItem,
				order: order
			});

			this._activeLayers[mapLayerId] = true;
		},

		_deactivateLayer: function(/*Object*/ atlasLayerItem, order) {
@@ -393,6 +396,8 @@ define([
					order: order,
					keepInstance: true
				});

				this._activeLayers[mapLayerId] = false;
			}
		}
	});
+26 −2
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'put-selector'
], function(
	declare
	, lang
	, aspect
	, put
) {

@@ -21,6 +23,8 @@ define([
			};

			lang.mixin(this, this.config, args);

			aspect.before(this, '_deactivateLayer', lang.hitch(this, this._atlasLegendDeactivateLayer));
		},

		_removeLegendOfRemovedLayer: function(layerId) {
@@ -61,10 +65,19 @@ define([

		_showLayerLegend: function(browserButtonObj) {

			var atlasLayerItem = browserButtonObj.item,
				layerId = atlasLayerItem.mapLayerId;

			if (!this._activeLayers[layerId]) {
				this._emitEvt('COMMUNICATION', {
					description: this.i18n.addLayerFirst
				});

				return;
			}

			var container = browserButtonObj.node,
				legendContainer = container.children[1],
				atlasLayerItem = browserButtonObj.item,
				layerId = atlasLayerItem.mapLayerId,
				legend = this._legendByLayerId[layerId],
				legendShown = this._legendShownByLayerId[layerId];

@@ -87,6 +100,17 @@ define([
				put('!', legend);
				this._legendShownByLayerId[layerId] = false;
			}
		},

		_atlasLegendDeactivateLayer: function(atlasLayerItem) {

			if (!atlasLayerItem) {
				return;
			}

			var mapLayerId = atlasLayerItem.mapLayerId;

			this._legendShownByLayerId[mapLayerId] = false;
		}
	});
});
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ define({
	, "toggleLayerVisibility": "Alternar visibilidad de capa"
	, "showLegend": "Mostrar leyenda de la capa"
	, "showElevation": "Mostrar valores de elevación de la capa"
	, "addLayerFirst": "Añade la capa al mapa primero"
	, "navigateToLayerInfo": "Navegar a la vista de detalles de la capa"
	, "userData": "Datos de usuario"
	, "cancel": "Cancelar"
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ define({
		, "toggleLayerVisibility": "Toggle layer visibility"
		, "showLegend": "Show layer legend"
		, "showElevation": "Show layer elevation values"
		, "addLayerFirst": "Add layer to map first"
		, "navigateToLayerInfo": "Navigate to layer details view"
		, "userData": "User data"
		, "cancel": "Cancel"