diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | t/app/controller/around.t | 8 | ||||
-rw-r--r-- | templates/web/base/report/new/_category_select.html | 1 | ||||
-rw-r--r-- | templates/web/base/report/new/category.html | 2 | ||||
-rw-r--r-- | templates/web/base/reports/_list-filters.html | 3 |
5 files changed, 12 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f724b8f98..d7be16b11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Improve Bing geocoder results. - Add option of checking passwords against Have I Been Pwned. - Add aerial maps option to Bing maps. + - Select matches for both filter category and group. #3110 - Changes: - Mark user as active when sent an email alert. - Bugfixes: diff --git a/t/app/controller/around.t b/t/app/controller/around.t index e35406bb6..ba5f8c48a 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -250,7 +250,10 @@ subtest 'check category, status and extra filtering works on /around' => sub { # Create one open and one fixed report in each category foreach my $category ( @$categories ) { my $contact = $mech->create_contact_ok( category => $category, body_id => $body->id, email => "$category\@example.org" ); - if ($category ne 'Pothole') { + if ($category eq 'Vegetation') { + $contact->set_extra_metadata(group => ['Environment', 'Green']); + $contact->update; + } elsif ($category eq 'Flytipping') { $contact->set_extra_metadata(group => ['Environment']); $contact->update; } @@ -281,6 +284,9 @@ subtest 'check category, status and extra filtering works on /around' => sub { $mech->get_ok( '/around?filter_group=Environment&bbox=' . $bbox ); $mech->content_contains('<option value="Flytipping" selected>'); + + $mech->get_ok( '/around?filter_group=Environment&filter_category=Vegetation&bbox=' . $bbox ); + $mech->content_like(qr/<optgroup label="Environment">.*?<option value="Vegetation" selected>.*?<optgroup label="Green">.*?<option value="Vegetation">/s); }; $json = $mech->get_ok_json( '/around?ajax=1&filter_category=Pothole&bbox=' . $bbox ); diff --git a/templates/web/base/report/new/_category_select.html b/templates/web/base/report/new/_category_select.html index d5aa9842b..61353647d 100644 --- a/templates/web/base/report/new/_category_select.html +++ b/templates/web/base/report/new/_category_select.html @@ -1,3 +1,4 @@ +[% SET filter_group = c.get_param('filter_group') %] [%~ IF category_groups.size ~%] [%~ FOREACH group IN category_groups ~%] [% IF group.name %]<optgroup label="[% group.name %]">[% END %] diff --git a/templates/web/base/report/new/category.html b/templates/web/base/report/new/category.html index b5bfd0251..37479e4a5 100644 --- a/templates/web/base/report/new/category.html +++ b/templates/web/base/report/new/category.html @@ -10,7 +10,7 @@ END [% IF category_options.size OR category_groups.size ~%] [%~ BLOCK category_option ~%] [% cat_lc = cat.category | lower =%] - <option value='[% cat.category | html %]'[% ' selected' IF report.category == cat.category || category_lc == cat_lc ~%] + <option value='[% cat.category | html %]'[% ' selected' IF ( report.category == cat.category || category_lc == cat_lc ) AND ( NOT filter_group OR filter_group == group.name ) ~%] >[% IF loop.first %][% cat.category_display %][% ELSE %][% cat.category_display | html %][% END %] [%~ IF cat.get_extra_metadata('help_text') %] ([% cat.get_extra_metadata('help_text') %])[% END ~%] </option> diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html index ee9815157..9973a0c1f 100644 --- a/templates/web/base/reports/_list-filters.html +++ b/templates/web/base/reports/_list-filters.html @@ -1,9 +1,10 @@ [% select_status = PROCESS 'reports/_list-filter-status.html' %] +[%# We want to only select things that match all filters, if filters are provided ~%] [% BLOCK category_options %] [% FOR cat IN categories %] [% SET cat_safe = mark_safe(cat.category) %] - <option value="[% cat.category %]"[% ' selected' IF filter_category.$cat_safe OR ( filter_group AND ( cat.groups.grep(filter_group).size OR cat.category == filter_group ) ) %]> + <option value="[% cat.category %]"[% ' selected' IF ( filter_category.size OR filter_group ) AND ( NOT filter_category.size OR filter_category.$cat_safe ) AND ( NOT filter_group OR filter_group == group.name ) %]> [% cat.category_display %] [%~ IF cat.get_extra_metadata('help_text') %] ([% cat.get_extra_metadata('help_text') %])[% END ~%] </option> |