Class: Maglev::Uikit::Form::RichtextComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/maglev/uikit/form/richtext_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, name:, options: {}, html_options: {}) ⇒ RichtextComponent

Returns a new instance of RichtextComponent.



9
10
11
12
13
14
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 9

def initialize(label:, name:, options: {}, html_options: {})
  @label = label
  @name = name
  @options = options
  @html_options = html_options || {}
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



7
8
9
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 7

def html_options
  @html_options
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 7

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 7

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 7

def options
  @options
end

Instance Method Details

#build_data_action(actions) ⇒ Object



48
49
50
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 48

def build_data_action(actions)
  [html_options.dig(:data, :action), actions].compact.join(' ')
end

#dom_idObject



16
17
18
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 16

def dom_id
  name.to_s.parameterize.underscore
end


32
33
34
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 32

def edit_link_path
  options[:edit_link_path]
end

#errorObject



44
45
46
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 44

def error
  options[:error]
end

#label_nameObject



40
41
42
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 40

def label_name
  options[:label_name]
end

#line_break?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 28

def line_break?
  options[:line_break] || false
end

#number_of_rowsObject



24
25
26
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 24

def number_of_rows
  options[:rows] || 4
end

#placeholderObject



36
37
38
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 36

def placeholder
  options[:placeholder]
end

#valueObject



20
21
22
# File 'app/components/maglev/uikit/form/richtext_component.rb', line 20

def value
  options[:value]
end