Class: Avo::TabSwitcherComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Avo::TabSwitcherComponent
- Includes:
- ApplicationHelper, UrlHelpers
- Defined in:
- app/components/avo/tab_switcher_component.rb
Constant Summary
Constants included from Concerns::FindAssociationField
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary collapse
-
#current_one?(tab) ⇒ Boolean
We’ll mark the tab as selected if it’s the current one.
- #is_edit? ⇒ Boolean
- #is_new? ⇒ Boolean
-
#tab_path(tab) ⇒ Object
TOD: helper to record:.
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
Methods included from ResourcesHelper
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #resource_grid, #resource_show_path, #resource_table
Methods included from UrlHelpers
#edit_resource_path, #new_resource_path, #preview_resource_path, #related_resources_path, #resource_attach_path, #resource_detach_path, #resource_path, #resource_view_path, #resources_path
Methods inherited from BaseComponent
Methods included from Concerns::FindAssociationField
Instance Method Details
#current_one?(tab) ⇒ Boolean
We’ll mark the tab as selected if it’s the current one
36 37 38 |
# File 'app/components/avo/tab_switcher_component.rb', line 36 def current_one?(tab) tab.name == @active_tab_name end |
#is_edit? ⇒ Boolean
27 28 29 |
# File 'app/components/avo/tab_switcher_component.rb', line 27 def is_edit? @view.in?(%w[edit update]) end |
#is_new? ⇒ Boolean
31 32 33 |
# File 'app/components/avo/tab_switcher_component.rb', line 31 def is_new? @view.in?(%w[new create]) end |
#tab_path(tab) ⇒ Object
TOD: helper to record:
17 18 19 20 21 22 23 24 25 |
# File 'app/components/avo/tab_switcher_component.rb', line 17 def tab_path(tab) if is_edit? helpers.edit_resource_path(resource: @resource, record: @resource.record, keep_query_params: true, active_tab_name: tab.name, tab_turbo_frame: @group.turbo_frame_id) elsif is_new? helpers.new_resource_path(resource: @resource, keep_query_params: true, active_tab_name: tab.name, tab_turbo_frame: @group.turbo_frame_id) else helpers.resource_path(resource: @resource, record: @resource.record, keep_query_params: true, active_tab_name: tab.name, tab_turbo_frame: @group.turbo_frame_id) end end |