Sha256: 3afb1868350b18607ce8d1076f382098143e9abb470a675eac45c675e7717015

Contents?: true

Size: 1018 Bytes

Versions: 40

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

class Avo::Fields::TrixField::EditComponent < Avo::Fields::EditComponent
  attr_reader :resource

  def initialize(**args)
    @resource = args[:resource]
    @resource_id = args[:resource_id] || @resource&.record&.to_param
    @resource_name = args[:resource_name] || @resource&.singular_route_key

    super(**args)
  end

  def trix_id
    if @resource_name.present?
      "trix_#{@resource_name}_#{@field.id}"
    elsif form.present?
      "trix_#{form.index}_#{@field.id}"
    end
  end

  def data_values
    {
      resource_name: @resource_name,
      resource_id: @resource_id,
      attachments_disabled: @field.attachments_disabled,
      attachment_key: @field.attachment_key,
      hide_attachment_filename: @field.hide_attachment_filename,
      hide_attachment_filesize: @field.hide_attachment_filesize,
      hide_attachment_url: @field.hide_attachment_url,
      is_action_text: @field.is_action_text?,
    }.transform_keys { |key| "trix_field_#{key}_value" }
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
avo-3.13.7 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.6 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.5 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.4 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.3 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.2 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.1 app/components/avo/fields/trix_field/edit_component.rb
avo-3.13.0 app/components/avo/fields/trix_field/edit_component.rb
avo-3.12.0 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.10 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.9 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.8 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.7 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.6 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.5 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.4 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.3 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.2 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.1 app/components/avo/fields/trix_field/edit_component.rb
avo-3.11.0 app/components/avo/fields/trix_field/edit_component.rb