Class: Plutonium::UI::Form::Wizard

Inherits:
Resource
  • Object
show all
Defined in:
lib/plutonium/ui/form/wizard.rb

Overview

Renders the CURRENT wizard step through the existing resource-form pipeline (§7). It rides Form::Resource unchanged — the only wizard-specific wiring is the per-step adapter (resource_definition), the value source (the wizard's typed data, so inputs render seeded from staged data for resume/back, including repeater rows), the wizard[...] param namespace, the step POST URL, and a hidden _direction (default next).

Constant Summary

Constants included from Concerns::RendersNestedResourceFields

Concerns::RendersNestedResourceFields::DEFAULT_NESTED_LIMIT, Concerns::RendersNestedResourceFields::NESTED_OPTION_KEYS, Concerns::RendersNestedResourceFields::SINGULAR_MACROS

Instance Attribute Summary collapse

Attributes inherited from Resource

#resource_definition, #resource_fields, #singular_resource

Instance Method Summary collapse

Methods inherited from Resource

#view_template

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?

Constructor Details

#initialize(step:, data:, action:, fields:, wizard:, **options) ⇒ Wizard

Returns a new instance of Wizard.

Parameters:

  • step (Plutonium::Wizard::Step)
  • data (Object)

    the wizard's typed data snapshot (the form object; responds to every step attribute / structured input name).

  • action (String)

    the current step's POST URL.

  • fields (Array<Symbol>)

    the step's renderable field names (scalar attributes + structured inputs).

  • wizard (Plutonium::Wizard::Base)

    the run being rendered. Exposed as form.wizard so a step's proc-valued option can reach the run — see #wizard. Required: it is read during render, so defaulting it to nil would only defer the failure to a NoMethodError inside a proc.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/plutonium/ui/form/wizard.rb', line 23

def initialize(step:, data:, action:, fields:, wizard:, **options, &)
  @step = step
  @wizard = wizard
  options[:key] = :wizard
  options[:as] = :wizard
  options[:action] = action
  options[:resource_fields] = fields
  options[:resource_definition] = Plutonium::Wizard::StepAdapter.new(step)
  options[:singular_resource] = true
  super(data, **options, &)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Attribute Details

#wizardPlutonium::Wizard::Base (readonly)

The run being rendered. Public because a step's proc-valued option is how an option depends on the run, and reaching the run is the whole point:

input :tier, as: :select,
choices: ->(form) { form.wizard.anchor.available_tiers }

Deliberately NOT reached by rebinding a zero-arity proc to the wizard. A step block is instance_exec'd against a FieldCapture at class load, so its closure holds nothing useful — but that is equally true of a form_layout block and its Builder, and the answer there is to ask for the receiver rather than have it swapped in silently. Same answer here: -> { … } means what it reads like wherever it is written, and an input line moved between a definition and a step keeps its meaning.

form.object, alongside this, is the step's staged data.



52
53
54
# File 'lib/plutonium/ui/form/wizard.rb', line 52

def wizard
  @wizard
end