Class: Avo::ManualFrameComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Avo::ManualFrameComponent
- Defined in:
- app/components/avo/manual_frame_component.rb
Overview
Renders a <turbo-frame> with NO src that defers loading until the user
clicks the "Load" button. Used by manual (loading: :manual) tabs and
associations on Show pages.
The frame carries the deferred URL in data-manual-frame-url-value for the
manual-frame Stimulus controller, which sets the frame src on click and
renders an inline error + Retry on failure. It is marked data-manual-frame
as an identifying hook.
States (single component, three states):
- placeholder: title + a "Load
" button - loading:
Avo::LoadingComponentspinner while the request is in flight - error: inline message + Retry
Instance Method Summary collapse
-
#dev_details_note ⇒ Object
In development only, a link straight to the deferred URL so a developer can open the failing frame on its own and read the real error / stack trace (the inline error state otherwise swallows the response).
-
#label ⇒ Object
The display label.
-
#load_label ⇒ Object
"Load
", interpolated so the full phrase is translatable, matching the codebase's attach_item/create_new_itemconvention. -
#retry_label ⇒ Object
The Retry button's aria-label: "Retry
" (the visible copy is just "Retry"; the aria-label scopes it to this frame for screen readers).
Instance Method Details
#dev_details_note ⇒ Object
In development only, a link straight to the deferred URL so a developer can
open the failing frame on its own and read the real error / stack trace
(the inline error state otherwise swallows the response). Mirrors the
dev-only link in avo/home/failed_to_load.html.erb. Returns nil elsewhere.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/components/avo/manual_frame_component.rb', line 62 def dev_details_note return unless Rails.env.development? && @deferred_url.present? helpers.tag.p(class: "manual-frame__error-note") do helpers.safe_join([ "Follow ", helpers.link_to("this link", @deferred_url, target: "_blank", rel: "noopener", class: "manual-frame__error-link"), " for more details about the issue and how to fix it." ]) end end |
#label ⇒ Object
The display label. Callers already hand us presentation-ready, translated
text (field name / tab title), so we use it as-is. Never humanize, which
would mangle custom or translated names ("Order Items" -> "Order items").
42 43 44 |
# File 'app/components/avo/manual_frame_component.rb', line 42 def label @title.to_s end |
#load_label ⇒ Object
"Load
attach_item/create_new_item convention.
48 49 50 |
# File 'app/components/avo/manual_frame_component.rb', line 48 def load_label t("avo.load_item", item: label) end |
#retry_label ⇒ Object
The Retry button's aria-label: "Retry
54 55 56 |
# File 'app/components/avo/manual_frame_component.rb', line 54 def retry_label t("avo.retry_item", item: label) end |