Class: Avo::Fields::LexxyField::EditComponent

Inherits:
EditComponent
  • Object
show all
Defined in:
app/components/avo/fields/lexxy_field/edit_component.rb

Instance Method Summary collapse

Instance Method Details

#editor_tagObject



4
5
6
7
8
9
10
11
12
13
# File 'app/components/avo/fields/lexxy_field/edit_component.rb', line 4

def editor_tag
  if helpers.respond_to?(:lexxy_rich_textarea_tag)
    # Rails 8.0/8.1: the lexxy gem prepends its own tag helper.
    helpers.lexxy_rich_textarea_tag field_name, @field.value, editor_options
  else
    # Rails 8.2+: Action Text renders through the editor adapter, which the
    # lexxy gem registers as the default editor.
    helpers.rich_textarea_tag field_name, @field.value, editor_options
  end
end

#media_library?Boolean

A picked blob lands in the content as an attachment, so a field with attachments disabled has nowhere to put it.

Returns:

  • (Boolean)


17
18
19
# File 'app/components/avo/fields/lexxy_field/edit_component.rb', line 17

def media_library?
  !@field.attachments_disabled && Avo::MediaLibrary.configuration.visible?
end

#media_library_pathObject



21
22
23
24
25
26
# File 'app/components/avo/fields/lexxy_field/edit_component.rb', line 21

def media_library_path
  helpers.avo.attach_media_path(
    controller_selector: unique_selector,
    controller_name: "lexxy-field"
  )
end

#unique_idObject



28
29
30
# File 'app/components/avo/fields/lexxy_field/edit_component.rb', line 28

def unique_id
  @unique_id ||= "lexxy_#{@field.id}_#{SecureRandom.hex(4)}"
end

#unique_selectorObject



32
# File 'app/components/avo/fields/lexxy_field/edit_component.rb', line 32

def unique_selector = "[data-unique-selector=#{unique_id}]"