Skip to content

Commit

Permalink
✨ Live filtering (#520)
Browse files Browse the repository at this point in the history
* initial commit

* remove apply filter button

* refactored to remove addition script function

* update from oninput to onchange

* remove apply filters methods
  • Loading branch information
mitchdawson1982 authored Jul 9, 2024
1 parent 54bdbff commit 797e4ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
13 changes: 11 additions & 2 deletions home/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class SearchForm(forms.Form):
"form": "searchform",
"class": "govuk-select",
"aria-label": "Domain",
"onchange": "document.getElementById('searchform').submit();",
}
),
)
Expand All @@ -107,14 +108,22 @@ class SearchForm(forms.Form):
choices=get_where_to_access_choices,
required=False,
widget=forms.CheckboxSelectMultiple(
attrs={"class": "govuk-checkboxes__input", "form": "searchform"}
attrs={
"class": "govuk-checkboxes__input",
"form": "searchform",
"onchange": "document.getElementById('searchform').submit();",
}
),
)
entity_types = forms.MultipleChoiceField(
choices=get_entity_types,
required=False,
widget=forms.CheckboxSelectMultiple(
attrs={"class": "govuk-checkboxes__input", "form": "searchform"}
attrs={
"class": "govuk-checkboxes__input",
"form": "searchform",
"onchange": "document.getElementById('searchform').submit();",
}
),
)
sort = forms.ChoiceField(
Expand Down
4 changes: 0 additions & 4 deletions templates/partial/filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ <h2 class="govuk-heading-m">Filter</h2>
{% include "partial/selected_filters.html" %}
{% endif %}
<div class="moj-filter__options">
<a href="#search-results" class="govuk-skip-link extra-skip-link" data-module="govuk-skip-link">Skip to results</a>
<button form="searchform" class="govuk-button" data-module="govuk-button" data-test-id="apply-filters">
Apply filters
</button>
<div class="govuk-form-group">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">Domain</legend>
Expand Down
5 changes: 0 additions & 5 deletions tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ def selected_filter_tag(self, value) -> WebElement:
def clear_filters(self) -> WebElement:
return self.selenium.find_element(By.ID, "clear_filter")

def apply_filters_button(self) -> WebElement:
return self.selenium.find_element(
By.CSS_SELECTOR, 'button[data-test-id="apply-filters"]'
)

def current_page(self) -> WebElement:
return self.selenium.find_element(
By.CLASS_NAME, "govuk-pagination__item--current"
Expand Down
9 changes: 0 additions & 9 deletions tests/selenium/test_search_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_apply_domain_filters(self):
domain = "Prisons"
self.start_on_the_search_page()
self.select_domain(domain)
self.click_apply_filters()
self.verify_i_am_on_the_search_page()
self.verify_i_have_results()
self.verify_domain_selected(domain)
Expand Down Expand Up @@ -88,7 +87,6 @@ def test_filters_query_and_sort_persist(self):
domain = "Prisons"
self.start_on_the_search_page()
self.select_domain(domain)
self.click_apply_filters()
self.enter_a_query_and_submit("nomis")
self.click_option("Ascending")
self.click_on_the_search_button()
Expand Down Expand Up @@ -117,9 +115,7 @@ def test_adding_a_filter_resets_pagination(self):
self.start_on_the_search_page()
self.click_next_page()
self.verify_page("2")

self.select_domain("Prisons")
self.click_apply_filters()
self.verify_page("1")

def test_clear_single_filter(self):
Expand All @@ -130,7 +126,6 @@ def test_clear_single_filter(self):
domain = "Prisons"
self.start_on_the_search_page()
self.select_domain(domain)
self.click_apply_filters()
self.verify_domain_selected(domain)
self.click_clear_selected_filter(domain)
self.verify_unselected_domain()
Expand All @@ -147,7 +142,6 @@ def test_clear_all_filters(self):
self.select_domain(domain)
for filter in filters:
self.click_option(filter)
self.click_apply_filters()
self.verify_domain_selected(domain)
self.verify_checkbox_filters_selected(filters)
self.click_clear_filters()
Expand Down Expand Up @@ -207,9 +201,6 @@ def select_domain(self, domain):
def click_option(self, sortby):
self.search_page.sort_label(sortby).click()

def click_apply_filters(self):
self.search_page.apply_filters_button().click()

def click_clear_selected_filter(self, name):
self.search_page.selected_filter_tag(name).click()

Expand Down

0 comments on commit 797e4ad

Please sign in to comment.