Module: Playbook::PbDropdown::QuickpickHelper

Defined in:
app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb

Class Method Summary collapse

Class Method Details

.get_quickpick_options(range_ends_today: false, custom_quick_pick_dates: {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb', line 7

def get_quickpick_options(range_ends_today: false, custom_quick_pick_dates: {})
  default_options = build_default_options(range_ends_today)

  # Handle custom_quick_pick_dates
  return default_options if custom_quick_pick_dates.blank?

  dates = custom_quick_pick_dates[:dates] || custom_quick_pick_dates["dates"]
  return default_options if dates.blank?

  custom_options = dates.map { |date_config| build_custom_option(date_config) }

  # Override logic
  override = custom_quick_pick_dates[:override]
  override = custom_quick_pick_dates["override"] if override.nil?

  if override == false
    default_options + custom_options
  else
    custom_options
  end
end