Class: Plutonium::UI::Form::Resource
- Includes:
- Concerns::RendersNestedResourceFields
- Defined in:
- lib/plutonium/ui/form/resource.rb
Direct Known Subclasses
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
-
#resource_definition ⇒ Object
readonly
Returns the value of attribute resource_definition.
-
#resource_fields ⇒ Object
readonly
Returns the value of attribute resource_fields.
-
#singular_resource ⇒ Object
readonly
Returns the value of attribute singular_resource.
Instance Method Summary collapse
- #form_class ⇒ Object
- #form_template ⇒ Object
-
#initialize(resource_fields:, resource_definition:, singular_resource: false) ⇒ Resource
constructor
A new instance of Resource.
-
#view_template(&block) ⇒ Object
Mirrors Phlexi::Form::Base#view_template (phlexi-form ~> 0.14) — keep these in sync if upgrading.
Methods included from Component::Behaviour
Methods included from Component::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(resource_fields:, resource_definition:, singular_resource: false) ⇒ Resource
Returns a new instance of Resource.
13 14 15 16 17 18 |
# File 'lib/plutonium/ui/form/resource.rb', line 13 def initialize(*, resource_fields:, resource_definition:, singular_resource: false, **, &) super(*, **, &) @resource_fields = resource_fields @resource_definition = resource_definition @singular_resource = singular_resource end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Attribute Details
#resource_definition ⇒ Object (readonly)
Returns the value of attribute resource_definition.
9 10 11 |
# File 'lib/plutonium/ui/form/resource.rb', line 9 def resource_definition @resource_definition end |
#resource_fields ⇒ Object (readonly)
Returns the value of attribute resource_fields.
9 10 11 |
# File 'lib/plutonium/ui/form/resource.rb', line 9 def resource_fields @resource_fields end |
#singular_resource ⇒ Object (readonly)
Returns the value of attribute singular_resource.
9 10 11 |
# File 'lib/plutonium/ui/form/resource.rb', line 9 def singular_resource @singular_resource end |
Instance Method Details
#form_class ⇒ Object
50 51 52 |
# File 'lib/plutonium/ui/form/resource.rb', line 50 def form_class in_modal? ? "flex-1 flex flex-col min-h-0" : super end |
#form_template ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/plutonium/ui/form/resource.rb', line 20 def form_template if in_modal? # In modal: form is the flex container that fills the modal # body. Fields region scrolls; action strip sits flush at the # bottom edge of the modal. div(class: "flex-1 min-h-0 overflow-y-auto px-6 py-5") do render_fields end else render_fields end render_actions end |
#view_template(&block) ⇒ Object
Mirrors Phlexi::Form::Base#view_template (phlexi-form ~> 0.14) — keep these in sync if upgrading. We override so the guard dialog renders inside the <form> tag (where the JS controller looks for it via ‘dirty-form-guard-target`) even when a subclass overrides `form_template`. Without this, the controller silently falls back to `window.confirm`.
40 41 42 43 44 45 46 47 48 |
# File 'lib/plutonium/ui/form/resource.rb', line 40 def view_template(&block) captured_body = capture { form_template(&block) } captured_guard = capture { render_dirty_form_guard_dialog if in_modal? } form_tag do form_errors raw(safe(captured_body)) raw(safe(captured_guard)) end end |