Class: Layout::SearchComponent

Inherits:
CommonComponent show all
Defined in:
app/components/layout/search_component.rb

Overview

this class render an events search panel

Instance Method Summary collapse

Methods inherited from CommonComponent

#icon, #icon_text, #level, #level_item, #pagy, #turbo_yield

Methods included from ApplicationHelper

#fas_icon, #icon, #icon_text, #l_date, #l_long, #l_time, #notifications, #notify, #notify_status, #t_enum

Constructor Details

#initialize(url:, turbo_frame:, text: true, date_range: true, scope: nil, blank: true, categories: [], editor: false, soldout: false) ⇒ SearchComponent

Returns a new instance of SearchComponent.

Parameters:

  • url (String)

    form destination url

  • turbo_frame (String)

    turbo_frame name to update

  • scope (String) (defaults to: nil)

    (nil) optional, default: nil id or key to add as hidden_field in the form for scoped search

  • text (Boolean) (defaults to: true)

    (true) if true add text search input

  • date_range (Boolean) (defaults to: true)

    (true) if true add start_at and stop_at date input

  • categories (Array) (defaults to: [])

    ([]) if present add a category select input

  • blank (Boolean) (defaults to: true)

    (true) if true add include_blank to category select

  • editor (Boolean) (defaults to: false)

    (false) if true make start_at not mandatory

  • soldout (Boolean) (defaults to: false)

    (false) if true add soldout select input



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/layout/search_component.rb', line 26

def initialize(url:, turbo_frame:, text: true, date_range: true, scope: nil, blank: true, categories: [], editor: false, soldout: false)
  super
  @url = url
  @turbo_frame = turbo_frame
  @text = text
  @scope = scope
  @categories = categories
  @blank = blank
  @date_range = date_range
  @soldout = soldout
  @editor = editor
end

Instance Method Details

#include_blankHash

make hash for include_blank

Returns:

  • (Hash)

    if @blank is true return include_blank with the localize value

  • (Hash)

    if @blank is false, return an empty Hash



42
43
44
45
46
47
48
# File 'app/components/layout/search_component.rb', line 42

def include_blank
  if @blank
    { include_blank: t(".all_category") }
  else
    {}
  end
end