Class: Jav::Views::ResourceShowComponent

Inherits:
ResourceComponent
  • Object
show all
Includes:
ApplicationHelper, ResourcesHelper
Defined in:
app/components/jav/views/resource_show_component.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg, #white_panel_classes

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table

Constructor Details

#initialize(resource: nil, reflection: nil, parent_resource: nil, parent_model: nil, resource_panel: nil, actions: []) ⇒ ResourceShowComponent

Returns a new instance of ResourceShowComponent.



7
8
9
10
11
12
13
14
15
16
# File 'app/components/jav/views/resource_show_component.rb', line 7

def initialize(resource: nil, reflection: nil, parent_resource: nil, parent_model: nil, resource_panel: nil, actions: [])
  super
  @resource = resource
  @reflection = reflection
  @resource_panel = resource_panel
  @actions = actions
  @parent_model = parent_model
  @parent_resource = parent_resource
  @view = :show
end

Instance Method Details

#back_pathObject



28
29
30
31
32
33
34
35
36
# File 'app/components/jav/views/resource_show_component.rb', line 28

def back_path
  if via_resource?
    return helpers.resource_path(model: association_resource.model_class, resource: association_resource, resource_id: params[:via_resource_id], active_tab_name: params[:active_tab_name]) if params[:active_tab_name].present?

    helpers.resource_path(model: association_resource.model_class, resource: association_resource, resource_id: params[:via_resource_id])
  else
    helpers.resources_path(resource: @resource)
  end
end

#edit_pathObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/components/jav/views/resource_show_component.rb', line 38

def edit_path
  args = {}

  if via_resource?
    args = {
      via_resource_class: params[:via_resource_class],
      via_resource_id: params[:via_resource_id]
    }
    args[:active_tab_name] = params[:active_tab_name] if params[:active_tab_name].present?
  end

  helpers.edit_resource_path(model: @resource.model, resource: @resource, **args)
end

#render_action_control?(action) ⇒ Boolean

Returns:



52
53
54
# File 'app/components/jav/views/resource_show_component.rb', line 52

def render_action_control?(action)
  can_act_on? && action.visible_in_view(parent_resource: @parent_resource)
end

#titleObject



18
19
20
21
22
23
24
25
26
# File 'app/components/jav/views/resource_show_component.rb', line 18

def title
  if @reflection.present?
    return field.name if has_one_field?

    reflection_resource.name
  else
    @resource.default_panel_name
  end
end