Skip to content

Commit

Permalink
Refactor advanced search component a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
javierm committed Jun 16, 2020
1 parent 149845e commit d344eff
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/components/advanced_search_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(search_path)

def official_level_search_options
options_for_select((1..5).map { |i| [setting["official_level_#{i}_name"], i] },
params[:advanced_search].try(:[], :official_level))
search_params[:official_level])
end

def date_range_options
Expand All @@ -24,10 +24,14 @@ def date_range_options
end

def selected_date_range
custom_date_range? ? "custom" : params[:advanced_search].try(:[], :date_min)
custom_date_range? ? "custom" : search_params[:date_min]
end

def custom_date_range?
params[:advanced_search].try(:[], :date_max).present?
search_params[:date_max].present?
end

def search_params
params[:advanced_search] || {}
end
end

0 comments on commit d344eff

Please sign in to comment.