Class: Avo::Fields::TiptapField::EditComponent

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

Instance Attribute Summary collapse

Attributes inherited from EditComponent

#compact, #field, #form, #index, #kwargs, #multiple, #stacked, #view

Instance Method Summary collapse

Methods inherited from EditComponent

#classes, #disabled?, #field_wrapper_args, #render?

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table

Constructor Details

#initialize(**args) ⇒ EditComponent

Returns a new instance of EditComponent.



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

def initialize(**args)
  @resource = args[:resource]
  @resource_id = args[:resource_id]
  @resource_name = args[:resource_name]

  super(**args)
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'app/components/avo/fields/tiptap_field/edit_component.rb', line 4

def resource
  @resource
end

Instance Method Details

#resource_idObject



18
19
20
# File 'app/components/avo/fields/tiptap_field/edit_component.rb', line 18

def resource_id
  @resource_id || resource&.record&.id
end

#resource_nameObject



14
15
16
# File 'app/components/avo/fields/tiptap_field/edit_component.rb', line 14

def resource_name
  @resource_name || resource&.singular_route_key
end

#tiptap_idObject



22
23
24
25
26
27
28
# File 'app/components/avo/fields/tiptap_field/edit_component.rb', line 22

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