Sha256: 094bf3e2237c45b94e63818b72b1c09153162bc0bfa94912f7c0e4a7b1ee4131

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module ActiveScaffold
  module Helpers
    module FormColumnHelpers
      def active_scaffold_input_paperclip(column, options)
        options = active_scaffold_input_text_options(options)
        input = file_field(:record, column.name, options)
        paperclip = @record.send("#{column.name}")
        if paperclip.file?
          if ActiveScaffold.js_framework == :jquery
            js_remove_file_code = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
          else
            js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show(); return false;";
          end
          
          content = active_scaffold_column_paperclip(@record, column)
          content_tag(:div,
            content + " | " +
              hidden_field(:record, "delete_#{column.name}", :value => "false") +
              content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code}) 
          ) + content_tag(:div, input, :style => "display: none")
        else
          input
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_scaffold-3.3.0.rc3 lib/active_scaffold/bridges/paperclip/form_ui.rb
active_scaffold-3.3.0.rc2 lib/active_scaffold/bridges/paperclip/form_ui.rb
active_scaffold-3.3.0.rc lib/active_scaffold/bridges/paperclip/form_ui.rb