Class: Avo::Views::ResourceEditComponent

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

Instance Method Summary collapse

Methods included from Concerns::FormBuilder

#build_form, #form_url

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, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal

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

Instance Method Details

#back_pathObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/avo/views/resource_edit_component.rb', line 16

def back_path
  # The `return_to` param takes precedence over anything else.
  return params[:return_to] if params[:return_to].present?

  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)


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

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)


46
47
48
# File 'app/components/avo/views/resource_edit_component.rb', line 46

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

#controlsObject



50
51
52
# File 'app/components/avo/views/resource_edit_component.rb', line 50

def controls
  @resource.render_edit_controls
end

#resource_view_pathObject



34
35
36
# File 'app/components/avo/views/resource_edit_component.rb', line 34

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

#resources_pathObject



30
31
32
# File 'app/components/avo/views/resource_edit_component.rb', line 30

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

#titleObject



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

def title
  @resource.default_panel_name
end