Commit 101bdcf6 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Corrige carga de datos de infraestructuras

parent 73579b0f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -10,9 +10,10 @@ define([

		_addData: function(response) {

			// TODO evitar sobreescribir respuesta, en su lugar adaptar su lectura donde haga falta
			if (response.data.features) {
				response.data.data = response.data.features;
				delete response.data.features;
				//delete response.data.features;
			}

			const data = response.data,
+2 −1
Original line number Diff line number Diff line
@@ -15,8 +15,9 @@ define([
				this.inherited(arguments);
			}

			// TODO evitar sobreescribir respuesta, en su lugar adaptar su lectura donde haga falta
			response.data.data = response.data.features;
			delete response.data.features;
			//delete response.data.features;

			this.inherited(arguments);
		},
+4 −2
Original line number Diff line number Diff line
@@ -224,11 +224,13 @@ define([
			var requesterId = action === '_suggest' ? this.getOwnChannel() : null;

			this._emitEvt('REQUEST', {
				method: this.methodSuggest,
				target: this._getTarget(),
				action: action,
				requesterId: requesterId,
				method: this.methodSuggest,
				params: {
					query: req.data
				}
			});
		},

+2 −2
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ define([
			listenBounds: false,
			listenZoom: false,
			radius: false
		},
		mapLayerPopupTemplate: null
		}
	};

	return declare(null, {
@@ -66,6 +65,7 @@ define([
			this.mergeComponentAttribute('mapLayerConfig', {
				parentChannel,
				selectorChannel: parentChannel,
				target: this.target,
				idProperty: 'uuid',
				simpleSelection: true
			});
+11 −68
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'
@@ -15,7 +14,6 @@ define([
], function(
	declare
	, lang
	, _Filter
	, _Module
	, _Show
	, _Store
@@ -28,8 +26,8 @@ define([
	, TemplateList
) {

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

@@ -37,7 +35,7 @@ define([

			const defaultConfig = {
				ownChannel: 'activityInfrastructureMap',
				_dataTarget: redmicConfig.services.infrastructureByActivity,
				target: redmicConfig.services.infrastructureByActivity,
				mapLayerPopupTemplate: TemplatePopup
			};

@@ -73,82 +71,27 @@ define([
			});
		},

		_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) {
		_infrastructureUrlCallback: function(res) {

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

		_onMeOrAncestorShown: function() {

			const replacedTarget = this._getTargetWithVariableReplaced();

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

		_getTargetWithVariableReplaced: function() {
		_requestData: function() {

			const replaceObj = {
			const path = {
				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('SET_PROPS'), {
				target: replacedTarget
			});
			const method = 'POST',
				target = this.target,
				params = {path};

			this._publish(browserInstance.getChannel('SET_PROPS'), {
				target: replacedTarget
			});

			this._publish(searchInstance.getChannel('SET_PROPS'), {
				target: replacedTarget
			});
		},

		_requestDataFromReplacedTarget: function(replacedTarget) {

			this._publish(this.getChannel('SET_PROPS'), {
				target: replacedTarget
			});
			this._emitEvt('REQUEST', {method, target, params});
		}
	});
});
Loading