Sha256: a658a3468fc01b4593f042062048ed42b4953ab4df185e431eeb5077c567f268

Contents?: true

Size: 1.26 KB

Versions: 24

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Orderable
      class FormComponent < ViewComponent::Base # :nodoc:
        include Katalyst::Tables::Identifiable::Defaults

        attr_reader :id, :url

        # @param collection [Katalyst::Tables::Collection::Core] the collection to render
        # @param url [String] the url to submit the form to (e.g. <resources>_order_path)
        # @param id [String] the id of the form element (defaults to <resources>_order_form)
        # @param scope [String] the base scope to use for form inputs (defaults to order[<resources>])
        def initialize(collection:, url:, id: nil, scope: nil)
          super

          @id    = id || Orderable.default_form_id(collection)
          @url   = url
          @scope = scope || Orderable.default_scope(collection)
        end

        def call
          form_with(id:, url:, method: :patch, data: {
                      controller:                       FORM_CONTROLLER,
                      "#{FORM_CONTROLLER}-scope-value": @scope,
                    }) do |form|
            form.button(hidden: "")
          end
        end

        def inspect
          "#<#{self.class.name} id: #{id.inspect}, url: #{url.inspect}>"
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
katalyst-tables-3.7.0 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.6.2 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.6.1 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.6.0 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.5 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.4 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.3 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.2 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.1 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.5.0 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.6 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.5 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.4 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.3 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.2 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.1 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.4.0 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.3.4 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.3.3 app/components/katalyst/tables/orderable/form_component.rb
katalyst-tables-3.3.2 app/components/katalyst/tables/orderable/form_component.rb