Commit 91b9c3c5 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Refactoriza atlas y mejora marine-monitoring

Reubica partes de la implementación del componente Atlas para poder
aprovechar mejor su funcionalidad desde el nuevo visor de monitorización
marina.

Integra las capas de monitorización marina junto con las que el usuario
pueda seleccionar en el catálogo de atlas, facilitando así su uso.

Actualiza submódulo.

Fix #94.
parent af754604
Loading
Loading
Loading
Loading
Compare c1cc640d to 70f4adac
Original line number Diff line number Diff line
Subproject commit c1cc640db136bf3dcb574657936b41328a5cf7c9
Subproject commit 70f4adac51ad49883773a07b8d0110bf4fa56b13
+24 −114
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ define([
	, 'src/redmicConfig'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'dojo/Deferred'
	, 'src/component/base/_Module'
	, 'src/component/base/_Selection'
@@ -25,6 +26,7 @@ define([
	, redmicConfig
	, declare
	, lang
	, aspect
	, Deferred
	, _Module
	, _Selection
@@ -64,12 +66,13 @@ define([
				selectionTarget: redmicConfig.services.atlasLayerSelection,
				pathSeparator: '.',

				_layerInstances: {}, // capas de las que hemos creado instancia (no se borran, se reciclan)
				_layerIdsById: {}, // correspondencia entre ids de las capas con sus layerIds
				_lastOrder: 0 // order de la última capa añadida (para saber donde añadir la siguiente)
			};

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

			aspect.before(this, '_createLayerInstance', lang.hitch(this, this._atlasBeforeCreateLayerInstance));
		},

		_setConfigurations: function() {
@@ -84,6 +87,7 @@ define([
								icon: 'fa-trash-o',
								btnId: 'remove',
								title: 'remove',
								condition: function(item) { return !!item.originalItem.atlas; },
								returnItem: true
							}]
						}
@@ -199,7 +203,7 @@ define([

			this.inherited(arguments);

			this._addTabs(this.addTabChannel);
			this._addTabs();
		},

		getNodeToShow: function() {
@@ -207,24 +211,18 @@ define([
			return this._atlasContainer;
		},

		_addTabs: function(addTabChannel) {
		_addTabs: function() {

			if (!addTabChannel) {
			if (!this.addTabChannel) {
				console.error('Missing channel to add tabs at Atlas module "%s"', this.getChannel());
				return;
			}

			this._publish(addTabChannel, {
			this._publish(this.addTabChannel, {
				title: this.i18n.layersCatalog,
				iconClass: 'fr fr-world',
				channel: this.catalogView.getChannel()
			});

			this._publish(addTabChannel, {
				title: this.i18n.selectedLayers,
				iconClass: 'fa fa-map-o',
				channel: this._themesBrowser.getChannel()
			});
		},

		_checkSelectionAfterShown: function() {
@@ -235,6 +233,11 @@ define([
			}
		},

		_atlasBeforeCreateLayerInstance: function(id, layerId) {

			this._layerIdsById[id] = layerId;
		},

		_select: function(path, total) {

			var id = path.split(this.pathSeparator).pop();
@@ -274,27 +277,13 @@ define([

		_reportDeselection: function(id) {

			this._publish(this._themesBrowser.getChildChannel('browser', 'REMOVE'), {
				ids: [id]
			});

			this._removeLayerInstance(id);

			this._lastOrder--;
		},

		_removeLayerInstance: function(id) {

			var layerId = this._layerIdsById[id];

			this._emitEvt('REMOVE_LAYER', {
				layer: layerId
			});

			this._removeSubsAndPubsForLayer(this._layerInstances[layerId]);
			this._removeLayerInstance(layerId);

			delete this._layerInstances[layerId];
			delete this._layerIdsById[id];

			this._lastOrder--;
		},

		_clearSelection: function() {
@@ -313,12 +302,12 @@ define([

			this._clearSelectionPending = false;

			this._publish(this._themesBrowser.getChildChannel('browser', 'CLEAR'));

			for (var key in this._layerIdsById) {
				this._removeLayerInstance(key);
				this._removeLayerInstance(this._layerIdsById[key]);
			}

			this._layerIdsById = [];

			this._lastOrder = 0;
		},

@@ -355,22 +344,6 @@ define([
				return;
			}

			var layerDefinition = this._getAtlasLayerDefinition(),
				layerConfiguration = this._getAtlasLayerConfiguration(item),
				layerLabel = layerConfiguration.layerLabel;

			layerConfiguration.mapChannel = this.getMapChannel();

			var data = {
				id: itemId,
				label: layerLabel,
				originalItem: item,
				layer: {
					definition: layerDefinition,
					props: layerConfiguration
				}
			};

			this._emitEvt('TRACK', {
				type: TRACK.type.event,
				info: {
@@ -380,13 +353,15 @@ define([
				}
			});

			var layerItem = this._getLayerItemToInject(item);

			this._emitEvt('INJECT_ITEM', {
				data: data,
				data: layerItem,
				target: this.localTarget
			});

			this._lastOrder++;
			this._activateLayer(data, this._lastOrder);
			this._activateLayer(layerItem, this._lastOrder);
		},

		_subLayerRemoved: function(res) {
@@ -413,71 +388,6 @@ define([
			this._publish(this.templateDisplayerDetails.getChannel('SHOW'), {
				node: node
			});
		},

		_activateLayer: function(/*Object*/ item, order) {

			if (!item || !item.layer) {
				return;
			}

			var definition = item.layer.definition,
				props = item.layer.props,
				id = item.id,
				layerId = this._createLayerId(item.originalItem),
				layer = this._getLayerInstance(id, layerId, definition, props);

			this._emitEvt('ADD_LAYER', {
				layer: layer,
				layerId: layerId,
				layerLabel: item.label,
				atlasItem: item.originalItem,
				order: order
			});
		},

		_getLayerInstance: function(id, layerId, definition, props) {

			var layer = this._layerInstances[layerId];

			if (!layer) {
				layer = new definition(props);
				this._layerInstances[layerId] = layer;
				this._layerIdsById[id] = layerId;
				this._createSubsAndPubsForLayer(layer);
			}

			return layer;
		},

		_createSubsAndPubsForLayer: function(layerInstance) {

			this._createLegendSubsAndPubsForLayer(layerInstance);
		},

		_deactivateLayer: function(/*Object*/ item, order) {

			if (!item.layer) {
				return;
			}

			var layerId = this._createLayerId(item.originalItem),
				layer = this._layerInstances[layerId];

			if (layer) {
				this._emitEvt('REMOVE_LAYER', {
					layer: layer,
					order: order,
					keepInstance: true
				});
			}
		},

		_removeSubsAndPubsForLayer: function(layerInstance) {

			this._removeLegendSubsAndPubsForLayer(layerInstance);

			this._publish(layerInstance.getChannel('DISCONNECT'));
		}
	});
});
+108 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ define([

			this.config = {
				layerIdSeparator: '_',
				themeSeparator: '-'
				themeSeparator: '-',
				_layerInstances: {}, // capas de las que hemos creado instancia (no se borran, se reciclan)
				defaultLayerItemState: true
			};

			lang.mixin(this, this.config, args);
@@ -272,6 +274,27 @@ define([
			};
		},

		_getLayerItemToInject: function(item) {

			var itemId = this._getAtlasLayerId(item),
				layerDefinition = this._getAtlasLayerDefinition(),
				layerConfiguration = this._getAtlasLayerConfiguration(item),
				layerLabel = layerConfiguration.layerLabel;

			layerConfiguration.mapChannel = this.getMapChannel();

			return {
				id: itemId,
				label: layerLabel,
				state: this.defaultLayerItemState,
				originalItem: item,
				layer: {
					definition: layerDefinition,
					props: layerConfiguration
				}
			};
		},

		_getAtlasLayerId: function(layerItem) {

			return layerItem && layerItem.id;
@@ -287,6 +310,90 @@ define([
		_createLayerLabel: function(layerItem) {

			return layerItem.alias || layerItem.title;
		},

		_removeLayerInstance: function(layerId) {

			this._emitEvt('REMOVE_LAYER', {
				layer: layerId
			});

			this._removeSubsAndPubsForLayer(this._layerInstances[layerId]);

			delete this._layerInstances[layerId];
		},

		_createSubsAndPubsForLayer: function(layerInstance) {

			this._createLegendSubsAndPubsForLayer(layerInstance);
		},

		_removeSubsAndPubsForLayer: function(layerInstance) {

			this._removeLegendSubsAndPubsForLayer(layerInstance);

			this._publish(layerInstance.getChannel('DISCONNECT'));
		},

		_getLayerInstance: function(id, layerId, Definition, props) {

			var layerInstance = this._layerInstances[layerId];

			if (layerInstance) {
				return layerInstance;
			}

			return this._createLayerInstance(id, layerId, Definition, props);
		},

		_createLayerInstance: function(_id, layerId, Definition, props) {

			var layerInstance = new Definition(props);

			this._layerInstances[layerId] = layerInstance;

			this._createSubsAndPubsForLayer(layerInstance);

			return layerInstance;
		},

		_activateLayer: function(/*Object*/ item, order) {

			if (!item || !item.layer) {
				return;
			}

			var definition = item.layer.definition,
				props = item.layer.props,
				id = item.id,
				layerId = this._createLayerId(item.originalItem),
				layer = this._getLayerInstance(id, layerId, definition, props);

			this._emitEvt('ADD_LAYER', {
				layer: layer,
				layerId: layerId,
				layerLabel: item.label,
				atlasItem: item.originalItem,
				order: order
			});
		},

		_deactivateLayer: function(/*Object*/ item, order) {

			if (!item.layer) {
				return;
			}

			var layerId = this._createLayerId(item.originalItem),
				layer = this._layerInstances[layerId];

			if (layer) {
				this._emitEvt('REMOVE_LAYER', {
					layer: layer,
					order: order,
					keepInstance: true
				});
			}
		}
	});
});
+51 −5
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ define([
	, 'app/designs/list/layout/Layout'
	, 'src/component/browser/_DragAndDrop'
	, 'src/component/browser/bars/Total'
	, 'src/redmicConfig'
	, 'templates/AtlasList'
], function(
	declare
@@ -15,6 +16,7 @@ define([
	, Layout
	, _DragAndDrop
	, Total
	, redmicConfig
	, ListTemplate
) {

@@ -26,21 +28,34 @@ define([

			this.config = {
				pathSeparator: '.',
				parentProperty: 'parent'
				parentProperty: 'parent',
				addThemesBrowserFirst: false,
				omitThemesBrowser: false
			};

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

			if (this.omitThemesBrowser) {
				return;
			}

			this._prepareThemesBrowserCallbacks();
		},

		_prepareThemesBrowserCallbacks: function() {

			aspect.before(this, '_afterSetConfigurations', lang.hitch(this, this._themesBrowserAfterSetConfigurations));
			aspect.before(this, '_initialize', lang.hitch(this, this._initializeThemesBrowser));
			aspect.before(this, '_defineSubscriptions', lang.hitch(this, this._defineThemesBrowserSubscriptions));
		},

		_afterSetConfigurations: function() {
			var aspectMethod = this.addThemesBrowserFirst ? 'before' : 'after';
			aspect[aspectMethod](this, '_addTabs', lang.hitch(this, this._addThemesBrowserTabs));

			this._setThemesBrowserConfiguration();
			aspect.before(this, '_reportDeselection', lang.hitch(this, this._themesBrowserReportDeselection));
			aspect.before(this, '_reportClearSelection', lang.hitch(this, this._themesBrowserReportClearSelection));
		},

		_setThemesBrowserConfiguration: function() {
		_themesBrowserAfterSetConfigurations: function() {

			this.themesBrowserConfig = this._merge([{
				parentChannel: this.getChannel(),
@@ -55,6 +70,11 @@ define([
					rowConfig: {
						buttonsConfig: {
							listButton: [{
								icon: 'fa-info-circle',
								btnId: 'details',
								title: 'info',
								href: redmicConfig.viewPaths.ogcServiceDetails
							},{
								icon: 'fa-map-o',
								btnId: 'legend',
								title: 'legend',
@@ -97,6 +117,20 @@ define([
			});
		},

		_addThemesBrowserTabs: function() {

			if (!this.addTabChannel) {
				console.error('Missing channel to add themes tab at module "%s"', this.getChannel());
				return;
			}

			this._publish(this.addTabChannel, {
				title: this.i18n.selectedLayers,
				iconClass: 'fa fa-map-o',
				channel: this._themesBrowser.getChannel()
			});
		},

		_subThemesBrowserButtonEvent: function(objReceived) {

			var btnId = objReceived.btnId,
@@ -180,6 +214,18 @@ define([
		_getLatLng: function(coord) {

			return [coord[1], coord[0]];
		},

		_themesBrowserReportDeselection: function(id) {

			this._publish(this._themesBrowser.getChildChannel('browser', 'REMOVE'), {
				ids: [id]
			});
		},

		_themesBrowserReportClearSelection: function() {

			this._publish(this._themesBrowser.getChildChannel('browser', 'CLEAR'));
		}
	});
});
+1 −0
Original line number Diff line number Diff line
define({
	"ok": "Aceptar"
	, "contents": "Contenidos"
	, "userData": "Datos de usuario"
	, "cancel": "Cancelar"
	, "nextStep": "Siguiente"
Loading