Browse Source

Add remaining filter questions

pull/2423/head
Kat 2 years ago committed by kosiakkatrina
parent
commit
2d50020cba
  1. 19
      app/helpers/filters_helper.rb
  2. 1
      app/views/filters/_radio_filter.html.erb
  3. 22
      app/views/filters/lettings_log_filters/assigned_to.html.erb
  4. 20
      app/views/filters/lettings_log_filters/managed_by.html.erb
  5. 10
      app/views/filters/lettings_log_filters/needstype.html.erb
  6. 20
      app/views/filters/lettings_log_filters/owned_by.html.erb
  7. 10
      app/views/filters/lettings_log_filters/status.html.erb

19
app/helpers/filters_helper.rb

@ -102,6 +102,14 @@ module FiltersHelper
} }
end end
def collection_year_radio_options
{
current_collection_start_year.to_s => { label: year_combo(current_collection_start_year) },
previous_collection_start_year.to_s => { label: year_combo(previous_collection_start_year) },
archived_collection_start_year.to_s => { label: year_combo(archived_collection_start_year) },
}
end
def filters_applied_text(filter_type) def filters_applied_text(filter_type)
applied_filters_count(filter_type).zero? ? "No filters applied" : "#{pluralize(applied_filters_count(filter_type), 'filter')} applied" applied_filters_count(filter_type).zero? ? "No filters applied" : "#{pluralize(applied_filters_count(filter_type), 'filter')} applied"
end end
@ -157,6 +165,17 @@ module FiltersHelper
filters_count(applied_filters(filter_type)) filters_count(applied_filters(filter_type))
end end
def check_your_answers_lettings_filters_list(session_filters)
[
{ label: "Collection year", value: session_filters["years"]&.to_sentence, path: filters_years_lettings_logs_path },
{ label: "Status", value: session_filters["status"]&.to_sentence, path: filters_status_lettings_logs_path },
{ label: "Needs type", value: session_filters["needstypes"]&.to_sentence, path: filters_needstype_lettings_logs_path },
{ label: "Assigned to", value: session_filters["assigned_to"]&.to_s, path: filters_assigned_to_lettings_logs_path },
{ label: "Owned by", value: session_filters["owning_organisation"]&.to_s, path: filters_owned_by_lettings_logs_path },
{ label: "Managed by", value: session_filters["managing_organisation"]&.to_s, path: filters_managed_by_lettings_logs_path },
]
end
private private
def applied_filters(filter_type) def applied_filters(filter_type)

1
app/views/filters/_radio_filter.html.erb

@ -3,6 +3,7 @@
<%= f.govuk_radio_button category, key.to_s, <%= f.govuk_radio_button category, key.to_s,
label: { text: option[:label] }, label: { text: option[:label] },
checked: filter_selected?(category, key, @filter_type), checked: filter_selected?(category, key, @filter_type),
name: "#{category}[]",
size: "s" do %> size: "s" do %>
<% if option[:conditional_filter] %> <% if option[:conditional_filter] %>
<%= render partial: "filters/#{option[:conditional_filter][:type]}_filter", locals: { <%= render partial: "filters/#{option[:conditional_filter][:type]}_filter", locals: {

22
app/views/filters/lettings_log_filters/assigned_to.html.erb

@ -0,0 +1,22 @@
<%= form_with model: @filter_form, url: filters_lettings_logs_path(search: @search_term, codes_only: @codes_only) do |f| %>
<%= render partial: "filters/radio_filter",
locals: {
f:,
options: {
"all": { label: "Any user" },
"you": { label: "You" },
"specific_user": {
label: "Specific user",
conditional_filter: {
type: "select",
label: "User",
category: "user",
options: assigned_to_filter_options(current_user),
},
},
},
label: "Assigned to",
category: "assigned_to",
} %>
<%= f.govuk_submit "Save changes", class: "govuk-!-margin-bottom-0" %>
<% end %>

20
app/views/filters/lettings_log_filters/managed_by.html.erb

@ -0,0 +1,20 @@
<%= form_with model: @filter_form, url: filters_lettings_logs_path(search: @search_term, codes_only: @codes_only) do |f| %>
<%= render partial: "filters/radio_filter", locals: {
f:,
options: {
"all": { label: "Any managing organisation" },
"specific_org": {
label: "Specific managing organisation",
conditional_filter: {
type: "select",
label: user_or_org_lettings_path? ? "Managed by" : "Reported by",
category: "managing_organisation",
options: managing_organisation_filter_options(current_user),
},
},
},
label: user_or_org_lettings_path? ? "Managed by" : "Reported by",
category: "managing_organisation_select",
} %>
<%= f.govuk_submit "Save changes", class: "govuk-!-margin-bottom-0" %>
<% end %>

10
app/views/filters/lettings_log_filters/needstype.html.erb

@ -0,0 +1,10 @@
<%= form_with model: @filter_form, url: filters_lettings_logs_path(search: @search_term, codes_only: @codes_only) do |f| %>
<%= render partial: "filters/checkbox_filter",
locals: {
f:,
options: needstype_filters,
label: "Needs type",
category: "needstypes",
} %>
<%= f.govuk_submit "Save changes", class: "govuk-!-margin-bottom-0" %>
<% end %>

20
app/views/filters/lettings_log_filters/owned_by.html.erb

@ -0,0 +1,20 @@
<%= form_with model: @filter_form, url: filters_lettings_logs_path(search: @search_term, codes_only: @codes_only) do |f| %>
<%= render partial: "filters/radio_filter", locals: {
f:,
options: {
"all": { label: "Any owning organisation" },
"specific_org": {
label: "Specific owning organisation",
conditional_filter: {
type: "select",
label: "Owning Organisation",
category: "owning_organisation",
options: owning_organisation_filter_options(current_user),
},
},
},
label: "Owned by",
category: "owning_organisation_select",
} %>
<%= f.govuk_submit "Save changes", class: "govuk-!-margin-bottom-0" %>
<% end %>

10
app/views/filters/lettings_log_filters/status.html.erb

@ -0,0 +1,10 @@
<%= form_with model: @filter_form, url: filters_lettings_logs_path(search: @search_term, codes_only: @codes_only) do |f| %>
<%= render partial: "filters/checkbox_filter",
locals: {
f:,
options: status_filters,
label: "Status",
category: "status",
} %>
<%= f.govuk_submit "Save changes", class: "govuk-!-margin-bottom-0" %>
<% end %>
Loading…
Cancel
Save