Class: Avo::Views::ResourceEditComponent

Inherits:
ResourceComponent
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/components/avo/views/resource_edit_component.rb

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

Instance Method Details

#after_initializeObject



12
13
14
# File 'app/components/avo/views/resource_edit_component.rb', line 12

def after_initialize
  @display_breadcrumbs = @reflection.blank? && display_breadcrumbs
end

#back_pathObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/avo/views/resource_edit_component.rb', line 20

def back_path
  return if via_belongs_to?
  return resource_view_path if via_resource?
  return resources_path if via_index?

  if is_edit? && Avo.configuration.resource_default_view.show? # via resource show or edit page
    return helpers.resource_path(record: @resource.record, resource: @resource, **keep_referrer_params)
  end

  resources_path
end

#can_see_the_destroy_button?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
# File 'app/components/avo/views/resource_edit_component.rb', line 40

def can_see_the_destroy_button?
  return super if is_edit? && Avo.configuration.resource_default_view.edit?

  false
end

#can_see_the_save_button?Boolean

The save button is dependent on the edit? policy method. The update? method should be called only when the user clicks the Save button so the developer gets access to the params from the form.

Returns:

  • (Boolean)


48
49
50
# File 'app/components/avo/views/resource_edit_component.rb', line 48

def can_see_the_save_button?
  @resource.authorization.authorize_action @view, raise_exception: false
end

#controlsObject



52
53
54
# File 'app/components/avo/views/resource_edit_component.rb', line 52

def controls
  @resource.render_edit_controls
end

#resource_view_pathObject



36
37
38
# File 'app/components/avo/views/resource_edit_component.rb', line 36

def resource_view_path
  helpers.resource_view_path(record: association_resource.record, resource: association_resource)
end

#resources_pathObject



32
33
34
# File 'app/components/avo/views/resource_edit_component.rb', line 32

def resources_path
  helpers.resources_path(resource: @resource, **keep_referrer_params)
end

#titleObject



16
17
18
# File 'app/components/avo/views/resource_edit_component.rb', line 16

def title
  @resource.default_panel_name
end

#view_for(field) ⇒ Object

Render :show view for read only trix fields



57
58
59
# File 'app/components/avo/views/resource_edit_component.rb', line 57

def view_for(field)
  (field.is_a?(Avo::Fields::TrixField) && field.is_disabled?) ? :show : @view
end