Class: RubyUIAdmin::Views::ShowTab

Inherits:
Phlex::HTML
  • Object
show all
Includes:
UI, PathHelpers, RailsHelpers, ShowFields, StructureRenderer, Translation
Defined in:
app/components/ruby_ui_admin/views/show_tab.rb

Overview

Renders a single show tab's content as a standalone fragment (no page chrome), fetched lazily by the JS when the tab is first opened. tab_index is the tab's flat position across all tab groups on the show view — the same index the full page assigned.

Instance Method Summary collapse

Methods included from ShowFields

#render_association_row, #render_field, #render_field_row

Methods included from StructureRenderer

#render_structure

Methods included from Translation

#rua_t

Methods included from PathHelpers

#attachment_url, #resource_edit_path, #resource_index_path, #resource_new_path, #resource_show_path

Constructor Details

#initialize(resource:, record:, tab_index:) ⇒ ShowTab

Returns a new instance of ShowTab.



16
17
18
19
20
# File 'app/components/ruby_ui_admin/views/show_tab.rb', line 16

def initialize(resource:, record:, tab_index:)
  @resource = resource
  @record = record
  @tab_index = tab_index
end

Instance Method Details

#view_templateObject



22
23
24
25
26
27
28
29
30
31
32
# File 'app/components/ruby_ui_admin/views/show_tab.rb', line 22

def view_template
  tab = flat_tabs[@tab_index]
  return if tab.nil?

  # Wrapped in the matching `<turbo-frame>` so the lazy frame on the show page swaps this in.
  # `target="_top"` so links/forms inside the tab break out of the frame (else Turbo renders
  # "Content missing" navigating within the frame to a page that has no matching frame).
  tag(:turbo_frame, id: "rua-tab-frame-#{@tab_index}", target: "_top") do
    render_tab_content(tab)
  end
end