mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Clarified relationship between metadata and _facet= facets, updated docs - refs @255
This commit is contained in:
parent
b263da78e3
commit
566f2d31d6
3 changed files with 91 additions and 40 deletions
|
|
@ -104,7 +104,12 @@
|
|||
<div class="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 }}">
|
||||
<p class="facet-info-name"><strong>{{ facet_info.name }}</strong> <a href="{{ path_with_removed_args(request, {'_facet': facet_info['name']}) }}">✖</a></p>
|
||||
<p class="facet-info-name">
|
||||
<strong>{{ facet_info.name }}</strong>
|
||||
{% if facet_hideable(facet_info.name) %}
|
||||
<a href="{{ path_with_removed_args(request, {'_facet': facet_info['name']}) }}">✖</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<ul>
|
||||
{% for facet_value in facet_info.results %}
|
||||
<li><a href="{{ facet_value.toggle_url }}">{{ facet_value.label }}</a> {{ "{:,}".format(facet_value.count) }}</li>
|
||||
|
|
|
|||
|
|
@ -537,10 +537,12 @@ class TableView(RowTableShared):
|
|||
|
||||
# facets support
|
||||
FACET_SIZE = 20
|
||||
metadata_facets = table_metadata.get("facets", [])
|
||||
facets = metadata_facets[:]
|
||||
try:
|
||||
facets = request.args["_facet"]
|
||||
facets.extend(request.args["_facet"])
|
||||
except KeyError:
|
||||
facets = table_metadata.get("facets", [])
|
||||
pass
|
||||
facet_results = {}
|
||||
for column in facets:
|
||||
facet_sql = """
|
||||
|
|
@ -719,6 +721,7 @@ class TableView(RowTableShared):
|
|||
key=lambda f: (len(f["results"]), f["name"]),
|
||||
reverse=True
|
||||
),
|
||||
"facet_hideable": lambda facet: facet not in metadata_facets,
|
||||
"is_sortable": any(c["sortable"] for c in display_columns),
|
||||
"path_with_replaced_args": path_with_replaced_args,
|
||||
"path_with_removed_args": path_with_removed_args,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue