Module: Plutonium::Definition::DisplayLayout

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/plutonium/definition/display_layout.rb

Overview

Declarative display sectioning — the display_layout counterpart to FormLayout, applied to the show page's field grid instead of the form. Same shape (section/ungrouped, first-section-wins ownership, condition:) and the same resolution semantics, so a section/field author only has to learn the DSL once.

Reuses FormLayout's Section/ResolvedSection structs and its ownership-resolution algorithm (FormLayout.resolve_sections) rather than duplicating them — the algorithm has nothing form-specific about it, only the declaring macro and the render target differ.

Deliberately does NOT support columns:. The display side already has a per-field width pathway — display :x, wrapper: {class: "col-span-2"} — and every section renders into the same responsive grid, so a second, section-level column mechanism would be a redundant way to say the same thing. Grouping is what this DSL is for; widths stay on the field. A columns: option raises rather than being silently dropped.

Examples:

display_layout do
  section :identity, :name, :email, label: "Identification"
  section :address, :street, :city, collapsible: true,
    condition: -> { object.requires_address? }
  ungrouped label: "Other"
end

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Instance Method Details

#defined_display_layoutObject

Instance access — the display render path holds a definition instance (mirrors the defineable_prop convention).



98
99
100
# File 'lib/plutonium/definition/display_layout.rb', line 98

def defined_display_layout
  self.class.defined_display_layout
end

#resolve_display_sections(resource_fields) ⇒ Object

Resolve the policy-filtered field list into ordered ResolvedSections. Returns nil when no layout is declared (caller falls back to one grid).



104
105
106
107
108
109
# File 'lib/plutonium/definition/display_layout.rb', line 104

def resolve_display_sections(resource_fields)
  layout = defined_display_layout
  return nil unless layout

  FormLayout.resolve_sections(layout, resource_fields)
end