|
|
|
@ -5,7 +5,9 @@ module FiltersHelper |
|
|
|
selected_filters = JSON.parse(session[session_name_for(filter_type)]) |
|
|
|
selected_filters = JSON.parse(session[session_name_for(filter_type)]) |
|
|
|
return true if selected_filters.blank? && filter == "user" && value == :all |
|
|
|
return true if selected_filters.blank? && filter == "user" && value == :all |
|
|
|
return true if !selected_filters.key?("organisation") && filter == "organisation_select" && value == :all |
|
|
|
return true if !selected_filters.key?("organisation") && filter == "organisation_select" && value == :all |
|
|
|
|
|
|
|
return true if !selected_filters.key?("owning_organisation") && filter == "owning_organisation_select" && value == :all |
|
|
|
return true if selected_filters["organisation"].present? && filter == "organisation_select" && value == :specific_org |
|
|
|
return true if selected_filters["organisation"].present? && filter == "organisation_select" && value == :specific_org |
|
|
|
|
|
|
|
return true if selected_filters["owning_organisation"].present? && filter == "owning_organisation_select" && value == :specific_org |
|
|
|
return false if selected_filters[filter].blank? |
|
|
|
return false if selected_filters[filter].blank? |
|
|
|
|
|
|
|
|
|
|
|
selected_filters[filter].include?(value.to_s) |
|
|
|
selected_filters[filter].include?(value.to_s) |
|
|
|
@ -42,6 +44,11 @@ module FiltersHelper |
|
|
|
[OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) } |
|
|
|
[OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def owning_organisations_filter_options(user) |
|
|
|
|
|
|
|
organisation_options = user.support? ? Organisation.all : [user.organisation] + user.organisation.stock_owners |
|
|
|
|
|
|
|
[OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def collection_year_options |
|
|
|
def collection_year_options |
|
|
|
{ "2023": "2023/24", "2022": "2022/23", "2021": "2021/22" } |
|
|
|
{ "2023": "2023/24", "2022": "2022/23", "2021": "2021/22" } |
|
|
|
end |
|
|
|
end |
|
|
|
|