Class: Avo::TabSwitcherComponent

Inherits:
BaseComponent
  • Object
show all
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

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, #possibly_rails_authentication?, #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

#has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#current_one?(tab) ⇒ Boolean

We’ll mark the tab as selected if it’s the current one

Returns:

  • (Boolean)


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

Returns:

  • (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

Returns:

  • (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