Class: Records::ForeignRecords

Inherits:
Components::Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::TurboFrameTag
Defined in:
app/components/databasium/records/foreign_records.rb

Instance Method Summary collapse

Constructor Details

#initialize(model:, columns_names_types:, frame_id: nil) ⇒ ForeignRecords

Returns a new instance of ForeignRecords.



8
9
10
11
12
13
# File 'app/components/databasium/records/foreign_records.rb', line 8

def initialize(model:, columns_names_types:, frame_id: nil)
  @model = model
  @columns_names_types = columns_names_types
  @frame_id = frame_id || "foreign_records_#{@model&.name}"
  @table_id = @frame_id.sub(/\Aforeign_records_/, "foreign_records_table_")
end

Instance Method Details

#view_templateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/databasium/records/foreign_records.rb', line 15

def view_template
  turbo_frame_tag(@frame_id) do
    div(
      class: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/40 p-4",
      data: {
        table_select_target: "table"
      }
    ) do
      div(
        class:
          "relative bg-panel p-4 rounded-xl border-1 border-border w-fit max-w-[50vw] flex flex-col h-[90dvh] overflow-auto shadow-2xl",
        id: @frame_id,
        data: {
          action: "click->table-select#stopPropagation"
        }
      ) do
        render_title
        render_selected_record
        render_filters
        render_table
      end
    end
  end
end