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 Attribute Summary collapse
-
#view ⇒ Object
readonly
Returns the value of attribute view.
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.
9 10 11 12 13 14 |
# File 'app/components/avo/views/resource_edit_component.rb', line 9 def initialize(resource: nil, model: nil, actions: [], view: :edit) @resource = resource @model = model @actions = actions @view = view end |
Instance Attribute Details
#view ⇒ Object (readonly)
Returns the value of attribute view.
7 8 9 |
# File 'app/components/avo/views/resource_edit_component.rb', line 7 def view @view end |
Instance Method Details
#back_path ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/avo/views/resource_edit_component.rb', line 20 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.
35 36 37 |
# File 'app/components/avo/views/resource_edit_component.rb', line 35 def @resource.. @view, raise_exception: false end |
#title ⇒ Object
16 17 18 |
# File 'app/components/avo/views/resource_edit_component.rb', line 16 def title @resource.default_panel_name end |