diff options
author | Dave Arter <davea@mysociety.org> | 2016-12-01 16:52:34 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-01-10 10:55:19 +0000 |
commit | 7416881f07d2a02ce0c98718e0ca5790a39518d7 (patch) | |
tree | 8d4d725f403497846235a7e5a2040f7043cc78bd /templates | |
parent | d7c3106d64f8237a4f6388a0e51dcd29bae93ec8 (diff) |
Allow editing of ResponseTemplate state in admin
This includes a refactor of the state dropdown field into its own template for easy reuse.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/web/base/admin/report_edit.html | 14 | ||||
-rw-r--r-- | templates/web/base/admin/state_groups_select.html | 14 | ||||
-rw-r--r-- | templates/web/base/admin/template_edit.html | 10 | ||||
-rw-r--r-- | templates/web/base/report/_inspect.html | 12 |
4 files changed, 29 insertions, 21 deletions
diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index 02e75563c..911b1995a 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -112,16 +112,10 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a> <li><label for='detail'>[% loc('Details:') %]</label> <textarea class="form-control" name='detail' id='detail' cols=60 rows=10>[% problem.detail | html %]</textarea></li> -<li><label class="inline-text" for="state">[% loc('State:') %]</label> -<select class="form-control" name="state" id="state"> -[% FOREACH group IN state_groups %] - <optgroup label="[% group.0 %]"> - [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state == problem.state %] value="[% state %]">[% state_pretty.$state %]</option> - [% END %] - </optgroup> -[% END %] -</select></li> +<li> + <label class="inline-text" for="state">[% loc('State:') %]</label> + [% INCLUDE 'admin/state_groups_select.html' %] +</li> <li><label class="inline-text" for="category">[% loc('Category:') %]</label> <select class="form-control" name="category" id="category"> [% IF NOT problem.category OR NOT categories.grep(problem.category).size %] diff --git a/templates/web/base/admin/state_groups_select.html b/templates/web/base/admin/state_groups_select.html new file mode 100644 index 000000000..229d181ab --- /dev/null +++ b/templates/web/base/admin/state_groups_select.html @@ -0,0 +1,14 @@ +[% 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> diff --git a/templates/web/base/admin/template_edit.html b/templates/web/base/admin/template_edit.html index b2e734756..76de70dcc 100644 --- a/templates/web/base/admin/template_edit.html +++ b/templates/web/base/admin/template_edit.html @@ -31,6 +31,16 @@ </div> [% INCLUDE 'admin/category-checkboxes.html' %] + <div class="admin-hint"> + <p> + [% loc('If you want to use this template to prefill the update field when changing a report’s state, select the state here.') %] + </p> + </div> + <p> + <label for="state">[% loc('State') %]</label> + [% INCLUDE 'admin/state_groups_select.html' current_state=rt.state include_empty=1 %] + </p> + <p> <input type="hidden" name="token" value="[% csrf_token %]" > <input type="submit" class="btn" name="Edit templates" value="[% rt.id ? loc('Save changes') : loc('Create template') %]" > diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 84170a38c..43e86cb47 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -1,4 +1,3 @@ -[% PROCESS 'admin/report_blocks.html'; # For the report state dropdown %] [% permissions = c.user.permissions(c, problem.bodies_str) %] [% second_column = BLOCK -%] <div id="side-inspect"> @@ -65,16 +64,7 @@ [% IF permissions.report_inspect %] <p> <label for="state">[% loc('State') %]</label> - [%# XXX this is duplicated from admin/report_edit.html, should be refactored %] - <select name="state" id="state" class="form-control"> - [% FOREACH group IN state_groups %] - <optgroup label="[% group.0 %]"> - [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state == problem.state %] value="[% state %]">[% state_pretty.$state %]</option> - [% END %] - </optgroup> - [% END %] - </select> + [% INCLUDE 'admin/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 %]"> |