Sha256: 3f12d453e9f106387516d5a4cdc74bb6c7a54ae68b8a72f97e3388c85c2754cb

Contents?: true

Size: 1.18 KB

Versions: 39

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

class Avo::Fields::EditComponent < Avo::BaseComponent
  include Avo::ResourcesHelper

  attr_reader :compact
  attr_reader :field
  attr_reader :form
  attr_reader :index
  attr_reader :kwargs
  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, autofocus: false, **kwargs)
    @compact = compact
    @field = field
    @form = form
    @index = index
    @kwargs = kwargs
    @multiple = multiple
    @resource = resource
    @stacked = stacked
    @view = Avo::ViewInquirer.new("edit")
    @autofocus = autofocus
  end

  def classes(extra_classes = "")
    helpers.input_classes("#{@field.get_html(:classes, view: view, element: :input)} #{extra_classes}", has_error: @field.record_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

39 entries across 39 versions & 1 rubygems

Version Path
avo-3.15.1 app/components/avo/fields/edit_component.rb
avo-3.15.0 app/components/avo/fields/edit_component.rb
avo-3.14.5 app/components/avo/fields/edit_component.rb
avo-3.14.4 app/components/avo/fields/edit_component.rb
avo-3.14.3 app/components/avo/fields/edit_component.rb
avo-3.14.2 app/components/avo/fields/edit_component.rb
avo-3.14.1 app/components/avo/fields/edit_component.rb
avo-3.14.0 app/components/avo/fields/edit_component.rb
avo-3.13.7 app/components/avo/fields/edit_component.rb
avo-3.13.6 app/components/avo/fields/edit_component.rb
avo-3.13.5 app/components/avo/fields/edit_component.rb
avo-3.13.4 app/components/avo/fields/edit_component.rb
avo-3.13.3 app/components/avo/fields/edit_component.rb
avo-3.13.2 app/components/avo/fields/edit_component.rb
avo-3.13.1 app/components/avo/fields/edit_component.rb
avo-3.13.0 app/components/avo/fields/edit_component.rb
avo-3.12.0 app/components/avo/fields/edit_component.rb
avo-3.11.10 app/components/avo/fields/edit_component.rb
avo-3.11.9 app/components/avo/fields/edit_component.rb
avo-3.11.8 app/components/avo/fields/edit_component.rb