Sha256: 738afa3b7ba7cd3f721e12214107cd6ab7e927cc4ee40e7a28d04de4eda52de3

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

module Basepack
  module Forms
    class BulkEdit < Forms::Edit
      attr_accessor :query_form

      def initialize(factory, chain, options = {})
        super(factory, chain, options)
        @query_form = options[:query_form]
      end

      def collection
        @query_form ? @query_form.collection_without_pagination : []
      end

      def path
        @path ||= view.polymorphic_path([:bulk_update, chain].flatten, query_form.params)
      end


      def build_from_factory
        factory.build_form(self)
      end

      def default_partial
        'forms/bulk_edit'
      end

      def render_field!(field)
        if field.bulk_editable? and !field.read_only? and field.view_helper != :hidden_field
          field.required = false
          if field.bulk_edit_partial.present? and view.lookup_context.template_exists?(field.bulk_edit_partial, '', true)
            #rendering input field with bulk_edit extensions
            view.render field.bulk_edit_partial, form: self, field: field
          else
            #rendering common input field
            view.render field.partial, form: self, field: field
          end
        end
      end


    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
basepack-1.0.1 lib/basepack/forms/bulk_edit.rb
basepack-1.0.0 lib/basepack/forms/bulk_edit.rb
basepack-1.0.0.pre.0 lib/basepack/forms/bulk_edit.rb
basepack-0.2.0 lib/basepack/forms/bulk_edit.rb
basepack-0.1.0 lib/basepack/forms/bulk_edit.rb
basepack-0.0.2 lib/basepack/forms/bulk_edit.rb