Sha256: 004a0987a61ebdea9cbb708ca1ba99609faf98f5352bd9de655f82488c183f90
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Admin::Resources::DataTypes::PaperclipHelper def table_paperclip_field(attribute, item) options = { :height => 25, :width => 25 } typus_paperclip_preview(item, attribute, options) end def link_to_detach_attribute_for_paperclip(attribute) validators = @item.class.validators.delete_if { |i| i.class != ActiveModel::Validations::PresenceValidator }.map { |i| i.attributes }.flatten.map { |i| i.to_s } attachment = @item.send(attribute) if attachment.exists? && !validators.include?("#{attribute}_file_name") && attachment attribute_i18n = @item.class.human_attribute_name(attribute) message = Typus::I18n.t("Remove") label_text = <<-HTML #{attribute_i18n} <small>#{link_to message, { :action => 'update', :id => @item.id, :attribute => attribute, :_continue => true }, :confirm => Typus::I18n.t("Are you sure?")}</small> HTML label_text.html_safe end end def typus_paperclip_preview(item, attachment, options = {}) data = item.send(attachment) return unless data.exists? styles = data.styles.keys if data.content_type =~ /^image\/.+/ && styles.include?(Typus.file_preview) && styles.include?(Typus.file_thumbnail) render "admin/templates/paperclip_preview", :preview => data.url(Typus.file_preview, false), :thumb => data.url(Typus.file_thumbnail, false), :options => options else link_to data.original_filename, data.url(:original, false) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
typus-3.1.0.rc8 | app/helpers/admin/resources/data_types/paperclip_helper.rb |
typus-3.1.0.rc7 | app/helpers/admin/resources/data_types/paperclip_helper.rb |