Class: Practical::Views::Navigation::Pagination::GotoFormComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
FormWrapper
Defined in:
app/components/practical/views/navigation/pagination/goto_form_component.rb

Defined Under Namespace

Classes: URIParts

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormWrapper

#wrapped_form_with

Constructor Details

#initialize(pagy:, dialog_id:, page_detail_text:) ⇒ GotoFormComponent

Returns a new instance of GotoFormComponent.



9
10
11
12
13
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 9

def initialize(pagy:, dialog_id:, page_detail_text:)
  self.pagy = pagy
  self.dialog_id = dialog_id
  self.page_detail_text = page_detail_text
end

Instance Attribute Details

#dialog_idObject

Returns the value of attribute dialog_id.



5
6
7
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 5

def dialog_id
  @dialog_id
end

#page_detail_textObject

Returns the value of attribute page_detail_text.



5
6
7
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 5

def page_detail_text
  @page_detail_text
end

#pagyObject

Returns the value of attribute pagy.



5
6
7
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 5

def pagy
  @pagy
end

Instance Method Details

#form_wrapper(&block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 39

def form_wrapper(&block)
  wrapped_form_with(
    url: uri_parts.uri.to_s,
    method: :get,
    local: true,
    builder: ApplicationFormBuilder,
    class: 'pagination-goto-form wa-size-s',
    &block
  )
end

#generic_errors_idObject



35
36
37
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 35

def generic_errors_id
  "#{dialog_id}_pagination"
end

#hidden_field_for_goto_form(key:, value:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 24

def hidden_field_for_goto_form(key:, value:)
  case value
  when Array
    value.each do |x|
      helpers.hidden_field_tag key, x
    end
  else
    helpers.hidden_field_tag key, value
  end
end

#uri_partsObject



15
16
17
18
19
20
21
22
# File 'app/components/practical/views/navigation/pagination/goto_form_component.rb', line 15

def uri_parts
  uri = URI.parse(pagy.page_url)
  params = Rack::Utils.parse_query(uri.query)
  params.delete("page")
  uri.query = ""

  URIParts.new(uri: uri, params: params)
end