Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions docsearch/templates/docsearch/base_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ <h4>Limit your search</h4>
</button>
<div id="facet-panel-collapse" class="facets-collapse collapse" style="width:100%">
{% for facet_field in view.facet_fields %}
{% if facet_field == "section" and "area_exact" in selected_facet_fields or facet_field != "section" %}

@xmedr xmedr Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation for this if and its related endif seem to be a little off

<div class="card mt-3">
<div class="card-header p-0" id="facet-{{ facet_field }}-header">
<h5 class="mb-0">
Expand Down Expand Up @@ -170,6 +171,7 @@ <h5 class="mb-0">
</div>
</div>
{% endwith %}
{% endif %}
{% endfor %}
</div>
</div>
Expand Down Expand Up @@ -554,10 +556,23 @@ <h3>
}
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<relatedGeoEntityFacets.length; i++) {
Expand All @@ -568,21 +583,48 @@ <h3>
}
}
}

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);
});
}
}).addTo(map);

// 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<selectedFacets.length; i++) {
var sf = selectedFacets[i];
if (sf.indexOf('area_exact:') === 0) {
selectedAreas[sf.split(':')[1]] = true;
} else if (sf.indexOf('area_arr_exact:') === 0) {
selectedAreas[sf.split(':')[1]] = true;
}
}
// If any area is selected, filter features to only those in selectedAreas
var featuresToAdd = data.features;
if (Object.keys(selectedAreas).length > 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);
}
});
}

Expand Down