kopia lustrzana https://github.com/simonw/datasette
rodzic
20b1de86a1
commit
ea340cf320
|
@ -88,9 +88,6 @@
|
|||
</div>
|
||||
<label class="sort_by_desc small-screen-only"><input type="checkbox" name="_sort_by_desc"{% if sort_desc %} checked{% endif %}> descending</label>
|
||||
{% endif %}
|
||||
{% for facet in sorted_facet_results %}
|
||||
<input type="hidden" name="_facet" value="{{ facet.name }}">
|
||||
{% endfor %}
|
||||
{% for key, value in form_hidden_args %}
|
||||
<input type="hidden" name="{{ key }}" value="{{ value }}">
|
||||
{% endfor %}
|
||||
|
|
|
@ -778,6 +778,12 @@ class TableView(RowTableShared):
|
|||
)
|
||||
self.ds.update_with_inherited_metadata(metadata)
|
||||
form_hidden_args = []
|
||||
# Add currently selected facets
|
||||
for arg in special_args:
|
||||
if arg == "_facet" or arg.startswith("_facet_"):
|
||||
form_hidden_args.extend(
|
||||
(arg, item) for item in request.args.getlist(arg)
|
||||
)
|
||||
for arg in ("_fts_table", "_fts_pk"):
|
||||
if arg in special_args:
|
||||
form_hidden_args.append((arg, special_args[arg]))
|
||||
|
|
|
@ -448,12 +448,16 @@ def test_facet_display(app_client):
|
|||
|
||||
|
||||
def test_facets_persist_through_filter_form(app_client):
|
||||
response = app_client.get("/fixtures/facetable?_facet=planet_int&_facet=city_id")
|
||||
response = app_client.get(
|
||||
"/fixtures/facetable?_facet=planet_int&_facet=city_id&_facet_array=tags"
|
||||
)
|
||||
assert response.status == 200
|
||||
inputs = Soup(response.body, "html.parser").find("form").findAll("input")
|
||||
hiddens = [i for i in inputs if i["type"] == "hidden"]
|
||||
assert [("_facet", "city_id"), ("_facet", "planet_int")] == [
|
||||
(hidden["name"], hidden["value"]) for hidden in hiddens
|
||||
assert [(hidden["name"], hidden["value"]) for hidden in hiddens] == [
|
||||
("_facet", "planet_int"),
|
||||
("_facet", "city_id"),
|
||||
("_facet_array", "tags"),
|
||||
]
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue