From 9b11fec5b6f08d1b0c341792b4ba1214dec86d75 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 12 Apr 2022 09:08:31 +0100 Subject: [PATCH] extract partials --- app/views/case_logs/_log_filters.erb | 25 +++------------------ app/views/filters/_checkbox_filter.html.erb | 10 +++++++++ 2 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 app/views/filters/_checkbox_filter.html.erb diff --git a/app/views/case_logs/_log_filters.erb b/app/views/case_logs/_log_filters.erb index 7866b50f7..fb1cb32fa 100644 --- a/app/views/case_logs/_log_filters.erb +++ b/app/views/case_logs/_log_filters.erb @@ -13,28 +13,9 @@
<%= form_with url: "/logs", html: { method: :get } do |f| %> - <%= f.govuk_check_boxes_fieldset :year, legend: { text: "Collection year", size: "s"} do %> -
- <% years = {"2021": "2021/22", "2022": "2022/23"} %> - <% years.map do |key, option| %> - <%= f.govuk_check_box "year", "#{key}", - label: { text: option }, - checked: filter_selected?("year", key), - size: "s" %> - <% end %> -
- <% end %> - <%= f.govuk_check_boxes_fieldset :status, legend: { text: "Status", size: "s"} do %> -
- <% statuses = status_filters %> - <% statuses.map do |key, option| %> - <%= f.govuk_check_box "status", "#{key}", - label: { text: option }, - checked: filter_selected?("status", key), - size: "s" %> - <% end %> -
- <% end %> + <% years = {"2021": "2021/22", "2022": "2022/23"} %> + <%= render partial: "filters/checkbox_filter", locals: {f: f, options: years, label: "Collection year", category: "year" } %> + <%= render partial: "filters/checkbox_filter", locals: {f: f, options: status_filters, label: "Status", category: "status" } %> <%= f.govuk_submit "Apply filters", class: "govuk-!-margin-top-4" %> <% end %>
diff --git a/app/views/filters/_checkbox_filter.html.erb b/app/views/filters/_checkbox_filter.html.erb new file mode 100644 index 000000000..cb5208284 --- /dev/null +++ b/app/views/filters/_checkbox_filter.html.erb @@ -0,0 +1,10 @@ +<%= f.govuk_check_boxes_fieldset :year, legend: { text: label, size: "s"} do %> +
+ <% options.map do |key, option| %> + <%= f.govuk_check_box category, "#{key}", + label: { text: option }, + checked: filter_selected?(category, key), + size: "s" %> + <% end %> +
+<% end %> \ No newline at end of file