diff --git a/docsearch/templates/docsearch/base_search.html b/docsearch/templates/docsearch/base_search.html
index 6f78241..5648e3d 100644
--- a/docsearch/templates/docsearch/base_search.html
+++ b/docsearch/templates/docsearch/base_search.html
@@ -72,6 +72,7 @@
Limit your search
{% for facet_field in view.facet_fields %}
+ {% if facet_field == "section" and "area_exact" in selected_facet_fields or facet_field != "section" %}
{% endwith %}
+ {% endif %}
{% endfor %}
@@ -554,10 +556,23 @@
}
layer.on('mousedown', function() {
if (featureIsSelected) {
- // Remove the facet from the query string
- selectedFacets.splice(facetIndex, 1);
+ // Remove the facet from the query string
+ selectedFacets.splice(facetIndex, 1);
} else {
- // Add the facet to the query string
+ // Only allow one selected area at a time
+ if (entity === 'area') {
+ selectedFacets = selectedFacets.filter(function(sf) {
+ return !(sf.startsWith('area_exact:') || sf.startsWith('area_arr_exact:') ||
+ sf.startsWith('area_exact:') || sf.startsWith('area_arr:') ||
+ sf.startsWith('area:') || sf.startsWith('area_arr:') );
+ }).filter(function(sf) {
+ // Clear any selected sections after selecting an area
+ return !(sf.startsWith('section_exact:') || sf.startsWith('section_arr_exact:') ||
+ sf.startsWith('section_exact:') || sf.startsWith('section_arr:') ||
+ sf.startsWith('section:') || sf.startsWith('section_arr:'));
+ });
+ }
+
if (entity == 'section') {
// Add area, township, and range as well
for (var i=0; i
}
}
}
+
selectedFacets.push(facetString);
}
+
+ const dedupedFacets = Array.from(new Set(selectedFacets));
+
// Redirect to page 1 of the new faceted view
window.location.search = $.param({
'q': query,
- 'selected_facets': selectedFacets,
+ 'selected_facets': dedupedFacets,
}, traditional=true);
});
}
@@ -581,8 +600,31 @@
// Defer the loading of the GeoJSON layer
if (geojsonUrl) {
+ // When displaying sections, only render those that are in the selected areas
$.getJSON(geojsonUrl, function(data) {
- geojsonLayer.addData(data);
+ if (entity === 'section') {
+ // Build a set of selected area values (handles both 'area' and 'area_arr' facet names)
+ var selectedAreas = {};
+ for (var i=0; i 0) {
+ featuresToAdd = data.features.filter(function(f) {
+ var val = f.properties && f.properties.area;
+ return val && selectedAreas.hasOwnProperty(val);
+ });
+ }
+ geojsonLayer.addData({type: 'FeatureCollection', features: featuresToAdd});
+ } else {
+ geojsonLayer.addData(data);
+ }
});
}