Class: SearchResults::Models

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

Instance Method Summary collapse

Constructor Details

#initialize(models:, pagy:) ⇒ Models

Returns a new instance of Models.



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

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

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/databasium/search_results/models.rb', line 14

def view_template
  turbo_frame_tag("results") do
    @models&.each do |model|
      link_to(
        databasium.model_path(model),
        data: {
          turbo_frame: "main"
        },
        class:
          "text-main-text hover:text-hover hover:cursor-pointer flex items-center gap-2 p-1 border-b
            border-border flex items-center justify-between"
      ) do
        p(class: "max-w-fit overflow-x-auto me-2 scrollbar-thin p-1") do
          "#{model.upcase_first}"
        end
      end
    end
    div(class: "mt-4 flex justify-start") { raw @pagy.series_nav.html_safe } if @pagy
  end
end