aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-01-16 14:14:12 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-01-16 17:40:44 +0000
commit609ed81c84129744cfbc9bc8616e0e04a861fd9a (patch)
tree04d630477c1b9271a776ed1ae29d4db3af98ad05
parent91ed9facc29eda616d2de9bb248df3347101a5be (diff)
Include category groups in dashboard filter.
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm1
-rw-r--r--t/app/controller/dashboard.t11
-rw-r--r--templates/web/base/dashboard/index.html3
3 files changed, 11 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index f226e08de..3a4480e85 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -109,6 +109,7 @@ sub index : Path : Args(0) {
$c->forward('/admin/fetch_contacts');
$c->stash->{contacts} = [ $c->stash->{contacts}->all ];
+ $c->forward('/report/stash_category_groups', [ $c->stash->{contacts}, 0 ]);
# See if we've had anything from the body dropdowns
$c->stash->{category} = $c->get_param('category');
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 15c718c74..72fc00128 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -30,7 +30,11 @@ my $other_body = $mech->create_body_ok(1234, 'Some Other Council');
my $body = $mech->create_body_ok(2651, 'City of Edinburgh Council');
my @cats = ('Litter', 'Other', 'Potholes', 'Traffic lights');
for my $contact ( @cats ) {
- $mech->create_contact_ok(body_id => $body->id, category => $contact, email => "$contact\@example.org");
+ my $c = $mech->create_contact_ok(body_id => $body->id, category => $contact, email => "$contact\@example.org");
+ if ($contact eq 'Potholes') {
+ $c->set_extra_metadata(group => ['Road']);
+ $c->update;
+ }
}
my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1);
@@ -70,7 +74,7 @@ foreach my $problem (@closed_problems) {
}
my $categories = scraper {
- process "select[name=category] > option", 'cats[]' => 'TEXT',
+ process "select[name=category] option", 'cats[]' => 'TEXT',
process "table[id=overview] > tr", 'rows[]' => scraper {
process 'td', 'cols[]' => 'TEXT'
},
@@ -135,8 +139,9 @@ FixMyStreet::override_config {
subtest 'The correct categories and totals shown by default' => sub {
$mech->get_ok("/dashboard");
- my $expected_cats = [ 'All', @cats ];
+ my $expected_cats = [ 'All', 'Litter', 'Other', 'Traffic lights', 'Potholes' ];
my $res = $categories->scrape( $mech->content );
+ $mech->content_contains('<optgroup label="Road">');
is_deeply( $res->{cats}, $expected_cats, 'correct list of categories' );
# Three missing as more than a month ago
test_table($mech->content, 1, 0, 0, 1, 0, 0, 0, 0, 2, 0, 4, 6, 7, 3, 0, 10, 10, 3, 4, 17);
diff --git a/templates/web/base/dashboard/index.html b/templates/web/base/dashboard/index.html
index c90823d37..5ac414bde 100644
--- a/templates/web/base/dashboard/index.html
+++ b/templates/web/base/dashboard/index.html
@@ -38,9 +38,10 @@
<p>
<label for="category">[% loc('Category:') %]</label>
<select class="form-control" name="category" id="category"><option value=''>[% loc('All') %]</option>
- [% FOR cat IN contacts %]
+ [% BLOCK category_option %]
<option value='[% cat.category | html %]'[% ' selected' IF category == cat.category %]>[% cat.category_display | html %]</option>
[% END %]
+ [%~ INCLUDE 'report/new/_category_select.html' category_options=contacts ~%]
</select>
</p>