Commit 7fd0528b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Permite ocultar facets vacíos, reestructura aggs

Revisa definición y uso de ajustes de agregación, simplificando la
estructura y optimizando su recorrido.

Permite definir para cada campo un valor para 'minCount'. Aplica el
ajuste al listado de observaciones de vista detalle.
parent e5d20424
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -120,23 +120,22 @@ define([
			this._aggregationGroupsDefinition = aggs;
			this._currentAggregationGroups = [];

			for (var item in aggs) {
				var terms = aggs[item].terms,
					field = terms.field,
					nested = terms.nested,
					obj = {
						size: terms.size || 100,
			for (const [key, value] of Object.entries(aggs)) {
				let field = value.field,
					nested = value.nested,
					aggObj = {
						term: key,
						field: field,
						term: item,
						minCount: 0
						size: value.size || 100,
						minCount: value.minCount || 0
					};

				if (nested) {
					obj.nested = nested;
					aggObj.nested = nested;
					this._nestedAggs[field] = nested;
				}

				this._currentAggregationGroups.push(obj);
				this._currentAggregationGroups.push(aggObj);
			}
		},

+40 −107
Original line number Diff line number Diff line
@@ -300,215 +300,148 @@ define([], function() {
	retObj.aggregations = {
		activity: {
			themeInspire: {
				terms: {
				field: 'themeInspire.name'
				}
			},
			activityType: {
				terms: {
				field: 'activityType.name'
				}
			},
			territorialScope: {
				terms: {
				field: 'scope.name'
			}
			}
		},
		activityType: {
			activityField: {
				terms: {
				field: 'activityField.name'
			}
			}
		},
		animal: {
			sex: {
				terms: {
				field: 'sex.name'
				}
			},
			lifeStage: {
				terms: {
				field: 'lifeStage.name'
			}
			}
		},
		atlasLayer: {
			protocols: {
				terms: {
				field: 'protocols.type',
				nested: 'protocols'
				}
			},
			themeInspire: {
				terms: {
				field: 'themeInspire.name'
				}
			},
			keywords: {
				terms: {
				field: 'keywords'
			}
			}
		},
		contact: {
			organisation: {
				terms: {
				field: 'affiliation.name'
			}
			}
		},
		device: {
			deviceType: {
				terms: {
				field: 'deviceType.name'
			}
			}
		},
		document: {
			documentType: {
				terms: {
				field: 'documentType.name'
				}
			},
			language: {
				terms: {
				field: 'language'
			}
			}
		},
		metricsDefinition: {
			metricGroup: {
				terms: {
				field: 'metricGroup.name'
			}
			}
		},
		observationSeries: {
			animal: {
				terms: {
					field: 'observation.animal.name'
				}
				field: 'observation.animal.name',
				minCount: 1
			},
			species: {
				terms: {
					field: 'observation.taxonomy.scientificName'
				}
				field: 'observation.taxonomy.scientificName',
				minCount: 1
			},
			organisation: {
				terms: {
					field: 'observation.organisation.name'
				}
				field: 'observation.organisation.name',
				minCount: 1
			}
		},
		organisation: {
			organisationType: {
				terms: {
				field: 'organisationType.name'
			}
			}
		},
		parameter: {
			parameterType: {
				terms: {
				field: 'parameterType.name'
			}
			}
		},
		platform: {
			platformType: {
				terms: {
				field: 'platformType.name'
			}
			}
		},
		program: {
			territorialScope: {
				terms: {
				field: 'scope.name'
			}
			}
		},
		project: {
			projectGroup: {
				terms: {
				field: 'projectGroup.name'
				}
			},
			territorialScope: {
				terms: {
				field: 'scope.name'
			}
			}
		},
		species: {
			status: {
				terms: {
				field: 'status.name'
				}
			},
			origin: {
				terms: {
				field: 'peculiarity.origin.name'
				}
			},
			endemicity: {
				terms: {
				field: 'peculiarity.endemicity.name'
				}
			},
			permanence: {
				terms: {
				field: 'peculiarity.permanence.name'
				}
			},
			ecology: {
				terms: {
				field: 'peculiarity.ecology.name'
				}
			},
			trophicRegime: {
				terms: {
				field: 'peculiarity.trophicRegime.name'
				}
			},
			interest: {
				terms: {
				field: 'peculiarity.interest.name'
				}
			},
			canaryProtection: {
				terms: {
				field: 'peculiarity.canaryProtection.name'
				}
			},
			spainProtection: {
				terms: {
				field: 'peculiarity.spainProtection.name'
				}
			},
			euProtection: {
				terms: {
				field: 'peculiarity.euProtection.name'
			}
			}
		},
		timeSeriesStations: {
			properties: {
				terms: {
				field: 'properties.measurements.parameter.name',
				nested: 'properties.measurements'
			}
			}
		},
		unit: {
			unitType: {
				terms: {
				field: 'unitType.name'
			}
		}
		}
	};

	retObj.returnFields = {