Commit 05315eaa authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Refactoriza, muestra carga en mapa al pedir info

parent d27058db
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -21,9 +21,11 @@ define([
		//		Visualizador de contenido por pestañas. Recibe publicaciones de módulos que desean mostrarse como una
		//		nueva pestaña.

		constructor: function(args) {
		postMixInProperties: function() {

			this.config = {
			this.inherited(arguments);

			const defaultConfig = {
				ownChannel: 'tabsDisplayer',
				actions: {
					'ADD_TAB': 'addTab',
@@ -35,7 +37,7 @@ define([
				_tabNodesByChannel: {}
			};

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

		_defineSubscriptions: function() {
@@ -103,7 +105,7 @@ define([

			var childContainer = this._getTabNode(req),
				childChannel = req.channel,
				childShowChannel = this._buildChannel(childChannel, this.actions.SHOW);
				childShowChannel = this._buildChannel(childChannel, 'SHOW');

			this._publish(childShowChannel, {
				node: childContainer
+45 −22
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@ define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/component/base/_Module'
	, './_ContentManagement'
	, './_ResultsBrowser'
	, 'src/component/mapQuery/_ContentManagement'
	, 'src/component/mapQuery/_ResultsBrowser'
], function(
	declare
	, lang
@@ -21,6 +21,8 @@ define([

		postMixInProperties: function() {

			this.inherited(arguments);

			const defaultConfig = {
				ownChannel: 'queryOnMap',
				events: {
@@ -34,59 +36,74 @@ define([
					HIDE_LAYERS_INFO: 'hideLayersInfo',
					ADD_INFO_DATA: 'addInfoData',
					ADD_NEW_TEMPLATES: 'addNewTemplates',
					SHOW_LAYERS_INFO: 'showLayersInfo'
				},
					SHOW_LAYERS_INFO: 'showLayersInfo',

				_tabsDisplayerActions: {
					// Map actions
					MAP_CLICKED: 'mapClicked',
					LAYER_ADDED_CONFIRMED: 'layerAddedConfirmed',
					LAYER_REMOVED_CONFIRMED: 'layerRemovedConfirmed',
					LAYER_QUERYING: 'layerQuerying',
					LAYER_INFO: 'layerInfo',
					SET_QUERYABLE_CURSOR: 'setQueryableCursor',
					LAYER_LOADING: 'layerLoading',
					LAYER_LOADED: 'layerLoaded',

					// TabsDisplayer actions
					ADD_TAB: 'addTab',
					SHOW_TAB: 'showTab'
				},

				getMapChannel: null,

				title: this.i18n.layersQueryResults,
				_queryableLayersLoaded: 0,
				_layersWaiting: 0
			};

			this._mergeOwnAttributes(defaultConfig);
		},

			this.title = this.i18n.layersQueryResults;
		_initialize: function() {

			this.inherited(arguments);

			if (!this.getMapChannel) {
				console.error('Map channel not defined for QueryOnMap "%s"', this.getChannel());
			}

			// TODO cuando venga así desde fuera (string en lugar de función), quitar y usar directamente
			this.mapChannel = this.getMapChannel?.();
		},

		_defineSubscriptions: function() {

			this.inherited(arguments);

			var options = {
				predicate: lang.hitch(this, this._chkLayerIsQueryable)
			};

			this.subscriptionsConfig.push({
				channel : this.getMapChannel('MAP_CLICKED'),
				channel : this._buildChannel(this.mapChannel, 'MAP_CLICKED'),
				callback: '_subMapClickedQueryOnMap'
			},{
				channel: this.getMapChannel('LAYER_ADDED_CONFIRMED'),
				channel : this._buildChannel(this.mapChannel, 'LAYER_ADDED_CONFIRMED'),
				callback: '_subLayerAddedQueryOnMap',
				options: options
			},{
				channel: this.getMapChannel('LAYER_REMOVED_CONFIRMED'),
				channel : this._buildChannel(this.mapChannel, 'LAYER_REMOVED_CONFIRMED'),
				callback: '_subLayerRemovedQueryOnMap',
				options: options
			},{
				channel: this.getMapChannel('LAYER_QUERYING'),
				channel : this._buildChannel(this.mapChannel, 'LAYER_QUERYING'),
				callback: '_subLayerQueryingQueryOnMap'
			},{
				channel: this.getMapChannel('LAYER_INFO'),
				channel : this._buildChannel(this.mapChannel, 'LAYER_INFO'),
				callback: '_subLayerInfoQueryOnMap'
			});
		},

		_definePublications: function() {

			this.inherited(arguments);

			this.publicationsConfig.push({
				event: 'HIDE_LAYERS_INFO',
				channel: this.getChannel('HIDE_LAYERS_INFO')
@@ -101,12 +118,20 @@ define([
				channel: this.getChannel('SHOW_LAYERS_INFO')
			},{
				event: 'SET_MAP_QUERYABLE_CURSOR',
				channel: this.getMapChannel('SET_QUERYABLE_CURSOR')
				channel : this._buildChannel(this.mapChannel, 'SET_QUERYABLE_CURSOR')
			},{
				event: 'LOADING',
				channel : this._buildChannel(this.mapChannel, 'LAYER_LOADING')
			},{
				event: 'LOADED',
				channel : this._buildChannel(this.mapChannel, 'LAYER_LOADED')
			});
		},

		_setOwnCallbacksForEvents: function() {

			this.inherited(arguments);

			this.on([
				this.events.HIDE,
				this.events.ANCESTOR_HIDE
@@ -124,7 +149,7 @@ define([

		_tryToAddOwnTab: function() {

			var tabsChannel = this.tabsDisplayerChannel;
			const tabsChannel = this.tabsDisplayerChannel;
			if (!tabsChannel) {
				console.warn('QueryOnMap "%s" tried to add itself as a tab, but no TabsDisplayer channel was found',
					this.getChannel());
@@ -134,7 +159,7 @@ define([
				return;
			}

			this._publish(this._buildChannel(tabsChannel, this._tabsDisplayerActions.ADD_TAB), {
			this._publish(this._buildChannel(tabsChannel, 'ADD_TAB'), {
				title: this.i18n.layersQueryResults,
				iconClass: 'fa fa-info',
				channel: this.getChannel()
@@ -143,7 +168,7 @@ define([

		_tryToFocusOwnTab: function() {

			var tabsChannel = this.tabsDisplayerChannel;
			const tabsChannel = this.tabsDisplayerChannel;
			if (!tabsChannel) {
				console.warn('QueryOnMap "%s" tried to focus own tab, but no TabsDisplayer channel was found',
					this.getChannel());
@@ -152,7 +177,7 @@ define([
			}

			if (!this._showTabChannel) {
				this._showTabChannel = this._buildChannel(tabsChannel, this._tabsDisplayerActions.SHOW_TAB);
				this._showTabChannel = this._buildChannel(tabsChannel, 'SHOW_TAB');
			}

			this._publish(this._showTabChannel, {
@@ -170,9 +195,7 @@ define([
			this._emitEvt('HIDE_LAYERS_INFO');

			if (this._queryableLayersLoaded) {
				this._emitEvt('LOADING', {
					global: true
				});
				this._emitEvt('LOADING');
			}
		},

+28 −25
Original line number Diff line number Diff line
@@ -20,22 +20,7 @@ define([
	, SpeciesDistributionCitation
) {

	return declare(null, {
		//	summary:
		//		Extensión del módulo para las tareas de identificar tipos de datos y correspondencia de capas con
		//		plantillas específicas.

		constructor: function(args) {

			this.config = {
				layerIdSeparator: '_',
				layerIdPrefix: 'layer-',
				layerThemeSeparator: '-',
				typeGroupProperty: 'dataType',
				parentTemplateSuffix: 'Parent',
				childrenTemplateSuffix: 'Children',

				_templatesByTypeGroup: {
	const TemplatesByTypeGroup = {
		//	Podemos sobreescribir las plantillas genéricas de las capas
		//	de atlas especificando el nombre de la capa completo
		//'el-batimetriaIslasParent': AtlasPrimaryList',
@@ -55,10 +40,28 @@ define([

		'sd-sightings-taxon-yearChildren': AtlasRedpromarSecondaryList,
		'sd-exotic-species-sightingChildren': AtlasRedpromarSecondaryList
				}
	};

			lang.mixin(this, this.config, args);
	return declare(null, {
		//	summary:
		//		Extensión del módulo para las tareas de identificar tipos de datos y correspondencia de capas con
		//		plantillas específicas.

		postMixInProperties: function() {

			this.inherited(arguments);

			const defaultConfig = {
				layerIdSeparator: '_',
				layerIdPrefix: 'layer-',
				layerThemeSeparator: '-',
				typeGroupProperty: 'dataType',
				parentTemplateSuffix: 'Parent',
				childrenTemplateSuffix: 'Children',
				_templatesByTypeGroup: TemplatesByTypeGroup
			};

			this._mergeOwnAttributes(defaultConfig);
		},

		_getLayerTemplatesDefinition: function(layerId) {
+14 −13
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'src/component/base/_Show'
	, 'src/component/layout/nestedContent/NestedBrowsersImpl'
	, 'src/component/layout/dataDisplayer/DataDisplayer'
@@ -9,7 +8,6 @@ define([
], function(
	declare
	, lang
	, aspect
	, _Show
	, NestedBrowsersImpl
	, DataDisplayer
@@ -20,21 +18,20 @@ define([
		//	summary:
		//		Extensión del módulo para mostrar los resultados de consulta en listados jerárquicos dinámicos.

		constructor: function(args) {
		postMixInProperties: function() {

			this.config = {
			this.inherited(arguments);

			const defaultConfig = {
				'class': 'queryOnMapContainer'
			};

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

			aspect.after(this, '_beforeInitialize', lang.hitch(this, this._initializeResultsBrowser));
			aspect.after(this, '_definePublications', lang.hitch(this, this._defineResultsBrowserPublications));
			aspect.after(this, '_setOwnCallbacksForEvents',
				lang.hitch(this, this._setResultsBrowserOwnCallbacksForEvents));
			this._mergeOwnAttributes(defaultConfig);
		},

		_initializeResultsBrowser: function() {
		_initialize: function() {

			this.inherited(arguments);

			this._layersInfo = new NestedBrowsersImpl({
				parentChannel: this.getChannel(),
@@ -57,7 +54,9 @@ define([
			});
		},

		_defineResultsBrowserPublications: function() {
		_definePublications: function() {

			this.inherited(arguments);

			this.publicationsConfig.push({
				event: 'HIDE_LAYERS_INFO',
@@ -71,7 +70,9 @@ define([
			});
		},

		_setResultsBrowserOwnCallbacksForEvents: function() {
		_setOwnCallbacksForEvents: function() {

			this.inherited(arguments);

			this._onEvt('SHOW_LAYERS_INFO', lang.hitch(this, this._showResultsAndHidePlaceholder));
			this._onEvt('HIDE_LAYERS_INFO', lang.hitch(this, this._hideResultsAndShowPlaceholder));