Module: Admin::Resources::DataTypes::DragonflyHelper
- Defined in:
- app/helpers/admin/resources/data_types/dragonfly_helper.rb
Instance Method Summary collapse
- #link_to_detach_attribute_for_dragonfly(attribute) ⇒ Object
- #table_dragonfly_field(attribute, item) ⇒ Object
- #typus_dragonfly_form_preview(item, attachment, options = {}) ⇒ Object
- #typus_dragonfly_preview(item, attachment) ⇒ Object
Instance Method Details
#link_to_detach_attribute_for_dragonfly(attribute) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/admin/resources/data_types/dragonfly_helper.rb', line 7 def link_to_detach_attribute_for_dragonfly(attribute) validators = @item.class.validators.delete_if { |i| i.class != ActiveModel::Validations::PresenceValidator }.map(&:attributes).flatten.map(&:to_s) = @item.send(attribute) if .present? && !validators.include?(attribute) && attribute_i18n = @item.class.human_attribute_name(attribute) label_text = <<-HTML #{attribute_i18n} <small>#{link_to Typus::I18n.t("Remove"), { :action => 'update', :id => @item.id, :_nullify => attribute, :_continue => true }, :confirm => Typus::I18n.t("Are you sure?")}</small> HTML label_text.html_safe end end |
#table_dragonfly_field(attribute, item) ⇒ Object
3 4 5 |
# File 'app/helpers/admin/resources/data_types/dragonfly_helper.rb', line 3 def table_dragonfly_field(attribute, item) typus_dragonfly_preview(item, attribute) end |
#typus_dragonfly_form_preview(item, attachment, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/admin/resources/data_types/dragonfly_helper.rb', line 34 def typus_dragonfly_form_preview(item, , = {}) data = item.send() return unless data if data.mime_type =~ /^image\/.+/ render "admin/templates/dragonfly_form_preview", :attachment => data, :preview => data.process(:thumb, Typus.image_preview_size).url, :thumb => data.process(:thumb, Typus.image_thumb_size).url, :options => else html = params[:_popup] ? data.name : link_to(data.name, data.url) # OPTIMIZE: Generate the tag with Ruby. "<p>#{html}</p>".html_safe end end |
#typus_dragonfly_preview(item, attachment) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/admin/resources/data_types/dragonfly_helper.rb', line 21 def typus_dragonfly_preview(item, ) data = item.send() return unless data if data.mime_type =~ /^image\/.+/ render "admin/templates/dragonfly_preview", :preview => data.process(:thumb, Typus.image_preview_size).url, :thumb => data.process(:thumb, Typus.image_table_thumb_size).url else params[:_popup] ? data.name : link_to(data.name, data.url) end end |