diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-08-19 13:15:36 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-09-30 11:12:19 +0100 |
commit | 8df616849f5641b95ebfe33c0c2f22820bbf0e52 (patch) | |
tree | 8c69aa6ba4378c5694b678c1cb9a0e5b740028f2 | |
parent | 90f4dbe8067639d7274a3b2c05cdd985bf6366c2 (diff) |
Factor out status select filter template.
-rw-r--r-- | templates/web/base/reports/_list-filter-status.html | 45 | ||||
-rw-r--r-- | templates/web/base/reports/_list-filters.html | 47 |
2 files changed, 46 insertions, 46 deletions
diff --git a/templates/web/base/reports/_list-filter-status.html b/templates/web/base/reports/_list-filter-status.html new file mode 100644 index 000000000..6923a7929 --- /dev/null +++ b/templates/web/base/reports/_list-filter-status.html @@ -0,0 +1,45 @@ +[% SET show_all_states = c.cobrand.filter_show_all_states OR (c.user_exists AND (c.user.is_superuser OR c.user.belongs_to_body(body.id))) %] + +<select class="form-control js-multiple" name="status" id="statuses" multiple + data-all="[% loc('All') %]" + [% IF show_all_states %] + [% options = []; + FOR group IN filter_states; FOR state IN group.1; + NEXT IF state == 'hidden'; + SET state = 'fixed' IF state == 'fixed - council'; + options.push(state); + END; END + %] + data-all-options='["[% options.join('", "') %]"]' + [%~ ELSE ~%] + [%~ IF has_fixed_state ~%] + data-all-options='["open","closed","fixed"]' + [%~ ELSE ~%] + data-all-options='["open","closed"]' + [%~ END ~%] + [%~ END ~%] + [% INCLUDE 'reports/_status_filter_options.html' %] + > + [% IF c.user_exists AND c.user.has_body_permission_to('planned_reports') AND !shortlist %] + <option value="shortlisted"[% ' selected' IF filter_status.shortlisted %]>[% loc('Shortlisted') %]</option> + <option value="unshortlisted"[% ' selected' IF filter_status.unshortlisted %]>[% loc('Unshortlisted') %]</option> + [% END %] + [% IF c.user_exists AND ( c.user.has_body_permission_to('report_inspect') OR c.user.has_body_permission_to('report_mark_private') ) %] + <option value="non_public"[% ' selected' IF filter_status.non_public %]>[% loc('Private only') %]</option> + [% END %] + [% IF show_all_states %] + [% FOR group IN filter_states %] + [% FOR state IN group.1 %] + [% NEXT IF state == 'hidden' %] + [% SET state = 'fixed' IF state == 'fixed - council' ~%] + <option value="[% state %]"[% ' selected' IF filter_status.$state %]>[% prettify_state(state, 1) %]</option> + [% END %] + [% END %] + [% ELSE %] + <option value="open"[% ' selected' IF filter_status.open %]>[% prettify_state('confirmed') %]</option> + <option value="closed"[% ' selected' IF filter_status.closed %]>[% prettify_state('closed') %]</option> + [% IF has_fixed_state %] + <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% prettify_state('fixed') %]</option> + [% END %] + [% END %] +</select> diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html index 6acb5936c..77c257e01 100644 --- a/templates/web/base/reports/_list-filters.html +++ b/templates/web/base/reports/_list-filters.html @@ -1,49 +1,4 @@ -[% SET show_all_states = c.cobrand.filter_show_all_states OR (c.user_exists AND (c.user.is_superuser OR c.user.belongs_to_body(body.id))) %] -[% select_status = BLOCK %] - <select class="form-control js-multiple" name="status" id="statuses" multiple - data-all="[% loc('All') %]" - [% IF show_all_states %] - [% options = []; - FOR group IN filter_states; FOR state IN group.1; - NEXT IF state == 'hidden'; - SET state = 'fixed' IF state == 'fixed - council'; - options.push(state); - END; END - %] - data-all-options='["[% options.join('", "') %]"]' - [%~ ELSE ~%] - [%~ IF has_fixed_state ~%] - data-all-options='["open","closed","fixed"]' - [%~ ELSE ~%] - data-all-options='["open","closed"]' - [%~ END ~%] - [%~ END ~%] - [% INCLUDE 'reports/_status_filter_options.html' %] - > - [% IF c.user_exists AND c.user.has_body_permission_to('planned_reports') AND !shortlist %] - <option value="shortlisted"[% ' selected' IF filter_status.shortlisted %]>[% loc('Shortlisted') %]</option> - <option value="unshortlisted"[% ' selected' IF filter_status.unshortlisted %]>[% loc('Unshortlisted') %]</option> - [% END %] - [% IF c.user_exists AND ( c.user.has_body_permission_to('report_inspect') OR c.user.has_body_permission_to('report_mark_private') ) %] - <option value="non_public"[% ' selected' IF filter_status.non_public %]>[% loc('Private only') %]</option> - [% END %] - [% IF show_all_states %] - [% FOR group IN filter_states %] - [% FOR state IN group.1 %] - [% NEXT IF state == 'hidden' %] - [% SET state = 'fixed' IF state == 'fixed - council' ~%] - <option value="[% state %]"[% ' selected' IF filter_status.$state %]>[% prettify_state(state, 1) %]</option> - [% END %] - [% END %] - [% ELSE %] - <option value="open"[% ' selected' IF filter_status.open %]>[% prettify_state('confirmed') %]</option> - <option value="closed"[% ' selected' IF filter_status.closed %]>[% prettify_state('closed') %]</option> - [% IF has_fixed_state %] - <option value="fixed"[% ' selected' IF filter_status.fixed %]>[% prettify_state('fixed') %]</option> - [% END %] - [% END %] - </select> -[% END %] +[% select_status = PROCESS 'reports/_list-filter-status.html' %] [% select_category = BLOCK %] [% IF filter_categories.size %] |