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

Permite desactivar capas de actividad

En la vista detalle de actividad, para aquellas que contienen capas de
mapa, carga automáticamente sólo la primera, y permite activar y
desactivar a voluntad cada una de ellas.
parent 9eb1e9df
Loading
Loading
Loading
Loading
+59 −1
Original line number Diff line number Diff line
@@ -51,7 +51,19 @@ define([
						classWindowContent: "view",
						notTextSearch: true,
						browserConfig: {
							template: ActivityLayerList
							template: ActivityLayerList,
							rowConfig: {
								buttonsConfig: {
									listButton: [{
										icon: "fa-toggle-on",
										altIcon: "fa-toggle-off",
										btnId: "toggleShowLayer",
										title: "layer",
										state: false,
										returnItem: true
									}]
								}
							}
						}
					}
				}
@@ -92,10 +104,56 @@ define([
			this.targetChange = lang.replace(this.templateTargetChange, {id: this.pathVariableId});

			var widgetInstance = this._getWidgetInstance('geographic');

			if (!this._listeningListButtons) {
				this._subscribe(widgetInstance.getChildChannel('browser', 'BUTTON_EVENT'), lang.hitch(this,
					this._subActivityLayersListButtonEvent));

				this._listeningListButtons = true;
			}

			this._publish(widgetInstance.getChannel("UPDATE_TARGET"), {
				target: this.targetChange,
				refresh: true
			});
		},

		_subActivityLayersListButtonEvent: function(res) {

			var btnId = res.btnId;

			if (btnId === 'toggleShowLayer') {
				this._onToggleShowLayer(res);
			}
		},

		_onToggleShowLayer: function(obj) {

			if (obj.state) {
				this._addMapLayer(obj.id);
			} else {
				this._removeMapLayer(obj.id);
			}
		},

		_updateToggleShowLayerButton: function(layerId, action) {

			var widgetInstance = this._getWidgetInstance('geographic');

			this._publish(widgetInstance.getChildChannel('browser', action), {
				idProperty: layerId,
				btnId: 'toggleShowLayer'
			});
		},

		_addMapLayer: function(layerId) {

			this._updateToggleShowLayerButton(layerId, 'CHANGE_ROW_BUTTON_TO_MAIN_CLASS');
		},

		_removeMapLayer: function(layerId) {

			this._updateToggleShowLayerButton(layerId, 'CHANGE_ROW_BUTTON_TO_ALT_CLASS');
		}
	});
});
+46 −6
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ define([
				layerTarget: redmicConfig.services.atlasLayer,
				activityCategory: ['ml'],
				definitionLayer: [WmsLayerImpl],
				_activityLayers: []
				_activityLayers: {}
			};

			lang.mixin(this, this.config, args);
@@ -72,10 +72,16 @@ define([
				data: layers
			});

			this._activityLayers = [];
			this._activityLayers = {};

			for (var i = 0; i < layers.length; i++) {
				this._createLayer(layers[i]);
				var layer = layers[i];
				this._createLayer(layer);

				if (i === 0) {
					var layerId = layer.id;
					this._addMapLayer(layerId);
				}
			}
		},

@@ -95,10 +101,44 @@ define([
				selectorChannel: widgetInstance.getChannel()
			}, this.layerConfig || {}]);

			var mapLayerInstance = new this._layerDefinition(this.layerConfig);
			this._activityLayers.push(mapLayerInstance);
			var mapLayerInstance = new this._layerDefinition(this.layerConfig),
				mapLayerId = layer.id;

			this._activityLayers[mapLayerId] = mapLayerInstance;
		},

		_addMapLayer: function(layerId) {

			this.inherited(arguments);

			var widgetInstance = this._getWidgetInstance('geographic');

			if (!widgetInstance) {
				return;
			}

			var layerInstance = this._activityLayers[layerId];

			this._publish(widgetInstance.getChildChannel('map', 'ADD_LAYER'), mapLayerInstance);
			this._publish(widgetInstance.getChildChannel('map', 'ADD_LAYER'), {
				layer: layerInstance
			});
		},

		_removeMapLayer: function(layerId) {

			this.inherited(arguments);

			var widgetInstance = this._getWidgetInstance('geographic');

			if (!widgetInstance) {
				return;
			}

			var layerInstance = this._activityLayers[layerId];

			this._publish(widgetInstance.getChildChannel('map', 'REMOVE_LAYER'), {
				layer: layerInstance
			});
		}
	});
});