Module: Fae::NestedFormHelper

Defined in:
app/helpers/fae/nested_form_helper.rb

Instance Method Summary collapse

Instance Method Details

#td_columns(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/fae/nested_form_helper.rb', line 11

def td_columns(params)
  attribute = params[:col]
  attributes = params[:cols]
  item = params[:item]

  attribute = (attribute.is_a?(Hash) && attribute[:attr]) ? attribute[:attr] : attribute
  first_attribute = (attributes.first.kind_of?(Hash) && attributes.first[:attr]) ? attributes.first[:attr] : attributes.first

  if attribute == first_attribute && !params[:edit_column]
    (:td) do
      (:a, class: 'js-edit-link', href: self.send(params[:edit_path], item)) do
        col_name_or_image(item, attribute)
      end
    end
  elsif item.class.columns_hash[attribute.to_s].present? && item.class.columns_hash[attribute.to_s].type == :boolean
    (:td) do attr_toggle(item, attribute) end
  else
    (:td) do col_name_or_image(item, attribute) end
  end
end

#th_columns(attribute) ⇒ Object



4
5
6
7
8
9
# File 'app/helpers/fae/nested_form_helper.rb', line 4

def th_columns(attribute)
  attribute = (attribute.is_a?(Hash) && attribute[:title]) ? attribute[:title] : attribute

  th_class = '-action-wide' if [:on_production, :on_prod, :on_stage].include?(attribute)
  (:th, class: th_class) do attribute.to_s.titleize end
end