Module: RubyUIAdmin::Views::ShowFields
Overview
Renders a show field as a label/value row. Shared by the full Show view and the lazy
tab fragment (ShowTab) so both render fields identically. Expects @record to be set.
Instance Method Summary collapse
- #render_association_row(field) ⇒ Object
-
#render_field(field) ⇒ Object
Called by StructureRenderer for each field.
- #render_field_row(field) ⇒ Object
Instance Method Details
#render_association_row(field) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/components/ruby_ui_admin/views/show_fields.rb', line 26 def render_association_row(field) div(class: "py-3 space-y-2 border-b border-border last:border-b-0") do div do span(class: "text-sm font-medium text-muted-foreground") { field.name } p(class: "text-xs text-muted-foreground") { field.description } if field.description end render RubyUIAdmin::Views::FieldValue.new(field: field, record: @record) end end |
#render_field(field) ⇒ Object
Called by StructureRenderer for each field.
9 10 11 |
# File 'app/components/ruby_ui_admin/views/show_fields.rb', line 9 def render_field(field) render_field_row(field) end |
#render_field_row(field) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/ruby_ui_admin/views/show_fields.rb', line 13 def render_field_row(field) # Collection associations render as a full-width table, so the label goes above it # (a left label column would squeeze the table into a third of the width). return render_association_row(field) if %i[has_many has_and_belongs_to_many].include?(field.type) div(class: "grid grid-cols-3 gap-4 py-3 border-b border-border last:border-b-0") do dt(class: "text-sm font-medium text-muted-foreground", title: field.description) { field.name } dd(class: "text-sm col-span-2") do render RubyUIAdmin::Views::FieldValue.new(field: field, record: @record) end end end |