From b65d760a0161f2493f39c8ff93a89fe864932fea Mon Sep 17 00:00:00 2001 From: msj Date: Wed, 15 Jul 2026 10:34:13 -0400 Subject: [PATCH 1/2] Fix searching by area/section facets - only allow faceting by section if an area has been selected - only allow sections in the selected area to be selected - only allow one area to be selected at a time --- .../templates/docsearch/base_search.html | 93 ++++++++++++++----- 1 file changed, 68 insertions(+), 25 deletions(-) diff --git a/docsearch/templates/docsearch/base_search.html b/docsearch/templates/docsearch/base_search.html index 6f78241..37cb5d0 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" %}
@@ -170,6 +171,7 @@
{% endwith %} + {% endif %} {% endfor %}
@@ -340,6 +342,7 @@

} var areaUrl = '{% static "geojson/area.geojson" %}'; + var townshipUrl = '{% static "geojson/township.geojson" %}'; var rangeUrl = '{% static "geojson/range.geojson" %}'; var sectionUrl = '{% static "geojson/section.geojson" %}'; @@ -553,37 +556,77 @@

}); } layer.on('mousedown', function() { - if (featureIsSelected) { - // Remove the facet from the query string - selectedFacets.splice(facetIndex, 1); - } else { - // Add the facet to the query string - if (entity == 'section') { - // Add area, township, and range as well - 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); + } + }); } $('#facet-' + facetField).on('shown.bs.collapse', function() { From ce23f44325863c2c204e1eebe9cc98104fb12a3c Mon Sep 17 00:00:00 2001 From: msj Date: Wed, 15 Jul 2026 10:45:28 -0400 Subject: [PATCH 2/2] Format --- .../templates/docsearch/base_search.html | 127 +++++++++--------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/docsearch/templates/docsearch/base_search.html b/docsearch/templates/docsearch/base_search.html index 37cb5d0..5648e3d 100644 --- a/docsearch/templates/docsearch/base_search.html +++ b/docsearch/templates/docsearch/base_search.html @@ -72,7 +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" %} + {% if facet_field == "section" and "area_exact" in selected_facet_fields or facet_field != "section" %}
@@ -171,7 +171,7 @@
{% endwith %} - {% endif %} + {% endif %} {% endfor %}
@@ -342,7 +342,6 @@

} var areaUrl = '{% static "geojson/area.geojson" %}'; - var townshipUrl = '{% static "geojson/township.geojson" %}'; var rangeUrl = '{% static "geojson/range.geojson" %}'; var sectionUrl = '{% static "geojson/section.geojson" %}'; @@ -556,77 +555,77 @@

}); } layer.on('mousedown', function() { - if (featureIsSelected) { - // Remove the facet from the query string - selectedFacets.splice(facetIndex, 1); - } else { - // 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 (featureIsSelected) { + // Remove the facet from the query string + selectedFacets.splice(facetIndex, 1); + } else { + // 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 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); - } - }); + // When displaying sections, only render those that are in the selected areas + $.getJSON(geojsonUrl, function(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); + } + }); } $('#facet-' + facetField).on('shown.bs.collapse', function() {