class Basepack::Forms::Import
Attributes
action_name[R]
builder[R]
builder_default_options[RW]
edit_form[R]
list_form[R]
show_form[R]
Public Class Methods
new(factory, chain, options = {})
click to toggle source
Calls superclass method
Basepack::Forms::Base::new
# File lib/basepack/forms/import.rb, line 11 def initialize(factory, chain, options = {}) super(factory, chain, options) @action_name = options[:action_name] || :import @builder_default_options = { as: :import, html: { multipart: true, class: 'form-horizontal denser' }, defaults: { input_html: { class: 'span6'} } } if options[:show_form] @show_form = options[:show_form] end if options[:edit_form] @edit_form = options[:edit_form] @edit_form.builder_default_options[:as] = :import @edit_form.content_for_form do |form, opt = {}, &block| form.render_form!(opt) do view.safe_concat form.render_fields view.safe_concat(view.content_tag(:div, class: "pull-right") do form.view.render("forms/buttons/submit_create") end) end end end if options[:list_form] @list_form = options[:list_form] @list_form.content_for_row do |form, &block| view.content_tag(:tr, class: @show_form.resource.id == form.resource.id ? "success" : nil, &block) end @list_form.content_for_actions do |form| result = ''.html_safe result << form.render_action("Zobrazit", path(import_id: form.resource.id), "icon-eye-open", class: @show_form.resource.id == form.resource.id ? 'btn btn-mini disabled' : 'btn btn-mini', ) result << form.render_action("Smazat", path(delete_id: form.resource.id), "icon-trash", class: 'btn btn-mini btn-danger', method: :delete, data: { confirm: I18n.t('admin.form.confirmation') }) result end end end
Public Instance Methods
configuration_params(&block)
click to toggle source
# File lib/basepack/forms/import.rb, line 108 def configuration_params(&block) if block @configuration_params = block else if @configuration_params @configuration_params.(self, @show_form.resource) elsif @show_form.resource.respond_to? :configuration_params @show_form.resource.configuration_params else nil end end end
default_partial()
click to toggle source
# File lib/basepack/forms/import.rb, line 81 def default_partial 'forms/import' end
field_nested_name(field)
click to toggle source
# File lib/basepack/forms/import.rb, line 85 def field_nested_name(field) field.form.nested_in ? "#{field_nested_name(field.form.nested_in)}[#{field.method_name}]" : field.method_name end
fields_for_import_as_select_options()
click to toggle source
# File lib/basepack/forms/import.rb, line 89 def fields_for_import_as_select_options @normal = [["Žádný", '']] @association = [] visible_fields.each do |field| if !field.association? @normal << [field.label.to_s, field.method_name.to_s] elsif nform = field.nform # nested form next if field.multiple? or !field.nested_form nform.visible_fields.each do |f| @association << [f.nested_label, field_nested_name(f)] end end end @normal + @association end
path(params = {})
click to toggle source
# File lib/basepack/forms/import.rb, line 58 def path(params = {}) view.polymorphic_path([@action_name, association_chain, resource_class].flatten, params) end
view=(view)
click to toggle source
Calls superclass method
# File lib/basepack/forms/import.rb, line 71 def view=(view) super if @edit_form @edit_form.view = view @edit_form.path = path end @show_form.view = view if @show_form @list_form.view = view if @list_form end
with_builder(builder) { |self| ... }
click to toggle source
# File lib/basepack/forms/import.rb, line 62 def with_builder(builder, &block) @builder = builder begin yield(self) ensure @builder = nil end end