Sha256: ac0a138d9f032d10ac0d2fb3c723208f8efd26d4cafdd09ae67a32966d6a6d28

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

module ActiveScaffold
  module Helpers
    # Helpers that assist with the rendering of a Form Column
    module FormColumnHelpers
      def active_scaffold_input_file_column(column, options)
        if @record.send(column.name) 
          # we already have a value?  display the form for deletion.
          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'; p=$(this).up(); p.hide(); p.next().show(); return false;";
          end
          content_tag(
            :div, 
            content_tag(
              :div, 
              get_column_value(@record, column) + " " +
              custom_hidden_field_tag +
              " | " +
                content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code}),
              {}
            ) +
            content_tag(
              :div,
              file_column_field("record", column.name, options),
              :style => "display: none"
            ),
            {}
          )
        else
          # no, just display the file_column_field
          file_column_field("record", column.name, options)
        end
      end      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_scaffold-3.1.5 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.1.4 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.1.3 lib/active_scaffold/bridges/file_column/form_ui.rb