Module: ActiveScaffoldCamera::ViewHelpers

Defined in:
lib/active_scaffold_camera/view_helpers.rb

Constant Summary collapse

I18N_ATTRIBUTES =
[:video_not_supported, :audio_not_supported, :media_forbidden]

Instance Method Summary collapse

Instance Method Details

#active_scaffold_column_snapshot(record, column, ui_options: column.options) ⇒ Object



17
18
19
20
# File 'lib/active_scaffold_camera/view_helpers.rb', line 17

def active_scaffold_column_snapshot(record, column, ui_options: column.options)
  value = record.send(column.name)
  tag :img, :src => value if value
end

#active_scaffold_input_snapshot(column, html_options, ui_options: column.options) ⇒ Object



11
12
13
14
15
# File 'lib/active_scaffold_camera/view_helpers.rb', line 11

def active_scaffold_input_snapshot(column, html_options, ui_options: column.options)
   :div, :class => "snapshot-input #{html_options[:class]}", :id => html_options[:id], :data => snapshot_attributes(column, ui_options: ui_options) do
    hidden_field :record, column.name, :name => html_options[:name]
  end
end

#snapshot_attributes(column, ui_options: column.options) ⇒ Object



4
5
6
7
8
9
# File 'lib/active_scaffold_camera/view_helpers.rb', line 4

def snapshot_attributes(column, ui_options: column.options)
  attributes = Hash[I18N_ATTRIBUTES.map{ |attr| [attr, ui_options[attr] || attr] }]
  attributes[:source] = ui_options[:source] if ui_options[:source]
  I18N_ATTRIBUTES.each { |attr| attributes[attr] = as_(attributes[attr]) if attributes[attr].is_a? Symbol }
  attributes
end