Class: Avo::Views::ResourceEditComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceEditComponent
show all
- Includes:
- ApplicationHelper
- Defined in:
- app/components/avo/views/resource_edit_component.rb
Instance Method Summary
collapse
#a_button, #a_link, #button_classes, #card_classes, #chart_color, #container_classes, #container_is_full_width?, #d, #decode_filter_params, #e, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #pagy_major_version, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
#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
#after_initialize ⇒ Object
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_path ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/components/avo/views/resource_edit_component.rb', line 20
def back_path
return params[:return_to] if params[:return_to].present?
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? return helpers.resource_path(record: @resource.record, resource: @resource, **keep_referrer_params)
end
resources_path
end
|
43
44
45
46
47
|
# File 'app/components/avo/views/resource_edit_component.rb', line 43
def can_see_the_destroy_button?
return super if is_edit? && Avo.configuration.resource_default_view.edit?
false
end
|
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.
51
52
53
|
# File 'app/components/avo/views/resource_edit_component.rb', line 51
def can_see_the_save_button?
@resource.authorization.authorize_action @view, raise_exception: false
end
|
#controls ⇒ Object
55
56
57
|
# File 'app/components/avo/views/resource_edit_component.rb', line 55
def controls
@resource.render_edit_controls
end
|
#resource_view_path ⇒ Object
39
40
41
|
# File 'app/components/avo/views/resource_edit_component.rb', line 39
def resource_view_path
helpers.resource_view_path(record: association_resource.record, resource: association_resource)
end
|
#resources_path ⇒ Object
35
36
37
|
# File 'app/components/avo/views/resource_edit_component.rb', line 35
def resources_path
helpers.resources_path(resource: @resource, **keep_referrer_params)
end
|
#title ⇒ Object
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
60
61
62
|
# File 'app/components/avo/views/resource_edit_component.rb', line 60
def view_for(field)
(field.is_a?(Avo::Fields::TrixField) && field.is_disabled?) ? :show : @view
end
|