Commit 35b8164d authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Corrige uso de facets con campos anidados

En la anterior reimplementación, se introdujo un fallo en el
procesamiento de propiedades de agregación anidadas en array,
permitiendo sólo anidamientos al primer nivel. Se ha restaurado la
funcionalidad original.

Se definen atributos sobreescribibles para la gestión de anidados
(prefijo y separadores).
parent 6273ecce
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ define([
				openFacets: false,
				maxInitialEntries: 5,
				aggs: null,
				aggGroupNamePrefix: 'sterms',
				aggGroupNameSeparator: '#',
				nestedAggNameSuffix: '$',
				_nestedAggs: {},
				_facetsInstances: {},
				_selectionByAggregationGroup: {},
@@ -162,7 +165,9 @@ define([

		_getNestedField: function(field) {

			return field.replace('.', '$.');
			var nestedAggName = this._nestedAggs[field];

			return field.replace(nestedAggName, nestedAggName + this.nestedAggNameSuffix);
		},

		_subAvailableFacets: function(availableAggregationGroups) {
@@ -175,13 +180,18 @@ define([

			var cleanAggregationGroups = {};
			for (var key in availableAggregationGroups) {
				var keySplitted = key.split('#');
				cleanAggregationGroups[keySplitted.pop()] = availableAggregationGroups[key];
				var cleanAggGroupName = this._getAggregationGroupNameWithoutPrefix(key);
				cleanAggregationGroups[cleanAggGroupName] = availableAggregationGroups[key];
			}

			this._showFacetsGroups(cleanAggregationGroups);
		},

		_getAggregationGroupNameWithoutPrefix: function(aggGroupName) {

			return aggGroupName.split(this.aggGroupNameSeparator).pop();
		},

		_reset: function() {

			this._selectionByAggregationGroup = {};
@@ -200,7 +210,12 @@ define([
				}

				if (!aggGroup.buckets) {
					if (aggGroup[groupName]) {
						aggGroup = aggGroup[groupName];
					} else {
						var prefixedAggGroupName = this._getAggregationGroupNameWithPrefix(groupName);
						aggGroup = aggGroup[prefixedAggGroupName];
					}
				}

				this._showFacetsGroup(aggGroup, groupName);
@@ -214,6 +229,15 @@ define([
			}
		},

		_getAggregationGroupNameWithPrefix: function(cleanAggGroupName) {

			if (cleanAggGroupName.indexOf(this.aggGroupNameSeparator) !== -1) {
				return cleanAggGroupName;
			}

			return this.aggGroupNamePrefix + this.aggGroupNameSeparator + cleanAggGroupName;
		},

		_showFacetsGroup: function(aggregationGroup, groupName) {

			var prevSelection = this._getAggregationGroupPreviousSelection(groupName),