Class: Avo::Views::ResourceEditComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceEditComponent
show all
- Includes:
- ApplicationHelper, ResourcesHelper
- Defined in:
- app/components/avo/views/resource_edit_component.rb
Instance Method Summary
collapse
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #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, model: nil, actions: [], view: :edit) ⇒ ResourceEditComponent
Returns a new instance of ResourceEditComponent.
7
8
9
10
11
12
|
# File 'app/components/avo/views/resource_edit_component.rb', line 7
def initialize(resource: nil, model: nil, actions: [], view: :edit)
@resource = resource
@model = model
@actions = actions
@view = view
end
|
Instance Method Details
#back_path ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'app/components/avo/views/resource_edit_component.rb', line 18
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(model: @resource.model, resource: @resource)
end
resources_path
end
|
37
38
39
40
41
|
# File 'app/components/avo/views/resource_edit_component.rb', line 37
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.
45
46
47
|
# File 'app/components/avo/views/resource_edit_component.rb', line 45
def can_see_the_save_button?
@resource.authorization.authorize_action @view, raise_exception: false
end
|
#resource_view_path ⇒ Object
33
34
35
|
# File 'app/components/avo/views/resource_edit_component.rb', line 33
def resource_view_path
helpers.resource_view_path(model: association_resource.model, resource: association_resource)
end
|
#resources_path ⇒ Object
29
30
31
|
# File 'app/components/avo/views/resource_edit_component.rb', line 29
def resources_path
helpers.resources_path(resource: @resource)
end
|
#title ⇒ Object
14
15
16
|
# File 'app/components/avo/views/resource_edit_component.rb', line 14
def title
@resource.default_panel_name
end
|