Sha256: 3ca7a44d8bf0b56991aad4241454c7712df74029a77fb24dce078fbb9f6331f1

Contents?: true

Size: 1.39 KB

Versions: 23

Compression:

Stored size: 1.39 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)
        record = options[:object]
        if record.send(column.name)
          # we already have a value? display the form for deletion.
          case ActiveScaffold.js_framework
          when :jquery
            remove_file_js = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show(); return false;"
          when :prototype
            remove_file_js = "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show(); return false;"
          end

          hidden_options = options.merge(:id => options[:id] + '_delete', :name => options[:name].sub("[#{column.name}]", "[delete_#{column.name}]"), :value => 'false')
          custom_hidden_field_tag = hidden_field(:record, column.name, hidden_options)

          content_tag(:div) do
            content_tag(:div) do
              safe_join [get_column_value(record, column), custom_hidden_field_tag, '|',
                         content_tag(:a, as_(:remove_file), :href => '#', :onclick => remove_file_js),
                         content_tag(:div, 'test', :style => 'display: none')], ' '
            end
          end
        else
          file_column_field('record', column.name, options)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_scaffold-3.7.0 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.20 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.19 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.17 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.15 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.14 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.13 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.12 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.11.1 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.11 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.10 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.9 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.8 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.6 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.5 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.4.1 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.4 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.3 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.2 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.6.1 lib/active_scaffold/bridges/file_column/form_ui.rb