[dashboard] Add observable subscribes to newly added facets
@@ -699,36 +699,38 @@ var Collection = function (vm, collection) {
}
self._addObservablesToFacet = function(facet, vm) {
- if (facet.properties) { // Very top facet
- if (facet.properties.facets_form && facet.properties.facets_form.aggregate) { // Only Solr 5+
+ // Very top facet
+ if (facet.properties && facet.properties.facets_form && facet.properties.facets_form.aggregate) { // Only Solr 5+
facet.properties.facets_form.aggregate.metrics = ko.computed(function() {
var _field = self.getTemplateField(facet.widgetType() == 'hit-widget' ? facet.field() : facet.properties.facets_form.field(), self.template.fieldsAttributes());
return self._get_field_operations(_field, facet);
});
- }
- facet.properties.limit.subscribe(function () {
+ if (facet.properties.facets) {
+ facet.properties.facets.subscribe(function(newValue) {
vm.search();
});
- facet.properties.mincount.subscribe(function () {
+ }
+ }
+
+ var facet_properties = facet.properties ? facet.properties : facet; // Old facet, nested facet
+
+ facet_properties.limit.subscribe(function () {
vm.search();
});
- if (facet.properties.gap) {
- facet.properties.gap.subscribe(function () {
+ facet_properties.mincount.subscribe(function () {
vm.search();
});
- }
- if (facet.properties.aggregate) {
- facet.properties.aggregate.function.subscribe(function () {
+ if (facet_properties.gap) {
+ facet_properties.gap.subscribe(function () {
vm.search();
});
}
- if (facet.properties.facets) {
- facet.properties.facets.subscribe(function(newValue) {
+ if (facet_properties.aggregate) {
+ facet_properties.aggregate.function.subscribe(function () {
vm.search();
});
}
- }
// For Solr 5+ facets only
if (typeof facet.template != 'undefined') {
