Commit 499155a7 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Migra de diseño y reubica más widgets

Migra al nuevo diseño de mapa a los widgets de citas y de
infraestructuras relacionadas con una actividad.

Reubica ficheros de definición de los widgets, anteriormente presentes
en el directorio de main del diseño de details, para unificarlos con los
nuevos en el directorio widgets de la vista detalle de actividad.
parent 13d70cd9
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/detail/activity/widget/ActivityTrackingMap'
	, 'app/details/views/ActivityAreaMapBase'
	, 'app/details/views/ActivityCitationMapBase'
	, 'src/detail/activity/widget/ActivityAreaMap'
	, 'src/detail/activity/widget/ActivityCitationMap'
	, 'src/detail/activity/widget/ActivityFixedObservationSeriesList'
	, 'src/detail/activity/widget/ActivityFixedObservationSeriesMap'
	, 'src/detail/activity/widget/ActivityFixedTimeseriesLineCharts'
	, 'src/detail/activity/widget/ActivityFixedTimeseriesMap'
	, 'src/detail/activity/widget/ActivityFixedTimeseriesWindrose'
	, 'app/details/views/ActivityInfrastructureMapBase'
	, 'src/detail/activity/widget/ActivityInfrastructureMap'
	, 'app/details/views/ActivityLayerMapBase'
	, 'src/detail/activity/widget/ActivityTrackingMap'
	, 'src/util/Credentials'
	, 'src/component/base/_Filter'
	, 'src/component/browser/_ButtonsInRow'
