|
|
@ -4,8 +4,13 @@ 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?("owning_organisation") && filter == "owning_organisation_select" && value == :all |
|
|
|
return true if !selected_filters.key?("owning_organisation") && filter == "owning_organisation_select" && value == :all |
|
|
|
|
|
|
|
return true if !selected_filters.key?("managing_organisation") && filter == "managing_organisation_select" && value == :all |
|
|
|
|
|
|
|
|
|
|
|
return true if selected_filters["owning_organisation"].present? && filter == "owning_organisation_select" && value == :specific_org |
|
|
|
return true if selected_filters["owning_organisation"].present? && filter == "owning_organisation_select" && value == :specific_org |
|
|
|
|
|
|
|
return true if selected_filters["managing_organisation"].present? && filter == "managing_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) |
|
|
@ -18,6 +23,7 @@ module FiltersHelper |
|
|
|
filters = JSON.parse(filters_json) |
|
|
|
filters = JSON.parse(filters_json) |
|
|
|
filters["user"] == "yours" || |
|
|
|
filters["user"] == "yours" || |
|
|
|
filters["organisation"].present? || |
|
|
|
filters["organisation"].present? || |
|
|
|
|
|
|
|
filters["managing_organisation"].present? || |
|
|
|
filters["status"]&.compact_blank&.any? || |
|
|
|
filters["status"]&.compact_blank&.any? || |
|
|
|
filters["years"]&.compact_blank&.any? || |
|
|
|
filters["years"]&.compact_blank&.any? || |
|
|
|
filters["bulk_upload_id"].present? |
|
|
|
filters["bulk_upload_id"].present? |
|
|
@ -56,6 +62,11 @@ module FiltersHelper |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def managing_organisation_filter_options(user) |
|
|
|
|
|
|
|
organisation_options = user.support? ? Organisation.all : [user.organisation] + user.organisation.managing_agents |
|
|
|
|
|
|
|
[OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def applied_filters_count(filter_type) |
|
|
|
def applied_filters_count(filter_type) |
|
|
|