aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-23 13:58:34 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-31 15:37:09 +0100
commit986c97311c4cb1f3ec092c0605dcb15ab2527da1 (patch)
tree870c91b9c680a30c42109d5d93aefdb164b6f819 /templates
parent27110ac506f071ad0c5925ef74de1321514c23c8 (diff)
Remove hardcoded states from templates.
State display names are now got from the database wherever they are displayed, including admin dropdowns, list filters, and update meta statements. This also covers the open/closed/fixed 'groups'. This also fixes a bug whereby if e.g. an update has problem_state investigating, the next update has no problem_state, and the last update has investigating again, it was previously showing a state change to investigating on that third update.
Diffstat (limited to 'templates')
-rw-r--r--templates/web/base/admin/problem_row.html4
-rw-r--r--templates/web/base/admin/report_blocks.html8
-rw-r--r--templates/web/base/dashboard/index.html11
-rw-r--r--templates/web/base/report/_item.html4
-rw-r--r--templates/web/base/report/banner.html6
-rw-r--r--templates/web/base/report/inspect/state_groups_select.html7
-rw-r--r--templates/web/base/report/state-list.html21
-rw-r--r--templates/web/base/report/update.html6
-rw-r--r--templates/web/base/reports/_list-filters.html25
-rw-r--r--templates/web/oxfordshire/report/inspect/state_groups_select.html12
10 files changed, 32 insertions, 72 deletions
diff --git a/templates/web/base/admin/problem_row.html b/templates/web/base/admin/problem_row.html
index 79461367e..446e94d66 100644
--- a/templates/web/base/admin/problem_row.html
+++ b/templates/web/base/admin/problem_row.html
@@ -34,8 +34,8 @@
[% loc('Created') %]:&nbsp;[% PROCESS format_time time=problem.created %]
<br>[% loc('When sent') %]:&nbsp;[% PROCESS format_time time=problem.whensent %]
[%- IF problem.is_visible %]<br>[% loc('Confirmed:' ) %]&nbsp;[% PROCESS format_time time=problem.confirmed %][% END -%]
- [%- IF problem.is_fixed %]<br>[% loc('Fixed:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%]
- [%- IF problem.is_closed %]<br>[% loc('Closed:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%]
+ [%- IF problem.is_fixed %]<br>[% prettify_state('fixed') %]: [% PROCESS format_time time=problem.lastupdate %][% END -%]
+ [%- IF problem.is_closed %]<br>[% prettify_state('closed') %]: [% PROCESS format_time time=problem.lastupdate %][% END -%]
[%- IF problem.is_open %]<br>[% loc('Last&nbsp;update:') %] [% PROCESS format_time time=problem.lastupdate %][% END -%]
</small></td>
<td><a href="[% c.uri_for( 'report_edit', problem.id ) %]">[% loc('Edit') %]</a></td>
diff --git a/templates/web/base/admin/report_blocks.html b/templates/web/base/admin/report_blocks.html
index 933521b94..f5896b88f 100644
--- a/templates/web/base/admin/report_blocks.html
+++ b/templates/web/base/admin/report_blocks.html
@@ -1,13 +1,7 @@
[%
SET report_blocks_included = 1;
-
-SET state_groups = [
- [ loc('Open'), [ 'confirmed', 'investigating', 'planned', 'in progress', 'action scheduled' ] ],
- [ loc('Fixed'), [ 'fixed', 'fixed - user', 'fixed - council' ] ],
- [ loc('Closed'), [ 'unable to fix', 'not responsible', 'duplicate', 'closed', 'internal referral' ] ],
- [ loc('Hidden'), [ 'hidden', 'partial', 'unconfirmed' ] ]
-];
+SET state_groups = c.cobrand.state_groups_admin;
%]
diff --git a/templates/web/base/dashboard/index.html b/templates/web/base/dashboard/index.html
index 6033ef36b..e47798573 100644
--- a/templates/web/base/dashboard/index.html
+++ b/templates/web/base/dashboard/index.html
@@ -136,11 +136,12 @@
</select>
<p>[% loc('Report state:') %] <select class="form-control" name="state">
<option value=''>[% loc('All') %]</option>
- [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating',
- loc('Investigating')], ['action scheduled', loc('Planned')], ['in progress',
- loc('In Progress')], ['closed', loc('Closed')], ['fixed', loc('Fixed')] ] %]
- <option [% 'selected ' IF state.0 == q_state %] value="[% state.0 %]">[% state.1 %]</option>
- [% END %]
+ [% FOR group IN filter_states %]
+ [% FOR state IN group.1 %]
+ [% NEXT IF state == 'hidden' %]
+ <option [% 'selected ' IF state == q_state %] value="[% state %]">[% prettify_state(state, 1) %]</option>
+ [% END %]
+ [% END %]
</select>
<input type="submit" class="btn" value="[% loc('Look up') %]">
<a class="export_as_csv" href="[% c.req.uri_with({ export => 1 }) %]">[% loc('Export as CSV') %]</a>
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index 3f5c5464b..9449ca55d 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -40,9 +40,9 @@
[% END %]
<small>
[% IF NOT no_fixed AND problem.is_fixed %]
- <span class="item-list__item__state">[% loc('Fixed') %]</span>
+ <span class="item-list__item__state">[% prettify_state('fixed') %]</span>
[% ELSIF NOT no_fixed AND problem.is_closed %]
- <span class="item-list__item__state">[% loc('Closed') %]</span>
+ <span class="item-list__item__state">[% prettify_state('closed') %]</span>
[% ELSIF (c.user.has_permission_to('report_edit_priority', problem.bodies_str_ids) OR c.user.has_permission_to('report_inspect', problem.bodies_str_ids)) AND problem.response_priority %]
<span class="item-list__item__state">[% problem.response_priority.name %]</span>
[% END %]
diff --git a/templates/web/base/report/banner.html b/templates/web/base/report/banner.html
index c80d129eb..ee73d287a 100644
--- a/templates/web/base/report/banner.html
+++ b/templates/web/base/report/banner.html
@@ -9,11 +9,11 @@
[% INCLUDE banner, id = 'unknown', text = loc('Unknown') %]
[% END %]
[% IF problem.is_fixed %]
- [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %]
+ [% INCLUDE banner, id = 'fixed', text = prettify_state('fixed') %]
[% END %]
[% IF problem.is_closed %]
- [% INCLUDE banner, id = 'closed', text = loc('Closed') %]
+ [% INCLUDE banner, id = 'closed', text = prettify_state('closed') %]
[% END %]
[% IF problem.is_in_progress %]
- [% INCLUDE banner, id = 'progress', text = loc('In progress') %]
+ [% INCLUDE banner, id = 'progress', text = prettify_state(problem.state) %]
[% END %]
diff --git a/templates/web/base/report/inspect/state_groups_select.html b/templates/web/base/report/inspect/state_groups_select.html
index 2cf1a4de5..998b99739 100644
--- a/templates/web/base/report/inspect/state_groups_select.html
+++ b/templates/web/base/report/inspect/state_groups_select.html
@@ -1,11 +1,6 @@
[%
-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' ] ]
-];
+SET state_groups = c.cobrand.state_groups_inspect;
%]
[% DEFAULT current_state = problem.state %]
diff --git a/templates/web/base/report/state-list.html b/templates/web/base/report/state-list.html
deleted file mode 100644
index e137c81e2..000000000
--- a/templates/web/base/report/state-list.html
+++ /dev/null
@@ -1,21 +0,0 @@
-[%
-SET state_pretty = {
- 'confirmed' = loc('Open')
- 'investigating' = loc('Investigating')
- 'planned' = loc('Planned')
- 'in progress' = loc('In progress')
- 'action scheduled' = loc('Action Scheduled')
- 'fixed' = loc('Fixed')
- 'fixed - user' = loc('Fixed - User')
- 'fixed - council' = loc('Fixed - Council')
- 'unable to fix' = loc('No further action')
- 'not responsible' = loc('Not Responsible')
- 'duplicate' = loc('Duplicate')
- 'closed' = loc('Closed')
- 'internal referral' = loc('Internal referral')
- 'hidden' = loc('Hidden')
- 'partial' = loc('Partial')
- 'unconfirmed' = loc('Unconfirmed')
-};
-state_pretty.$state
-~%]
diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html
index 1f1438bfc..85624669a 100644
--- a/templates/web/base/report/update.html
+++ b/templates/web/base/report/update.html
@@ -43,6 +43,12 @@
</div>
[% END %]
+ [% SET update_state = update.problem_state_display(c) %]
+ [% IF update_state AND update_state != global.last_state AND NOT (global.last_state == "" AND update.problem_state == 'confirmed') %]
+ <p class="meta-2">[% loc('State changed to:') %] [% update_state %]</p>
+ [%- global.last_state = update_state %]
+ [% END %]
+
<p class="meta-2">
[% INCLUDE meta_line %]
[% IF c.user_exists AND c.user.id == update.user_id AND !update.anonymous %]
diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html
index ef7c7ad78..329e481ae 100644
--- a/templates/web/base/reports/_list-filters.html
+++ b/templates/web/base/reports/_list-filters.html
@@ -1,6 +1,6 @@
[% select_status = BLOCK %]
<select class="form-control js-multiple" name="status" id="statuses" multiple
- data-all="[% loc('All reports') %]" data-all-options='["open","closed","fixed"]'
+ data-all="[% loc('All') %]" data-all-options='["open","closed","fixed"]'
[%~ IF c.cobrand.on_map_default_status == 'open' %]
data-none="[% loc('Unfixed reports') %]"
[%~ END ~%]
@@ -10,19 +10,16 @@
<option value="unshortlisted"[% ' selected' IF filter_status.unshortlisted %]>[% loc('Unshortlisted') %]</option>
[% END %]
[% IF c.user_exists AND c.user.is_superuser OR c.user.belongs_to_body(body.id) %]
- <option value="confirmed"[% ' selected' IF filter_status.confirmed %]>[% loc('Open') %]</option>
- <option value="investigating"[% ' selected' IF filter_status.investigating %]>[% loc('Investigating') %]</option>
- <option value="in progress"[% ' selected' IF filter_status.in_progress %]>[% loc('In progress') %]</option>
- <option value="action scheduled"[% ' selected' IF filter_status.action_scheduled %]>[% loc('Action scheduled') %]</option>
- <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% loc('Fixed reports') %]</option>
- <option value="unable to fix"[% ' selected' IF filter_status.unable_to_fix %]>[% loc('No further action') %]</option>
- <option value="not responsible"[% ' selected' IF filter_status.not_responsible %]>[% loc('Not responsible') %]</option>
- <option value="internal referral"[% ' selected' IF filter_status.internal_referral %]>[% loc('Internal referral') %]</option>
- <option value="duplicate"[% ' selected' IF filter_status.duplicate %]>[% loc('Duplicate') %]</option>
+ [% FOR group IN filter_states %]
+ [% FOR state IN group.1 %]
+ [% NEXT IF state == 'hidden' %]
+ <option value="[% state %]"[% ' selected' IF filter_status.$state %]>[% prettify_state(state, 1) %]</option>
+ [% END %]
+ [% END %]
[% ELSE %]
- <option value="open"[% ' selected' IF filter_status.open %]>[% loc('Unfixed reports') %]</option>
- <option value="closed"[% ' selected' IF filter_status.closed %]>[% loc('Closed reports') %]</option>
- <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% loc('Fixed reports') %]</option>
+ <option value="open"[% ' selected' IF filter_status.open %]>[% prettify_state('confirmed') %]</option>
+ <option value="closed"[% ' selected' IF filter_status.closed %]>[% prettify_state('closed') %]</option>
+ <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% prettify_state('fixed') %]</option>
[% END %]
</select>
[% END %]
@@ -46,7 +43,7 @@
[% END %]
<p class="report-list-filters">
- [% tprintf(loc('<label for="statuses">Show</label> %s <label for="filter_categories">about</label> %s', "The first %s is a dropdown of all/fixed/etc, the second is a dropdown of categories"), select_status, select_category) %]
+ [% tprintf(loc('<label for="statuses">Show</label> %s reports <label for="filter_categories">about</label> %s', "The first %s is a dropdown of all/fixed/etc, the second is a dropdown of categories"), select_status, select_category) %]
<input type="submit" name="filter_update" value="[% loc('Go') %]">
</p>
diff --git a/templates/web/oxfordshire/report/inspect/state_groups_select.html b/templates/web/oxfordshire/report/inspect/state_groups_select.html
deleted file mode 100644
index d36fb0191..000000000
--- a/templates/web/oxfordshire/report/inspect/state_groups_select.html
+++ /dev/null
@@ -1,12 +0,0 @@
-[%
-
-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' single_fixed=1 %]