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

Empieza a integrar capas de vista en themesBrowser

parent ec437883
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ define([
				classByList: '.borderList',
				browserConfig: {
					template: serviceOGCList,
					//noSelectParent: true,
					rowConfig: {
						buttonsConfig: {
							listButton: [{
@@ -146,7 +145,7 @@ define([
				target: 'tooltipDetails',
				'class': 'descriptionTooltip',
				timeClose: 200
			}, this.atlasConfig || {}]);
			}, this.detailsConfig || {}]);
		},

		_initialize: function() {
@@ -404,7 +403,7 @@ define([
			var node = res.iconNode,
				item = res.item;

			item.href = lang.replace(redmicConfig.viewPaths.serviceOGCCatalogDetails, item);
			item.href = lang.replace(redmicConfig.viewPaths.ogcServiceDetails, item);

			this._emitEvt('INJECT_ITEM', {
				data: item,
+0 −2
Original line number Diff line number Diff line
@@ -82,14 +82,12 @@ define([

		_initializeThemesBrowser: function() {

			console.log('inicializo');
			var ThemesBrowser = declare([Layout, Controller]);
			this._themesBrowser = new ThemesBrowser(this.themesBrowserConfig);
		},

		_defineThemesBrowserSubscriptions: function() {

			console.log('suscribo');
			this.subscriptionsConfig.push({
				channel: this._themesBrowser.getChildChannel('browser', 'BUTTON_EVENT'),
				callback: '_subThemesBrowserButtonEvent'
+39 −4
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'app/designs/mapWithSideContent/main/Geographic'
	, "app/designs/mapWithSideContent/Controller"
	, "app/designs/mapWithSideContent/layout/MapAndContent"
	, 'src/component/base/_ExternalConfig'
	, "src/component/base/_Store"
	, "src/component/atlas/Atlas"
	, 'src/component/layout/TabsDisplayer'
	, "src/component/mapQuery/QueryOnMap"
	, 'src/redmicConfig'
	, 'src/viewer/marineMonitoring/_ManageOgcServices'
], function(
	declare
	, lang
	, Geographic
	, Controller
	, Layout
	, _ExternalConfig
	, _Store
	, Atlas
	, TabsDisplayer
	, QueryOnMap
	, redmicConfig
	, _ManageOgcServices
) {

	return declare([Geographic, _ManageOgcServices, _ExternalConfig], {
	return declare([Layout, Controller, _Store, _ManageOgcServices, _ExternalConfig], {
		//	summary:
		//		Vista de visor de monitorización marina. Proporciona un mapa principal y una serie de capas temáticas,
		//		junto con el componente Atlas para cruzar datos.
@@ -26,7 +36,6 @@ define([
				ownChannel: 'marineMonitoringViewer',
				target: redmicConfig.services.atlasLayer,
				_activityLayersTarget: 'activityLayersTarget',
				notTextSearch: true,
				externalConfigPropName: 'marineMonitoringViewerActivities'
			};

@@ -53,6 +62,28 @@ define([
			}, this.atlasConfig || {}]);
		},

		_initialize: function() {

			this._tabsDisplayer = new TabsDisplayer({
				parentChannel: this.getChannel()
			});

			var getMapChannel = lang.hitch(this.map, this.map.getChannel);

			this._atlas = new Atlas({
				parentChannel: this.getChannel(),
				getMapChannel: getMapChannel,
				addTabChannel: this._tabsDisplayer.getChannel('ADD_TAB'),
				localTarget: this._activityLayersTarget
			});

			this._queryOnMap = new QueryOnMap({
				parentChannel: this.getChannel(),
				getMapChannel: getMapChannel,
				tabsDisplayerChannel: this._tabsDisplayer.getChannel()
			});
		},

		postCreate: function() {

			this.inherited(arguments);
@@ -60,6 +91,10 @@ define([
			this._emitEvt('GET_EXTERNAL_CONFIG', {
				propertyName: this.externalConfigPropName
			});

			this._publish(this._tabsDisplayer.getChannel('SHOW'), {
				node: this.contentNode
			});
		},

		_onGotExternalConfig: function(evt) {
+18 −118
Original line number Diff line number Diff line
@@ -3,13 +3,11 @@ define([
	, 'dojo/_base/lang'
	, 'src/component/atlas/_AtlasLayersManagement'
	, 'src/redmicConfig'
	, 'templates/ServiceOGCAtlasList'
], function(
	declare
	, lang
	, _AtlasLayersManagement
	, redmicConfig
	, ActivityLayersList
) {

	return declare(_AtlasLayersManagement, {
@@ -20,101 +18,12 @@ define([
		constructor: function(args) {

			this.config = {
				target: redmicConfig.services.atlasLayer,
				templateTargetChange: 'activityLayers',
				_activityLayers: {}
				target: redmicConfig.services.atlasLayer
			};

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

		_setMainConfigurations: function() {

			this.browserConfig = this._merge([{
				template: ActivityLayersList,
				rowConfig: {
					buttonsConfig: {
						listButton: [{
							icon: 'fa-toggle-on',
							altIcon: 'fa-toggle-off',
							btnId: 'toggleShowLayer',
							title: 'layer',
							state: false,
							returnItem: true
						}]
					}
				}
			}, this.browserConfig || {}], {
				arrayMergingStrategy: 'concatenate'
			});

			this.inherited(arguments);
		},

		_defineSubscriptions: function() {

			this.inherited(arguments);

			this.subscriptionsConfig.push({
				channel : this.browser.getChannel('BUTTON_EVENT'),
				callback: "_subActivityLayersListButtonEvent"
			});
		},

		_refreshModules: function() {

			this._emitEvt('REFRESH');
		},

		_subActivityLayersListButtonEvent: function(res) {

			var btnId = res.btnId;

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

		_onToggleShowLayer: function(obj) {

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

		_updateToggleShowLayerButton: function(layerId, action) {

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

		_addMapLayer: function(layerId, layerItem) {

			this._updateToggleShowLayerButton(layerId, 'CHANGE_ROW_BUTTON_TO_MAIN_CLASS');

			var layerInstance = this._activityLayers[layerId];

			this._publish(this.map.getChannel('ADD_LAYER'), {
				layer: layerInstance,
				atlasItem: layerItem
			});
		},

		_removeMapLayer: function(layerId) {

			this._updateToggleShowLayerButton(layerId, 'CHANGE_ROW_BUTTON_TO_ALT_CLASS');

			var layerInstance = this._activityLayers[layerId];

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

		_onActivityLayersData: function(res) {

			var layersData = this._getDataToAddToBrowser(res);
@@ -123,40 +32,31 @@ define([
				data: layersData,
				target: this._activityLayersTarget
			});

			this._activityLayers = {};

			layersData.forEach(lang.hitch(this, this._processActivityLayerItem));
		},

		_getDataToAddToBrowser: function(res) {

			return res.data.data;
		},

		_processActivityLayerItem: function(element, index) {

			this._createLayer(element);
			var items = res.data.data;

			if (index === 0) {
				this._addMapLayer(element.id, element);
			}
		},

		_createLayer: function(layer) {
			return items.map(lang.hitch(this, function(item) {

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

			layerConfiguration = this._merge([layerConfiguration, {
				mapChannel: this.map.getChannel(),
				selectorChannel: this.getChannel()
			}]);
				layerConfiguration.mapChannel = this.map.getChannel();

			var mapLayerInstance = new layerDefinition(layerConfiguration),
				mapLayerId = this._getAtlasLayerId(layer);

			this._activityLayers[mapLayerId] = mapLayerInstance;
				return {
					id: itemId,
					label: layerLabel,
					originalItem: item,
					layer: {
						definition: layerDefinition,
						props: layerConfiguration
					}
				};
			}));
		}
	});
});