From 0e5c67ecf24c585d05f4e63414133cc60946641f Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Wed, 25 Sep 2024 14:47:51 +0100 Subject: [PATCH 1/2] [Island Roads] Default 'CONFIRM Subject' to be a blank selection A 'Please select' option with a blank value is added under every group header in the dropdown; this is selected by default (under the relevant header) to force the admin user to choose a triage category (rather than it defaulting to the first category in the group). --- templates/web/base/admin/triage/_inspect.html | 68 ++++++++++++++----- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/templates/web/base/admin/triage/_inspect.html b/templates/web/base/admin/triage/_inspect.html index 8302a010ae..d51aa600f7 100644 --- a/templates/web/base/admin/triage/_inspect.html +++ b/templates/web/base/admin/triage/_inspect.html @@ -1,27 +1,61 @@ [% BLOCK category_list %] - + [% IF category_options.size %] + [%~ IF category_groups.size ~%] + [%~ FOREACH group IN category_groups ~%] + [% IF group.name %][% END %] + [% group_select = 0 %] + [% selected = 0 %] + [% IF group_select == 0 AND problem.category == group.name %] [% selected = 1; group_select = 1 %] [% END %] - + + + + [%~ FOREACH cat_op IN group.categories ~%] + + [% selected = 0 %] + [%~ END ~%] + [% IF group.name %][% END %] + [%~ END =%] + [% ELSE %] + [% FOREACH cat IN category_options %] + + [% END %] + [% END %] + [% END %] + + [% ELSE %] + [% END %] - [% END %] [% second_column = BLOCK -%] From 9e5465d9df4d6b2e1e6b4f869be1dbd04c533b69 Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Thu, 26 Sep 2024 12:27:39 +0100 Subject: [PATCH 2/2] fixup! [Island Roads] Default 'CONFIRM Subject' to be a blank selection --- t/cobrand/isleofwight.t | 36 +++++++++ templates/web/base/admin/triage/_inspect.html | 79 +++++++------------ 2 files changed, 65 insertions(+), 50 deletions(-) diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t index 04054663c8..3c5591d966 100644 --- a/t/cobrand/isleofwight.t +++ b/t/cobrand/isleofwight.t @@ -45,6 +45,7 @@ $contact->set_extra_fields( ( { order => 1, datatype_description => 'datatype', } ) ); +$contact->set_extra_metadata( group => ['Roads'] ); $contact->update; my $user = $mech->create_user_ok('user@example.org', name => 'Test User'); @@ -67,6 +68,10 @@ $admin_user->user_body_permissions->create({ body => $isleofwight, permission_type => 'triage' }); +$admin_user->user_body_permissions->create({ + body => $isleofwight, + permission_type => 'report_inspect', +}); my @reports = $mech->create_problems_for_body(1, $isleofwight->id, 'An Isle of wight report', { confirmed => '2019-10-25 09:00', @@ -590,6 +595,37 @@ subtest "reports are marked for triage upon submission" => sub { my $email = $mech->get_email; like $mech->get_text_body_from_email($email), qr/submitted to Island Roads for review/, 'correct text for email sent for Triage'; + + $mech->log_in_ok( $admin_user->email ); + $mech->get_ok( '/report/' . $report->id ); + $mech->content_contains( + '', + 'there is a "Roads" optgroup', + ); + $mech->content_contains( + '', + 'there is an empty-valued option selected by default', + ); + + $mech->submit_form( form_id => 'report_inspect_form' ); + $mech->text_contains( 'Please choose a category', + 'Form requires a category be chosen' ); + + $mech->submit_form( + form_id => 'report_inspect_form', + fields => { category => $contact->id }, # Pothole + ); + $mech->get_ok( '/report/' . $report->id ); + $mech->text_contains( + 'Report triaged from Roads to Potholes', + 'Update message describes triage', + ); + $mech->content_contains( + '[% END %] + [% group_select = 0 %] + [% selected = 0 %] + + [% SET categories = group.categories %] + [% IF c.cobrand.moniker == 'isleofwight' %] + [% + # Isle of Wight selects a blank option by default, + # to force admin user to select a triage category + %] + [% categories.unshift( + { id => '', category_display => loc('-- Please select --') } + ) + %] + [% END %] + [%~ FOREACH cat_op IN categories ~%] [% IF group_select == 0 AND problem.category == group.name %] [% selected = 1; group_select = 1 %] [% END %] - - - - [%~ FOREACH cat_op IN group.categories ~%] - - [% selected = 0 %] - [%~ END ~%] - [% IF group.name %][% END %] - [%~ END =%] - [% ELSE %] - [% FOREACH cat IN category_options %] - - [% END %] - [% END %] - [% END %] - - [% ELSE %] - [% END %] + [% END %] [% second_column = BLOCK -%]