Sha256: 509009ae3d1a03017f9ae79bfe4ae085835e07b7827263607b505447bc22c69b

Contents?: true

Size: 1.07 KB

Versions: 81

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

class Avo::Fields::EditComponent < ViewComponent::Base
  include Avo::ResourcesHelper

  attr_reader :compact
  attr_reader :field
  attr_reader :form
  attr_reader :index
  attr_reader :multiple
  attr_reader :resource
  attr_reader :stacked
  attr_reader :view

  def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: nil, multiple: false, **kwargs)
    @compact = compact
    @field = field
    @form = form
    @index = index
    @multiple = multiple
    @resource = resource
    @stacked = stacked
    @view = :edit
  end

  def classes(extra_classes = "")
    helpers.input_classes("#{@field.get_html(:classes, view: view, element: :input)} #{extra_classes}", has_error: @field.model_errors.include?(@field.id))
  end

  def render?
    !field.computed
  end

  def field_wrapper_args
    {
      compact: compact,
      field: field,
      form: form,
      index: index,
      resource: resource,
      stacked: stacked,
      view: view
    }
  end

  def disabled?
    field.is_readonly? || field.is_disabled?
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
avo-2.28.0 app/components/avo/fields/edit_component.rb
avo-2.27.2.pre.pr1606 app/components/avo/fields/edit_component.rb
avo-2.27.1 app/components/avo/fields/edit_component.rb
avo-2.27.0 app/components/avo/fields/edit_component.rb
avo-2.26.3.pre.pr1601 app/components/avo/fields/edit_component.rb
avo-2.26.2.pre.pr1579 app/components/avo/fields/edit_component.rb
avo-2.26.1.pr1584.pre.1 app/components/avo/fields/edit_component.rb
avo-2.25.1.pre.1.pr1579 app/components/avo/fields/edit_component.rb
avo-2.26.0 app/components/avo/fields/edit_component.rb
avo-2.25.0 app/components/avo/fields/edit_component.rb
avo-2.24.1 app/components/avo/fields/edit_component.rb
avo-2.24.0 app/components/avo/fields/edit_component.rb
avo-2.23.3.pre.1.pr1529 app/components/avo/fields/edit_component.rb
avo-2.23.2 app/components/avo/fields/edit_component.rb
avo-2.23.1 app/components/avo/fields/edit_component.rb
avo-2.23.0 app/components/avo/fields/edit_component.rb
avo-2.22.0 app/components/avo/fields/edit_component.rb
avo-2.21.3.pre.pr1489 app/components/avo/fields/edit_component.rb
avo-2.21.2.pre.pr1486 app/components/avo/fields/edit_component.rb
avo-2.21.1.pre.pr1484 app/components/avo/fields/edit_component.rb