Class: Practical::Views::Form::PracticalEditorComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/practical/views/form/practical_editor_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_id:, aria_describedby_id:, direct_upload_url:, options: {}) ⇒ PracticalEditorComponent

Returns a new instance of PracticalEditorComponent.



6
7
8
9
10
11
# File 'app/components/practical/views/form/practical_editor_component.rb', line 6

def initialize(input_id:, aria_describedby_id:, direct_upload_url:, options: {})
  self.input_id = input_id
  self.aria_describedby_id = aria_describedby_id
  self.direct_upload_url = direct_upload_url
  self.options = options
end

Instance Attribute Details

#aria_describedby_idObject

Returns the value of attribute aria_describedby_id.



4
5
6
# File 'app/components/practical/views/form/practical_editor_component.rb', line 4

def aria_describedby_id
  @aria_describedby_id
end

#direct_upload_urlObject

Returns the value of attribute direct_upload_url.



4
5
6
# File 'app/components/practical/views/form/practical_editor_component.rb', line 4

def direct_upload_url
  @direct_upload_url
end

#input_idObject

Returns the value of attribute input_id.



4
5
6
# File 'app/components/practical/views/form/practical_editor_component.rb', line 4

def input_id
  @input_id
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'app/components/practical/views/form/practical_editor_component.rb', line 4

def options
  @options
end

Instance Method Details

#callObject



21
22
23
24
25
# File 'app/components/practical/views/form/practical_editor_component.rb', line 21

def call
  tag.practical_editor(**finalized_options) {
    tag.div("slot": :editor, "aria-describedby": aria_describedby_id)
  }
end

#finalized_optionsObject



13
14
15
16
17
18
19
# File 'app/components/practical/views/form/practical_editor_component.rb', line 13

def finalized_options
  mix({
    input: input_id,
    serializer: :json,
    data: {direct_upload_url: direct_upload_url}
  }, options)
end