class Para::Inputs::NestedManyInput
Attributes
resource[R]
Public Instance Methods
input(_wrapper_options = nil)
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 6 def input(_wrapper_options = nil) input_html_options[:class] << 'nested-many' orderable = options.fetch(:orderable, model.orderable?) add_button = options.fetch(:add_button, true) # Load existing resources resources = object.send(attribute_name) # Order them if the list should be orderable resources = resources.sort_by(&:position) if orderable locals = options.fetch(:locals, {}) with_global_nested_field do template.render( partial: 'para/inputs/nested_many', locals: { form: @builder, model: model, attribute_name: attribute_name, orderable: orderable, add_button: add_button, dom_identifier: dom_identifier, resources: resources, nested_locals: locals, subclass: subclass, subclasses: subclasses, add_button_label: add_button_label, add_button_class: add_button_class, allow_destroy_if: allow_destroy_if, inset: inset?, uncollapsed: uncollapsed?, render_partial: render_partial?, remote_partial_params: remote_partial_params } ) end end
Protected Instance Methods
render_partial?()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 46 def render_partial? options[:render_partial] || object.errors.any? || (object.persisted? && uncollapsed?) || parent_nested_field(fallback_to_self: false)&.render_partial? end
Private Instance Methods
allow_destroy_if()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 63 def allow_destroy_if options.fetch(:allow_destroy_if, nil) end
inset?()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 67 def inset? options.fetch(:inset, false) end
model()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 59 def model @model ||= parent_model.reflect_on_association(attribute_name).klass end
parent_model()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 55 def parent_model @parent_model ||= @builder.object.class end
remote_partial_params()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 75 def remote_partial_params @remote_partial_params ||= options.fetch(:remote_partial_params, {}).merge( namespace: :nested_form ) end
uncollapsed?()
click to toggle source
# File lib/para/inputs/nested_many_input.rb, line 71 def uncollapsed? inset? && Para.config.uncollapse_inset_nested_fields end