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, #decode_filter_params, #empty_state, #encode_filter_params, #get_model_class, #input_classes, #mount_path, #number_to_social, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
#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, record: nil, actions: [], view: "edit") ⇒ ResourceEditComponent
Returns a new instance of ResourceEditComponent.
6
7
8
9
10
11
|
# File 'app/components/avo/views/resource_edit_component.rb', line 6
def initialize(resource: nil, record: nil, actions: [], view: "edit")
@resource = resource
@record = record
@actions = actions
@view = Avo::ViewInquirer.new(view)
end
|
Instance Method Details
#back_path ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/components/avo/views/resource_edit_component.rb', line 17
def back_path
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)
end
resources_path
end
|
36
37
38
39
40
|
# File 'app/components/avo/views/resource_edit_component.rb', line 36
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.
44
45
46
|
# File 'app/components/avo/views/resource_edit_component.rb', line 44
def can_see_the_save_button?
@resource.authorization.authorize_action @view, raise_exception: false
end
|
#resource_view_path ⇒ Object
32
33
34
|
# File 'app/components/avo/views/resource_edit_component.rb', line 32
def resource_view_path
helpers.resource_view_path(record: association_resource.record, resource: association_resource)
end
|
#resources_path ⇒ Object
28
29
30
|
# File 'app/components/avo/views/resource_edit_component.rb', line 28
def resources_path
helpers.resources_path(resource: @resource)
end
|
#title ⇒ Object
13
14
15
|
# File 'app/components/avo/views/resource_edit_component.rb', line 13
def title
@resource.default_panel_name
end
|