Class: RailsAdmin::Config::Fields::Types::RichPicker

Inherits:
Base
  • Object
show all
Defined in:
lib/rich/rails_admin/config/fields/types/rich_picker.rb

Instance Method Summary collapse

Instance Method Details

#editor_optionsObject



23
24
25
# File 'lib/rich/rails_admin/config/fields/types/rich_picker.rb', line 23

def editor_options
  Rich.options(config, scope_type, scope_id)
end

#preview_image_pathObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rich/rails_admin/config/fields/types/rich_picker.rb', line 27

def preview_image_path
  if value.to_s.html_safe != ""
    if (true if Float(value) rescue false)
      # if the value is numeric we assume its an object id
      rich_file = Rich::RichFile.find(value)
      rich_file.rich_file.url(:rich_thumb)
    else
      # if not, we assume its a url
      value.to_s
    end
  else
    # no value, show placeholder image
    editor_options[:placeholder_image]
  end

end

#scope_idObject



19
20
21
# File 'lib/rich/rails_admin/config/fields/types/rich_picker.rb', line 19

def scope_id
  bindings[:object].id
end

#scope_typeObject



15
16
17
# File 'lib/rich/rails_admin/config/fields/types/rich_picker.rb', line 15

def scope_type
  bindings[:form].object_name
end