Sha256: b5d8cf6a813d2d81db383071bd9af23ef58e78cb61d146483caf26e3714b3ff1

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 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
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-2.21.1.pre.pr1476 app/components/avo/fields/edit_component.rb
avo-2.21.1.pre.issue1450 app/components/avo/fields/edit_component.rb
avo-2.21.1.pre.issue1444 app/components/avo/fields/edit_component.rb
avo-2.20.0 app/components/avo/fields/edit_component.rb
avo-2.19.0 app/components/avo/fields/edit_component.rb
avo-2.18.1 app/components/avo/fields/edit_component.rb
avo-2.18.1.pre.1.eagerloaddirs app/components/avo/fields/edit_component.rb
avo-2.18.0 app/components/avo/fields/edit_component.rb
avo-2.17.1.pre.5.stackedlayout app/components/avo/fields/edit_component.rb