diff --git a/app/views/case_logs/_log_filters.erb b/app/views/case_logs/_log_filters.erb index ded8bc9dc..45354fb40 100644 --- a/app/views/case_logs/_log_filters.erb +++ b/app/views/case_logs/_log_filters.erb @@ -6,7 +6,7 @@
<%= form_with url: "/logs", html: { method: :get } do |f| %> <% years = {"2021": "2021/22", "2022": "2022/23"} %> - <% all_or_yours = {"all": "All", "yours": "Yours"} %> + <% all_or_yours = {"all": { label: "All" }, "yours": { label: "Yours" } } %> <%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %> <%= render partial: "filters/checkbox_filter", locals: { f: f, options: status_filters, label: "Status", category: "status" } %> <%= render partial: "filters/radio_filter", locals: { f: f, options: all_or_yours, label: "Logs", category: "user", } %> @@ -15,10 +15,18 @@ f: f, options: { "all": { label: "All" }, - "specific_org": { label: "Specific organisation", conditional_filter: { type: "select", label: "Organisation", category: "organisation" } } + "specific_org": { + label: "Specific organisation", + conditional_filter: { + type: "select", + label: "Organisation", + category: "organisation", + options: [OpenStruct.new(id: "", name: "Select an option")] + Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } + } + } }, label: "Organisation", - category: "organisation" + category: "organisation_select" } %> <% end %> <%= f.govuk_submit "Apply filters", class: "govuk-!-margin-bottom-0" %> diff --git a/app/views/filters/_radio_filter.html.erb b/app/views/filters/_radio_filter.html.erb index e246a7dcd..abb55eafe 100644 --- a/app/views/filters/_radio_filter.html.erb +++ b/app/views/filters/_radio_filter.html.erb @@ -1,17 +1,18 @@ <%= f.govuk_radio_buttons_fieldset category.to_sym, legend: { text: label, size: "s" }, small: true, form_group: { classes: "app-filter__group" } do %> <% options.map do |key, option| %> <%= f.govuk_radio_button category, key.to_s, - label: { text: option }, + label: { text: option[:label] }, checked: filter_selected?(category, key), - size: "s" - %> - <% if option[:conditional_filter] %> - <%= render partial: "filters/#{option[:conditional_filter][:type]}_filter", locals: { - f:, - collection: Organisation.all, - category: "organisation", - secondary: true, - } %> + size: "s" do %> + <% if option[:conditional_filter] %> + <%= render partial: "filters/#{option[:conditional_filter][:type]}_filter", locals: { + f:, + collection: option[:conditional_filter][:options], + category: option[:conditional_filter][:category], + label: option[:conditional_filter][:label], + secondary: true, + } %> + <% end %> <% end %> <% end %> <% end %>