Class: Practical::Views::Form::FallbackErrorsSectionComponent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f:, id:, blurb:, options:) ⇒ FallbackErrorsSectionComponent

Returns a new instance of FallbackErrorsSectionComponent.



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

def initialize(f:, id:, blurb:, options:)
  @f = f
  @id = id
  @blurb = blurb
  @options = options
end

Instance Attribute Details

#blurbObject (readonly)

Returns the value of attribute blurb.



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

def blurb
  @blurb
end

#fObject (readonly)

Returns the value of attribute f.



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

def f
  @f
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#finalized_optionsObject



12
13
14
15
16
17
# File 'app/components/practical/views/form/fallback_errors_section_component.rb', line 12

def finalized_options
  mix({
    data: {"pf-error-container": true, "pf-fallback-error-section": true},
    id: id
  }, @options)
end

#remaining_errorsObject



19
20
21
22
# File 'app/components/practical/views/form/fallback_errors_section_component.rb', line 19

def remaining_errors
  return [] if f.object.try(:errors).blank?
  return f.object.errors.reject{|error| error.options[:has_been_rendered] }
end