kopia lustrzana https://github.com/simonw/datasette
Fix for cog menu default facet bug, closes #1469
rodzic
a673a93b57
commit
763d0a0faa
|
@ -129,16 +129,15 @@ var DROPDOWN_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" heig
|
||||||
hideColumn.parentNode.style.display = "none";
|
hideColumn.parentNode.style.display = "none";
|
||||||
}
|
}
|
||||||
/* Only show facet if it's not the first column, not selected, not a single PK */
|
/* Only show facet if it's not the first column, not selected, not a single PK */
|
||||||
|
var displayedFacets = Array.from(
|
||||||
|
document.querySelectorAll(".facet-info")
|
||||||
|
).map((el) => el.dataset.column);
|
||||||
var isFirstColumn =
|
var isFirstColumn =
|
||||||
th.parentElement.querySelector("th:first-of-type") == th;
|
th.parentElement.querySelector("th:first-of-type") == th;
|
||||||
var isSinglePk =
|
var isSinglePk =
|
||||||
th.getAttribute("data-is-pk") == "1" &&
|
th.getAttribute("data-is-pk") == "1" &&
|
||||||
document.querySelectorAll('th[data-is-pk="1"]').length == 1;
|
document.querySelectorAll('th[data-is-pk="1"]').length == 1;
|
||||||
if (
|
if (isFirstColumn || displayedFacets.includes(column) || isSinglePk) {
|
||||||
isFirstColumn ||
|
|
||||||
params.getAll("_facet").includes(column) ||
|
|
||||||
isSinglePk
|
|
||||||
) {
|
|
||||||
facetItem.parentNode.style.display = "none";
|
facetItem.parentNode.style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
facetItem.parentNode.style.display = "block";
|
facetItem.parentNode.style.display = "block";
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
{% if facet_results %}
|
{% if facet_results %}
|
||||||
<div class="facet-results">
|
<div class="facet-results">
|
||||||
{% for facet_info in sorted_facet_results %}
|
{% for facet_info in sorted_facet_results %}
|
||||||
<div class="facet-info facet-{{ database|to_css_class }}-{{ table|to_css_class }}-{{ facet_info.name|to_css_class }}" id="facet-{{ facet_info.name|to_css_class }}">
|
<div class="facet-info facet-{{ database|to_css_class }}-{{ table|to_css_class }}-{{ facet_info.name|to_css_class }}" id="facet-{{ facet_info.name|to_css_class }}" data-column="{{ facet_info.name }}">
|
||||||
<p class="facet-info-name">
|
<p class="facet-info-name">
|
||||||
<strong>{{ facet_info.name }}{% if facet_info.type != "column" %} ({{ facet_info.type }}){% endif %}
|
<strong>{{ facet_info.name }}{% if facet_info.type != "column" %} ({{ facet_info.type }}){% endif %}
|
||||||
{% if show_facet_counts %} <span class="facet-info-total">{% if facet_info.truncated %}>{% endif %}{{ facet_info.results|length }}</span>{% endif %}
|
{% if show_facet_counts %} <span class="facet-info-total">{% if facet_info.truncated %}>{% endif %}{{ facet_info.results|length }}</span>{% endif %}
|
||||||
|
|
Ładowanie…
Reference in New Issue