Module: Bhf::EntriesHelper

Defined in:
app/helpers/bhf/entries_helper.rb

Instance Method Summary collapse

Instance Method Details

#is_image?(file) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/helpers/bhf/entries_helper.rb', line 15

def is_image?(file)
  ! file.match(/\.png|\.jpg|\.jpeg|\.gif|\.svg/i).nil?
end

#node(f, field, &block) ⇒ Object



4
5
6
# File 'app/helpers/bhf/entries_helper.rb', line 4

def node(f, field, &block)
  render partial: 'bhf/helper/node', locals: {f: f, field: field, input: with_output_buffer(&block)}
end

#reflection_node(f, field, &block) ⇒ Object



8
9
10
11
12
13
# File 'app/helpers/bhf/entries_helper.rb', line 8

def reflection_node(f, field, &block)
  return if field.form_type == :static && f.object.new_record? && f.object.send(field.reflection.name).blank?
  render partial: 'bhf/helper/reflection_node', locals: {
    f: f, field: field, input: with_output_buffer(&block)
  }
end

#reflection_title(f, field) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/bhf/entries_helper.rb', line 19

def reflection_title(f, field)
  title = f.object.class.human_attribute_name(field.reflection.name)
  if field.link
    title = t("bhf.platforms.#{field.link}.title", count: f.object.send(field.reflection.name).to_a.count, default: title)
  end
  title
end