Class: Avo::ManualFrameComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- 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 <title>” button
-
loading: ‘Avo::LoadingComponent` spinner while the request is in flight
-
error: inline message + Retry
Constant Summary
Constants included from Concerns::FindAssociationField
Concerns::FindAssociationField::ASSOCIATIONS
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 <title>”, interpolated so the full phrase is translatable, matching the codebase’s ‘attach_item`/`create_new_item` convention.
-
#retry_label ⇒ Object
The Retry button’s aria-label: “Retry <title>” (the visible copy is just “Retry”; the aria-label scopes it to this frame for screen readers).
Methods inherited from BaseComponent
#component_name, #hotkey_badge
Methods included from ApplicationHelper
#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #manual_frame_cookie_name, #manual_frame_remembered?, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_header_menu_items, #render_license_warning, #root_path_without_url, #rtl?, #safe_blob_path, #safe_blob_representation_url, #safe_blob_url, #text_direction, #ui, #wrap_in_modal
Methods included from SummaryChartHelper
Methods included from ResourcesHelper
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table
Methods included from Concerns::FindAssociationField
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 <title>”, interpolated so the full phrase is translatable, matching the codebase’s ‘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 <title>” (the visible copy is just “Retry”; the aria-label scopes it to this frame for screen readers).
54 55 56 |
# File 'app/components/avo/manual_frame_component.rb', line 54 def retry_label t("avo.retry_item", item: label) end |