Class: SearchResults::Tables

Inherits:
Components::Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::LinkTo, Phlex::Rails::Helpers::TurboFrameTag
Defined in:
app/components/databasium/search_results/tables.rb

Instance Method Summary collapse

Constructor Details

#initialize(tables:, pagy:) ⇒ Tables

Returns a new instance of Tables.



9
10
11
12
# File 'app/components/databasium/search_results/tables.rb', line 9

def initialize(tables:, pagy:)
  @tables = tables
  @pagy = pagy
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/databasium/search_results/tables.rb', line 14

def view_template
  turbo_frame_tag("results") do
    @tables&.each do |table|
      div(class: "border-b-2 border-b-border py-2 px-3") do
        link_to "#{table}",
                databasium.records_records_path(table: table, refresh: true),
                data: {
                  turbo_frame: "_top",
                  turbo_stream: true
                }
      end
    end
    div(class: "mt-4 flex justify-start") { raw @pagy.series_nav.html_safe } if @pagy
  end
end