Class: Ez::Resources::SearchCell

Inherits:
ApplicationCell show all
Defined in:
app/cells/ez/resources/search_cell.rb

Constant Summary collapse

SEARCHABLE_FIELDS =
%i[string association select link boolean checkboxes].freeze

Constants inherited from ApplicationCell

ApplicationCell::CSS_SCOPE

Instance Method Summary collapse

Methods inherited from ApplicationCell

#css_for, #custom_css_map, #div_for, form, #t

Instance Method Details

#cast_field_type(type) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/cells/ez/resources/search_cell.rb', line 10

def cast_field_type(type)
  case type
  when :link then :string
  when :boolean then :select
  when :association then :string
  else
    type
  end
end

#field_input_name(field) ⇒ Object



20
21
22
23
24
25
26
# File 'app/cells/ez/resources/search_cell.rb', line 20

def field_input_name(field)
  if association?(field)
    search_key(field.name, field.search_suffix, field.options.fetch(:association))
  else
    search_key(field.name, field.search_suffix)
  end
end

#field_label(field) ⇒ Object



28
29
30
# File 'app/cells/ez/resources/search_cell.rb', line 28

def field_label(field)
  field.search_label || "#{field.title} (#{t "search.suffix.#{field.search_suffix}"})"
end