diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-07 13:49:05 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-07 13:49:05 +0100 |
commit | 44819320af5533bb03a0855a75da0c9ffd207ee8 (patch) | |
tree | b42efd3598d5ef52eab09d3f58c8e451a3f67047 | |
parent | 719afb490479aa1cbc306b81a7534bb8a8affbf3 (diff) | |
parent | c93ebfa26b864c26b9219b59f6676371e434ea0a (diff) |
Merge branch 'issues/forcouncils/195-overloaded-action-scheduled'
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 19 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 52 | ||||
-rw-r--r-- | templates/web/base/report/_inspect.html | 11 | ||||
-rw-r--r-- | templates/web/oxfordshire/report/inspect/state_groups_select.html | 5 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/staff.js | 12 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 2 |
6 files changed, 60 insertions, 41 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index ef10dc32e..81abba3ac 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -367,15 +367,9 @@ sub inspect : Private { if ( $problem->state ne $old_state ) { $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'state_change' ] ); - # If the state has been changed by an inspector, consider the - # report to be inspected. - unless ($problem->get_extra_metadata('inspected')) { - $problem->set_extra_metadata( inspected => 1 ); - $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] ); - my $state = $problem->state; - $reputation_change = 1 if $c->cobrand->reputation_increment_states->{$state}; - $reputation_change = -1 if $c->cobrand->reputation_decrement_states->{$state}; - } + my $state = $problem->state; + $reputation_change = 1 if $c->cobrand->reputation_increment_states->{$state}; + $reputation_change = -1 if $c->cobrand->reputation_decrement_states->{$state}; # If an inspector has changed the state, subscribe them to # updates @@ -386,6 +380,13 @@ sub inspect : Private { }; $problem->user->create_alert($problem->id, $options); } + + # If the state has been changed to action scheduled and they've said + # they want to raise a defect, consider the report to be inspected. + if ($problem->state eq 'action scheduled' && $c->get_param('raise_defect') && !$problem->get_extra_metadata('inspected')) { + $problem->set_extra_metadata( inspected => 1 ); + $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] ); + } } if ( !$c->forward( '/admin/report_edit_location', [ $problem ] ) ) { diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index e3d24e9a9..481d8dc87 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -65,13 +65,15 @@ FixMyStreet::override_config { }; subtest "test inspect & instruct submission" => sub { - $report->unset_extra_metadata('inspected'); + $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); $report->state('confirmed'); $report->update; - $report->inspection_log_entry->delete; my $reputation = $report->user->get_extra_metadata("reputation"); $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ button => 'save', with_fields => { public_update => "This is a public update.", include_update => "1", state => 'action scheduled' } }); + $mech->submit_form_ok({ button => 'save', with_fields => { + public_update => "This is a public update.", include_update => "1", + state => 'action scheduled', raise_defect => 1, + } }); $report->discard_changes; is $report->comments->first->text, "This is a public update.", 'Update was created'; is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; @@ -203,46 +205,42 @@ FixMyStreet::override_config { }; subtest "test positive reputation" => sub { + $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); $report->unset_extra_metadata('inspected'); $report->update; $report->inspection_log_entry->delete if $report->inspection_log_entry; my $reputation = $report->user->get_extra_metadata("reputation") || 0; $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ button => 'save', with_fields => { state => 'action scheduled', include_update => undef } }); + $mech->submit_form_ok({ button => 'save', with_fields => { + state => 'in progress', include_update => undef, + } }); $report->discard_changes; - is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; + is $report->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; + + $mech->submit_form_ok({ button => 'save', with_fields => { + state => 'action scheduled', include_update => undef, + } }); + $report->discard_changes; + is $report->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; is $report->user->get_extra_metadata('reputation'), $reputation+1, "User reputation was increased"; + + $mech->submit_form_ok({ button => 'save', with_fields => { + state => 'action scheduled', include_update => undef, + raise_defect => 1, + } }); + $report->discard_changes; + is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; }; subtest "Oxfordshire-specific traffic management options are shown" => sub { $report->update({ state => 'confirmed' }); $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Signs and Cones', state => 'Investigating', include_update => undef } }); + $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Signs and Cones', state => 'Action Scheduled', include_update => undef } }); $report->discard_changes; - is $report->state, 'investigating', 'report state changed'; + is $report->state, 'action scheduled', 'report state changed'; is $report->get_extra_metadata('traffic_information'), 'Signs and Cones', 'report data changed'; }; - subtest "Action scheduled only shown appropriately" => sub { - $report->update({ state => 'confirmed' }); - $mech->get_ok("/report/$report_id"); - $mech->content_lacks('action scheduled'); - - # If the report is already in that state, though, we should show it - $report->update({ state => 'action scheduled' }); - $mech->get_ok("/report/$report_id"); - $mech->content_unlike(qr/<optgroup label="Scheduled">\s*<option value="action scheduled">Action Scheduled<\/option>/); - $mech->content_contains('<option selected value="action scheduled">Action Scheduled</option>'); - - $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); - $mech->get_ok("/report/$report_id"); - $mech->content_like(qr/<optgroup label="Scheduled">\s*<option selected value="action scheduled">Action Scheduled<\/option>/); - - $report->update({ state => 'confirmed' }); - $mech->get_ok("/report/$report_id"); - $mech->content_like(qr/<optgroup label="Scheduled">\s*<option value="action scheduled">Action Scheduled<\/option>/); - }; - }; FixMyStreet::override_config { diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 98925271d..9d73fbb94 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -72,6 +72,17 @@ <label for="state">[% loc('State') %]</label> [% INCLUDE 'report/inspect/state_groups_select.html' %] </p> + [% IF permissions.report_instruct AND NOT problem.get_extra_metadata('inspected') %] + <div id="js-inspect-action-scheduled" class="[% "hidden" UNLESS problem.state == 'action scheduled' %]"> + <p>[% loc('Do you want to automatically raise a defect?') %]</p> + <p class="segmented-control segmented-control--radio"> + <input type="radio" name="raise_defect" id="raise_defect_yes" value="1"> + <label class="btn" for="raise_defect_yes">[% loc('Yes') %]</label> + <input type="radio" name="raise_defect" id="raise_defect_no" value="0"> + <label class="btn" for="raise_defect_no">[% loc('No') %]</label> + </p> + </div> + [% END %] <div id="js-duplicate-reports" class="[% "hidden" UNLESS problem.duplicate_of %]"> <input type="hidden" name="duplicate_of" value="[% problem.duplicate_of.id %]"> <p class="[% "hidden" UNLESS problem.duplicate_of %]"><strong>[% loc('Duplicate of') %]</strong></p> diff --git a/templates/web/oxfordshire/report/inspect/state_groups_select.html b/templates/web/oxfordshire/report/inspect/state_groups_select.html index dcb24c982..a5fce525c 100644 --- a/templates/web/oxfordshire/report/inspect/state_groups_select.html +++ b/templates/web/oxfordshire/report/inspect/state_groups_select.html @@ -2,14 +2,11 @@ SET state_groups = [ [ loc('New'), [ 'confirmed', 'investigating' ] ], + [ loc('Scheduled'), [ 'action scheduled' ] ], [ loc('Fixed'), [ 'fixed - council' ] ], [ loc('Closed'), [ 'not responsible', 'duplicate', 'unable to fix' ] ] ]; -IF c.user_exists AND c.user.has_body_permission_to('report_instruct'); - CALL state_groups.splice(1, 0, [ [ loc('Scheduled'), [ 'action scheduled' ] ] ]); -END - %] [% DEFAULT current_state = problem.state %] [% INCLUDE 'report/_state_select_field.html' %] diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js index 5355a8f54..2a1c6a8f4 100644 --- a/web/cobrands/fixmystreet/staff.js +++ b/web/cobrands/fixmystreet/staff.js @@ -80,6 +80,18 @@ $.extend(fixmystreet.set_up, { $("#js-change-duplicate-report").click(refresh_duplicate_list); }, + action_scheduled_raise_defect: function() { + $("#report_inspect_form").find('[name=state]').on('change', function() { + if ($(this).val() !== "action scheduled") { + $("#js-inspect-action-scheduled").addClass("hidden"); + $('#raise_defect_yes').prop('required', false); + } else { + $("#js-inspect-action-scheduled").removeClass("hidden"); + $('#raise_defect_yes').prop('required', true); + } + }); + }, + list_item_actions: function() { $('.item-list--reports').on('click', ':submit', function(e) { e.preventDefault(); diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index 07a2b88f8..a261c3b0a 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -2268,7 +2268,7 @@ table.nicetable { .segmented-control--radio { input { position: absolute; - left: -999px; + opacity: 0; } input:checked + label { |