mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
_facet selections persist through table form, refs #255
This commit is contained in:
parent
514873c629
commit
f4943ca89b
2 changed files with 19 additions and 0 deletions
|
|
@ -81,6 +81,9 @@
|
||||||
</div>
|
</div>
|
||||||
<label class="sort_by_desc"><input type="checkbox" name="_sort_by_desc"{% if sort_desc %} checked{% endif %}> descending</label>
|
<label class="sort_by_desc"><input type="checkbox" name="_sort_by_desc"{% if sort_desc %} checked{% endif %}> descending</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% for facet in facet_results %}
|
||||||
|
<input type="hidden" name="_facet" value="{{ facet }}">
|
||||||
|
{% endfor %}
|
||||||
<input type="submit" value="Apply">
|
<input type="submit" value="Apply">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,22 @@ def test_sort_links(app_client):
|
||||||
] == attrs_and_link_attrs
|
] == attrs_and_link_attrs
|
||||||
|
|
||||||
|
|
||||||
|
def test_facets_persist_through_filter_form(app_client):
|
||||||
|
response = app_client.get(
|
||||||
|
'/test_tables/facetable?_facet=planet_id&_facet=city',
|
||||||
|
gather_request=False
|
||||||
|
)
|
||||||
|
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', 'planet_id'),
|
||||||
|
('_facet', 'city'),
|
||||||
|
] == [
|
||||||
|
(hidden['name'], hidden['value']) for hidden in hiddens
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('path,expected_classes', [
|
@pytest.mark.parametrize('path,expected_classes', [
|
||||||
('/', ['index']),
|
('/', ['index']),
|
||||||
('/test_tables', ['db', 'db-test_tables']),
|
('/test_tables', ['db', 'db-test_tables']),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue