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

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

Constant Summary collapse

URIParts =
Data.define(:uri, :params)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#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_url_for(pagy, nil))
  params = Rack::Utils.parse_query(uri.query)
  params.delete("page")
  uri.query = ""

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