Browse Source

extract partials

pull/464/head
Kat 3 years ago
parent
commit
9b11fec5b6
  1. 25
      app/views/case_logs/_log_filters.erb
  2. 10
      app/views/filters/_checkbox_filter.html.erb

25
app/views/case_logs/_log_filters.erb

@ -13,28 +13,9 @@
<div class="app-filter__content">
<div class="govuk-form-group app-filter__group">
<%= form_with url: "/logs", html: { method: :get } do |f| %>
<%= f.govuk_check_boxes_fieldset :year, legend: { text: "Collection year", size: "s"} do %>
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<% 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 %>
</div>
<% end %>
<%= f.govuk_check_boxes_fieldset :status, legend: { text: "Status", size: "s"} do %>
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<% 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 %>
</div>
<% 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 %>
</div>

10
app/views/filters/_checkbox_filter.html.erb

@ -0,0 +1,10 @@
<%= f.govuk_check_boxes_fieldset :year, legend: { text: label, size: "s"} do %>
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<% options.map do |key, option| %>
<%= f.govuk_check_box category, "#{key}",
label: { text: option },
checked: filter_selected?(category, key),
size: "s" %>
<% end %>
</div>
<% end %>
Loading…
Cancel
Save