Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Island Roads] Default 'CONFIRM Subject' to be a blank selection #5188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions t/cobrand/isleofwight.t
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]', name => 'Test User');
Expand All @@ -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',
Expand Down Expand Up @@ -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(
'<optgroup label="Roads">',
'there is a "Roads" optgroup',
);
$mech->content_contains(
'<option value="" selected>-- Please select --</option>',
'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(
'<option value="Potholes" selected>',
'Potholes selected as category',
);
$mech->content_lacks( '-- Please select --',
'No blank category available anymore' );
};
};

Expand Down
19 changes: 16 additions & 3 deletions templates/web/base/admin/triage/_inspect.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
[% BLOCK category_list %]
<select class="form-control" name="[% field_name %]" id="[% field_name %]">
<select class="form-control" name="[% field_name %]" id="[% field_name %]" required>
[% IF category_options.size %]
[%~ IF category_groups.size ~%]
[%~ FOREACH group IN category_groups ~%]
[% IF group.name %]<optgroup label="[% group.name %]">[% END %]
[% group_select = 0 %]
[% selected = 0 %]
[%~ FOREACH cat_op IN group.categories ~%]

[% 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 %]
<option value="[% cat_op.id %]"[% ' selected' IF selected OR problem.contact.id == cat_op.id %]>[% cat_op.category_display %] ([% cat_op.email %])</option>
<option value="[% cat_op.id %]"[% ' selected' IF selected OR problem.contact.id == cat_op.id %]>[% cat_op.category_display %][% IF cat_op.email %] ([% cat_op.email %])[% END %]</option>
[% selected = 0 %]
[%~ END ~%]
[% IF group.name %]</optgroup>[% END %]
Expand Down
Loading