Skip to content

Commit

Permalink
fixup! fixup! [FMS] Make dashboard categories multi-select
Browse files Browse the repository at this point in the history
  • Loading branch information
MorayMySoc committed Dec 5, 2023
1 parent e1556a9 commit 82431d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions t/app/controller/admin/report_edit.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ my $superuser = $mech->create_user_ok('[email protected]', name => 'Super Us

my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council');
my $user3 = $mech->create_user_ok('[email protected]', name => 'Body User', from_body => $oxfordshire);
my $oxfordshirecontact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => '[email protected]' );
my $oxfordshirecontact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => '[email protected]', extra => { group => 'Road' } );
$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => '[email protected]' );
$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Yellow lines', email => '[email protected]', extra => { group => 'Road' } );


my $oxford = $mech->create_body_ok(2421, 'Oxford City Council');
$mech->create_contact_ok( body_id => $oxford->id, category => 'Graffiti', email => '[email protected]' );
Expand Down Expand Up @@ -58,7 +60,7 @@ my $log_entries = FixMyStreet::DB->resultset('AdminLog')->search(
object_type => 'problem',
object_id => $report->id
},
{
{
order_by => { -desc => 'id' },
}
);
Expand Down Expand Up @@ -455,7 +457,8 @@ subtest 'change report category' => sub {
whensent => \'current_timestamp',
});
$mech->get_ok("/admin/report_edit/" . $ox_report->id);

$mech->content_contains('<optgroup label="Road">');
$mech->content_lacks('<option value="group-Road"');
$mech->submit_form_ok( { with_fields => { category => 'Traffic lights' } }, 'form_submitted' );
$ox_report->discard_changes;
is $ox_report->category, 'Traffic lights';
Expand Down
1 change: 1 addition & 0 deletions t/app/controller/dashboard.t
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ FixMyStreet::override_config {
my $expected_cats = [ 'Litter', 'Other', 'Traffic lights & bells', 'All Road', 'Potholes', 'White lines' ];
my $res = $categories->scrape( $mech->content );
$mech->content_contains('<optgroup label="Road">');
$mech->content_contains('<option value="group-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, 1, 0, 0, 1, 11, 3, 4, 18);
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h1>[% loc('Summary statistics') %]</h1>
[% SET category = cat.category | html %]
<option value='[% cat.category | html %]'[% ' selected' IF display_categories.$category %]>[% cat.category_display | html %]</option>
[% END %]
[%~ INCLUDE 'report/new/_category_select.html' ~%]
[%~ INCLUDE 'report/new/_category_select.html' include_group_option=1 ~%]
</select>
</p>

Expand Down
4 changes: 3 additions & 1 deletion templates/web/base/report/new/_category_select.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[%~ FOREACH group IN category_groups ~%]
[% IF group.name %]<optgroup label="[% group.name %]">
[% IF group.name AND include_group_option %]<optgroup label="[% group.name %]">
[% SET pseudo_category = "group-" _ group.name %]
<option value="group-[% group.name %]" [% ' selected' IF display_categories.$pseudo_category %]>All [% group.name %]</option>
[% ELSIF group.name %]
<optgroup label="[% group.name %]">
[% END %]
[%~ FOREACH cat IN group.categories ~%]
[% INCLUDE category_option %]
Expand Down

0 comments on commit 82431d6

Please sign in to comment.