diff options
author | Dave Arter <davea@mysociety.org> | 2017-01-30 16:32:52 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-02-08 10:54:23 +0000 |
commit | 312df7e5b0224d9aff0767148879a854089e4ee1 (patch) | |
tree | 60e7e103855013f7b11eda4c5e65108b3618ae17 | |
parent | 804506834e0ef7c1d6d9ab21dece21a18651295f (diff) |
[Oxfordshire] Show simpler state list on inspect form
Limits the state dropdown to those states which will be useful to OCC
inspectors, as well as removing a few from the base template on the inspect
form. Some slight template refactoring has made it easier for other cobrands to
override the list, as well as sharing the template with the admin report_edit
form to allow all states to be selected.
Fixes mysociety/fixmystreetforcouncils#129
-rw-r--r-- | t/app/controller/report_inspect.t | 8 | ||||
-rw-r--r-- | templates/web/base/admin/state_groups_select.html | 13 | ||||
-rw-r--r-- | templates/web/base/report/_inspect.html | 2 | ||||
-rw-r--r-- | templates/web/base/report/_state_select_field.html | 12 | ||||
-rw-r--r-- | templates/web/base/report/inspect/state_groups_select.html | 24 | ||||
-rw-r--r-- | templates/web/oxfordshire/report/inspect/state_groups_select.html | 21 |
6 files changed, 63 insertions, 17 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index f092561db..9888fc0f4 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -57,9 +57,9 @@ FixMyStreet::override_config { }; subtest "test basic inspect submission" => sub { - $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Planned', save_inspected => undef } }); + $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Action Scheduled', save_inspected => undef } }); $report->discard_changes; - is $report->state, 'planned', 'report state changed'; + is $report->state, 'action scheduled', 'report state changed'; is $report->get_extra_metadata('traffic_information'), 'Yes', 'report data changed'; }; @@ -190,9 +190,9 @@ FixMyStreet::override_config { 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 => 'Planned', save_inspected => undef } }); + $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Signs and Cones', state => 'Action Scheduled', save_inspected => undef } }); $report->discard_changes; - is $report->state, 'planned', 'report state changed'; + is $report->state, 'action scheduled', 'report state changed'; is $report->get_extra_metadata('traffic_information'), 'Signs and Cones', 'report data changed'; }; diff --git a/templates/web/base/admin/state_groups_select.html b/templates/web/base/admin/state_groups_select.html index 229d181ab..9a70cd2c9 100644 --- a/templates/web/base/admin/state_groups_select.html +++ b/templates/web/base/admin/state_groups_select.html @@ -1,14 +1,3 @@ [% PROCESS 'admin/report_blocks.html'; # For state_groups %] [% DEFAULT current_state = problem.state %] -<select class="form-control" name="state" id="state"> -[% IF include_empty %] - <option value="">---</option> -[% END %] -[% FOREACH group IN state_groups %] - <optgroup label="[% group.0 %]"> - [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state == current_state %] value="[% state %]">[% state_pretty.$state %]</option> - [% END %] - </optgroup> -[% END %] -</select> +[% INCLUDE 'report/_state_select_field.html' %] diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 3118a49b6..5a7e99ef9 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -64,7 +64,7 @@ [% IF permissions.report_inspect %] <p> <label for="state">[% loc('State') %]</label> - [% INCLUDE 'admin/state_groups_select.html' %] + [% INCLUDE 'report/inspect/state_groups_select.html' %] </p> <div id="js-duplicate-reports" class="[% "hidden" UNLESS problem.duplicate_of %]"> <input type="hidden" name="duplicate_of" value="[% problem.duplicate_of.id %]"> diff --git a/templates/web/base/report/_state_select_field.html b/templates/web/base/report/_state_select_field.html new file mode 100644 index 000000000..9b3ed18df --- /dev/null +++ b/templates/web/base/report/_state_select_field.html @@ -0,0 +1,12 @@ +<select class="form-control" name="state" id="state"> +[% IF include_empty %] + <option value="">---</option> +[% END %] +[% FOREACH group IN state_groups %] + <optgroup label="[% group.0 %]"> + [% FOREACH state IN group.1 %] + <option [% 'selected ' IF state == current_state %] value="[% state %]">[% state_pretty.$state %]</option> + [% END %] + </optgroup> +[% END %] +</select> diff --git a/templates/web/base/report/inspect/state_groups_select.html b/templates/web/base/report/inspect/state_groups_select.html new file mode 100644 index 000000000..c4043751b --- /dev/null +++ b/templates/web/base/report/inspect/state_groups_select.html @@ -0,0 +1,24 @@ +[% +SET state_pretty = { + 'confirmed' = loc('Open') + 'investigating' = loc('Investigating') + 'in progress' = loc('In progress') + 'action scheduled' = loc('Action Scheduled') + 'fixed - council' = loc('Fixed - Council') + 'unable to fix' = loc('No further action') + 'not responsible' = loc('Not Responsible') + 'duplicate' = loc('Duplicate') + 'internal referral' = loc('Internal referral') + 'hidden' = loc('Hidden') +}; + +SET state_groups = [ + [ loc('Open'), [ 'confirmed', 'investigating', 'in progress', 'action scheduled' ] ], + [ loc('Fixed'), [ 'fixed - council' ] ], + [ loc('Closed'), [ 'unable to fix', 'not responsible', 'duplicate', 'internal referral' ] ], + [ loc('Hidden'), [ 'hidden' ] ] +]; + +%] +[% DEFAULT current_state = problem.state %] +[% INCLUDE 'report/_state_select_field.html' %] diff --git a/templates/web/oxfordshire/report/inspect/state_groups_select.html b/templates/web/oxfordshire/report/inspect/state_groups_select.html new file mode 100644 index 000000000..d9db3864a --- /dev/null +++ b/templates/web/oxfordshire/report/inspect/state_groups_select.html @@ -0,0 +1,21 @@ +[% +SET state_pretty = { + 'confirmed' = loc('Open') + 'investigating' = loc('Investigating') + 'action scheduled' = loc('Action Scheduled') + 'fixed - council' = loc('Fixed') + 'not responsible' = loc('Not Responsible') + 'duplicate' = loc('Duplicate') + 'unable to fix' = loc('No further action') +}; + +SET state_groups = [ + [ loc('New'), [ 'confirmed', 'investigating' ] ], + [ loc('Scheduled'), [ 'action scheduled' ] ], + [ loc('Fixed'), [ 'fixed - council' ] ], + [ loc('Closed'), [ 'not responsible', 'duplicate', 'unable to fix' ] ] +]; + +%] +[% DEFAULT current_state = problem.state %] +[% INCLUDE 'report/_state_select_field.html' %] |