Sha256: f4867ffab81db3e1eb83468f8de4446c272f7678e71e6844891c6114641cac6f

Contents?: true

Size: 1.48 KB

Versions: 42

Compression:

Stored size: 1.48 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
            remove_file_js = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
          else
            remove_file_js = "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show(); return false;";
          end            
          
          hidden_options = options.dup
          hidden_options[:id] += '_delete'
          hidden_options[:name].sub!("[#{column.name}]", "[delete_#{column.name}]")
          hidden_options[:value] = 'false'          
          custom_hidden_field_tag = hidden_field(:record, column.name, hidden_options)

          content_tag(:div) do
            content_tag(:div) do
              content = get_column_value(@record, column) + " #{custom_hidden_field_tag} | ".html_safe
              content += content_tag(:a, as_(:remove_file), {:href => '#', :onclick => remove_file_js})
              content += content_tag(:div, file_column_field("record", column.name, options), :style => "display: none")
            end           
          end
       else
          file_column_field("record", column.name, options)          
       end        
      end
      
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
active_scaffold-3.3.3 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.2 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.1 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.0 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.20 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.0.rc3 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.0.rc2 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.19 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.3.0.rc lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.17 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.16 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.15 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.14 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.13 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.12 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.11 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.10 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.9 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.8 lib/active_scaffold/bridges/file_column/form_ui.rb
active_scaffold-3.2.7 lib/active_scaffold/bridges/file_column/form_ui.rb