@@ -31,16 +31,16 @@ define([
], function(
	declare
	, lang
	, ActivityTrackingMap
	, ActivityAreaMapBase
	, ActivityCitationMapBase
	, ActivityAreaMap
	, ActivityCitationMap
	, ActivityFixedObservationSeriesList
	, ActivityFixedObservationSeriesMap
	, ActivityFixedTimeseriesLineCharts
	, ActivityFixedTimeseriesMap
	, ActivityFixedTimeseriesWindrose
	, ActivityInfrastructureMapBase
	, ActivityInfrastructureMap
	, ActivityLayerMapBase
	, ActivityTrackingMap
	, Credentials
	, _Filter
	, _ButtonsInRow
@@ -268,7 +268,7 @@ define([
			return {
				width: 6,
				height: 6,
				type: ActivityCitationMapBase,
				type: ActivityCitationMap,
				props: {
					title: 'citations',
					pathVariableId: this._activityData.id
@@ -314,7 +314,7 @@ define([
			return {
				width: 6,
				height: 6,
				type: ActivityInfrastructureMapBase,
				type: ActivityInfrastructureMap,
				props: {
					title: 'infrastructures',
					pathVariableId: this._activityData.id
@@ -327,7 +327,7 @@ define([
			return {
				width: 6,
				height: 6,
				type: ActivityAreaMapBase,
				type: ActivityAreaMap,
				props: {
					title: 'area',
					pathVariableId: this._activityData.id
+128 −0
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/component/base/_Filter'
	, 'src/component/base/_Module'
	, 'src/component/base/_Show'
	, 'src/component/base/_Store'
	, 'src/design/map/_AddAtlasComponent'
	, 'src/design/map/_AddBrowserComponent'
	, 'src/design/map/_AddMapLayerComponent'
	, 'src/design/map/_MapDesignController'
	, 'src/design/map/_MapDesignWithContentLayout'
	, 'src/redmicConfig'
	, 'templates/SpeciesDistributionPopup'
	, 'templates/CitationList'
], function(
	declare
	, lang
	, _Filter
	, _Module
	, _Show
	, _Store
	, _AddAtlasComponent
	, _AddBrowserComponent
	, _AddMapLayerComponent
	, _MapDesignController
	, _MapDesignWithContentLayout
	, redmicConfig
	, TemplatePopup
	, TemplateList
) {

	return declare([_Module, _Show, _Store, _Filter, _MapDesignController, _MapDesignWithContentLayout,
		_AddAtlasComponent, _AddBrowserComponent, _AddMapLayerComponent], {
		//	summary:
		//		Widget para mostrar en un mapa las ubicaciones de citas asociadas a una actividad.

		constructor: function(args) {

			const defaultConfig = {
				enabledMapLayerExtensions: {
					radius: true
				},
				_dataTarget: redmicConfig.services.citationByActivity,
				mapLayerPopupTemplate: TemplatePopup
			};

			lang.mixin(this, this._merge([this, defaultConfig, args]));
		},

		_setOwnCallbacksForEvents: function() {

			this.inherited(arguments);

			this._onEvt('ME_OR_ANCESTOR_SHOWN', lang.hitch(this, this._onMeOrAncestorShown));
		},

		_setConfigurations: function() {

			this.inherited(arguments);

			this.mergeComponentAttribute('browserConfig', {
				template: TemplateList
			});
		},

		_beforeInitialize: function() {

			this.inherited(arguments);

			const queryChannel = this.queryChannel;

			this.mergeComponentAttribute('browserConfig', {
				queryChannel
			});

			this.mergeComponentAttribute('searchConfig', {
				queryChannel
			});
		},

		_onMeOrAncestorShown: function() {

			const replacedTarget = this._getTargetWithVariableReplaced();

			this._updateComponentTargetValues(replacedTarget);
			this._requestDataFromReplacedTarget(replacedTarget);
		},

		_getTargetWithVariableReplaced: function() {

			const replaceObj = {
				id: this.pathVariableId
			};

			return lang.replace(this._dataTarget, replaceObj);
		},

		_updateComponentTargetValues: function(replacedTarget) {

			const browserInstance = this.getComponentInstance('browser'),
				searchInstance = this.getComponentInstance('search'),
				mapLayerInstance = this.getComponentInstance('mapLayer');

			this._publish(mapLayerInstance.getChannel('CHANGE_TARGET'), {
				target: replacedTarget
			});

			this._publish(browserInstance.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});

			this._publish(searchInstance.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});
		},

		_requestDataFromReplacedTarget: function(replacedTarget) {

			this._publish(this.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});
		}
	});
});
+158 −0
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/component/base/_Filter'
	, 'src/component/base/_Module'
	, 'src/component/base/_Show'
	, 'src/component/base/_Store'
	, 'src/design/map/_AddAtlasComponent'
	, 'src/design/map/_AddBrowserComponent'
	, 'src/design/map/_AddMapLayerComponent'
	, 'src/design/map/_MapDesignController'
	, 'src/design/map/_MapDesignWithContentLayout'
	, 'src/redmicConfig'
	, 'templates/InfrastructurePopup'
	, 'templates/InfrastructureList'
], function(
	declare
	, lang
	, _Filter
	, _Module
	, _Show
	, _Store
	, _AddAtlasComponent
	, _AddBrowserComponent
	, _AddMapLayerComponent
	, _MapDesignController
	, _MapDesignWithContentLayout
	, redmicConfig
	, TemplatePopup
	, TemplateList
) {

	return declare([_Module, _Show, _Store, _Filter, _MapDesignController, _MapDesignWithContentLayout,
		_AddAtlasComponent, _AddBrowserComponent, _AddMapLayerComponent], {
		//	summary:
		//		Widget para mostrar en un mapa las ubicaciones de infraestructuras asociadas a una actividad.

		constructor: function(args) {

			const defaultConfig = {
				_dataTarget: redmicConfig.services.infrastructureByActivity,
				mapLayerPopupTemplate: TemplatePopup
			};

			lang.mixin(this, this._merge([this, defaultConfig, args]));
		},

		_setOwnCallbacksForEvents: function() {

			this.inherited(arguments);

			this._onEvt('ME_OR_ANCESTOR_SHOWN', lang.hitch(this, this._onMeOrAncestorShown));
		},

		_setConfigurations: function() {

			this.inherited(arguments);

			this.mergeComponentAttribute('browserConfig', {
				template: TemplateList,
				rowConfig: {
					buttonsConfig: {
						listButton: [{
							condition: "url",
							icon: "fa-link",
							btnId: "infrastructureUrl",
							returnItem: true,
							title: "url"
						}]
					}
				}
			}, {
				arrayMergingStrategy: 'concatenate'
			});
		},

		_beforeInitialize: function() {

			this.inherited(arguments);

			const queryChannel = this.queryChannel;

			this.mergeComponentAttribute('browserConfig', {
				queryChannel
			});

			this.mergeComponentAttribute('searchConfig', {
				queryChannel
			});
		},

		_defineSubscriptions: function() {

			this.inherited(arguments);

			const browserInstance = this.getComponentInstance('browser');

			this.subscriptionsConfig.push({
				channel : browserInstance.getChannel('BUTTON_EVENT'),
				callback: '_subBrowserInfrastructureUrlButtonEvent',
				options: {
					predicate: (evt) => evt?.btnId === 'infrastructureUrl'
				}
			});
		},

		_subBrowserInfrastructureUrlButtonEvent: function(res) {

			globalThis.open(res.item?.url, '_blank');
		},

		_onMeOrAncestorShown: function() {

			const replacedTarget = this._getTargetWithVariableReplaced();

			this._updateComponentTargetValues(replacedTarget);
			this._requestDataFromReplacedTarget(replacedTarget);
		},

		_getTargetWithVariableReplaced: function() {

			const replaceObj = {
				id: this.pathVariableId
			};

			return lang.replace(this._dataTarget, replaceObj);
		},

		_updateComponentTargetValues: function(replacedTarget) {

			const browserInstance = this.getComponentInstance('browser'),
				searchInstance = this.getComponentInstance('search'),
				mapLayerInstance = this.getComponentInstance('mapLayer');

			this._publish(mapLayerInstance.getChannel('CHANGE_TARGET'), {
				target: replacedTarget
			});

			this._publish(browserInstance.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});

			this._publish(searchInstance.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});
		},

		_requestDataFromReplacedTarget: function(replacedTarget) {

			this._publish(this.getChannel('UPDATE_TARGET'), {
				target: replacedTarget,
				refresh: true
			});
		}
	});
});
+0 −175
Original line number Diff line number Diff line
define([
	"app/designs/base/_Main"
	, "app/designs/details/Controller"
	, "app/designs/details/Layout"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "src/component/map/layer/PruneClusterLayerImpl"
	, "src/component/map/layer/_RadiusOnClick"
	, "app/designs/mapWithSideContent/main/Geographic"
], function(
	_Main
	, Controller
	, Layout
	, declare
	, lang
	, PruneClusterLayerImpl
	, _RadiusOnClick
	, Geographic
){
	return declare([Layout, Controller, _Main], {
		//	summary:
		//		Vista detalle de ActivityMap.

		constructor: function(args) {

			this.config = {
				_titleRightButtonsList: [],
				_activeRadius: true,
				noScroll: true,
				propsWidget: {
					omitTitleBar: true,
					resizable: false
				},
				targetReplaceParameter: 'id'
			};

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

		_setMainConfigurations: function() {

			this._replacePathVariableIdInTarget();

			this.widgetConfigs = this._merge([{
				geographic: {
					width: 6,
					height: 6,
					type: Geographic,
					props: {
						title: 'map',
						target: this.targetChange,
						classWindowContent: "view",
						filterConfig: {
							initQuery: {
								size: null
							}
						},
						browserConfig: {
							rowConfig: {
								buttonsConfig: {
									listButton: [{
										icon: "fa-map-marker",
										title: 'mapCentering',
										btnId: "mapCentering",
										returnItem: true
									}]
								}
							}
						}
					}
				}
			}, this.widgetConfigs || {}], {
				arrayMergingStrategy: 'concatenate'
			});

			this.layerConfig = this._merge([{
				idProperty: 'uuid',
				parentChannel: this.getChannel(),
				categoryStyle: "bubbles",
				getPopupContent: lang.hitch(this, this._getPopupContent),
				simpleSelection: true,
				getMarkerCategory: function(feature) {

					if (feature.properties && feature.properties.infrastructureType)
						return feature.properties.infrastructureType.id - 1;
					return 0;
				}
			}, this.layerConfig || {}]);
		},

		_replacePathVariableIdInTarget: function() {

			var replaceObj = {};
			replaceObj[this.targetReplaceParameter] = this.pathVariableId;

			this.targetChange = lang.replace(this.templateTargetChange, replaceObj);
		},

		_initialize: function() {

			if (!this.definitionLayer) {
				this.definitionLayer = [PruneClusterLayerImpl];
			}

			if (this._activeRadius) {
				this.definitionLayer.push(_RadiusOnClick);
			}

			this._layerDefinition = declare(this.definitionLayer);
		},

		_afterShow: function() {

			if (this.layerInstance) {
				this.startup();
				return;
			}

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

			this.layerConfig = this._merge([{
				mapChannel: widgetInstance.getChildChannel("map"),
				selectorChannel: widgetInstance.getChannel()
			}, this.layerConfig || {}]);

			this.layerInstance = new this._layerDefinition(this.layerConfig);

			this._publish(widgetInstance.getChildChannel("map", "ADD_LAYER"), this.layerInstance);

			this._publish(widgetInstance.getChildChannel("mapCenteringGateway", "ADD_CHANNELS_DEFINITION"), {
				channelsDefinition: [{
					input: widgetInstance.getChildChannel("browser", "BUTTON_EVENT"),
					output: this.layerInstance.getChannel("SET_CENTER"),
					subMethod: "setCenter"
				},{
					input: widgetInstance.getChildChannel("browser", "BUTTON_EVENT"),
					output: this.layerInstance.getChannel("ANIMATE_MARKER"),
					subMethod: "animateMarker"
				}]
			});

			this.startup();
		},

		_clearModules: function() {

			var widgetInstance = this._getWidgetInstance('geographic');
			this._publish(widgetInstance.getChannel("CLEAR"));
			this._publish(widgetInstance.getChannel("REFRESH"));
		},

		_refreshModules: function() {

			this._replacePathVariableIdInTarget();

			this.layerInstance && this._publish(this.layerInstance.getChannel("CHANGE_TARGET"), {
				target: this.targetChange
			});

			var widgetInstance = this._getWidgetInstance('geographic');
			this._publish(widgetInstance.getChannel("UPDATE_TARGET"), {
				target: this.targetChange,
				refresh: true
			});
		},

		_getPopupContent: function(data) {

			return this.templatePopup({
				i18n: this.i18n,
				feature: data.feature
			});
		}
	});
});
Loading