Module: ActiveScaffold::Helpers::BatchCreateColumnHelpers
- Defined in:
- lib/active_scaffold/helpers/batch_create_column_helpers.rb
Overview
Helpers that assist with the rendering of a Form Column
Instance Method Summary collapse
-
#active_scaffold_batch_create_by_column(column, scope = nil, options = {}) ⇒ Object
This method decides which input to use for the given column.
- #active_scaffold_batch_create_singular_association(column, html_options) ⇒ Object
- #batch_create_multiple_layout ⇒ Object
- #batch_create_multiple_remove_link ⇒ Object
- #current_form_columns(record, scope, subform_controller = nil) ⇒ Object
Instance Method Details
#active_scaffold_batch_create_by_column(column, scope = nil, options = {}) ⇒ Object
This method decides which input to use for the given column. It does not do any rendering. It only decides which method is responsible for rendering.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_scaffold/helpers/batch_create_column_helpers.rb', line 7 def active_scaffold_batch_create_by_column(column, scope = nil, = {}) = (column, scope, ) if column.form_ui == :record_select active_scaffold_record_select(column, , batch_create_by_records, true) elsif column.association active_scaffold_batch_create_singular_association(column, ) else text_area_tag(column.name, params[:record] ? params[:record][column.name] : '', .merge(column.[:html_options] || {})) end end |
#active_scaffold_batch_create_singular_association(column, html_options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_scaffold/helpers/batch_create_column_helpers.rb', line 20 def active_scaffold_batch_create_singular_association(column, ) = batch_create_by_records.collect {|r| r.id} = (column.association, nil, .delete(:record)) .update(column.[:html_options] || {}) = {} .update(column.) [:name] = "#{[:name]}[]" [:multiple] = true select_tag(column.name, (.uniq, :id, column.[:label_method] || :to_label, ), ) end |
#batch_create_multiple_layout ⇒ Object
35 36 37 |
# File 'lib/active_scaffold/helpers/batch_create_column_helpers.rb', line 35 def batch_create_multiple_layout "batch_create_form_#{active_scaffold_config.batch_create.layout}" end |
#batch_create_multiple_remove_link ⇒ Object
31 32 33 |
# File 'lib/active_scaffold/helpers/batch_create_column_helpers.rb', line 31 def batch_create_multiple_remove_link link_to as_(:remove), '#', :class => 'remove' end |
#current_form_columns(record, scope, subform_controller = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/active_scaffold/helpers/batch_create_column_helpers.rb', line 39 def current_form_columns(record, scope, subform_controller = nil) columns = super return columns if columns if %i[batch_new batch_create].include? action_name.to_sym active_scaffold_config.batch_create.columns.visible_columns_names elsif %i[batch_edit batch_update].include? action_name.to_sym active_scaffold_config.batch_update.columns.visible_columns_names end end |