Class: Avo::Views::ResourceEditComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceEditComponent
- Includes:
- ApplicationHelper, ResourcesHelper
- Defined in:
- app/components/avo/views/resource_edit_component.rb
Instance Method Summary collapse
- #back_path ⇒ Object
-
#can_see_the_save_button? ⇒ Boolean
The save button is dependent on the edit? policy method.
-
#initialize(resource: nil, model: nil, actions: [], view: :edit) ⇒ ResourceEditComponent
constructor
A new instance of ResourceEditComponent.
- #title ⇒ Object
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg
Methods included from ResourcesHelper
#edit_field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table, #show_field_wrapper
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 28 29 |
# File 'app/components/avo/views/resource_edit_component.rb', line 18 def back_path if via_resource? model = params[:via_resource_class] || params[:via_relation_class] helpers.resource_path(model: model.safe_constantize, resource: relation_resource, resource_id: params[:via_resource_id]) elsif via_index? helpers.resources_path(resource: @resource) elsif is_edit? # via resource show page helpers.resource_path(model: @resource.model, resource: @resource) else helpers.resources_path(resource: @resource) end 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.
33 34 35 |
# File 'app/components/avo/views/resource_edit_component.rb', line 33 def @resource.. @view, raise_exception: false end |
#title ⇒ Object
14 15 16 |
# File 'app/components/avo/views/resource_edit_component.rb', line 14 def title @resource.default_panel_name end |