Class: Avo::Views::ResourceNewComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Avo::Views::ResourceNewComponent
- Includes:
- ApplicationHelper, ResourcesHelper
- Defined in:
- app/components/avo/views/resource_new_component.rb
Instance Method Summary collapse
- #back_path ⇒ Object
-
#can_see_the_save_button? ⇒ Boolean
The create button is dependent on the new? policy method.
-
#initialize(resource: nil, model: nil) ⇒ ResourceNewComponent
constructor
A new instance of ResourceNewComponent.
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #svg, #turbo_frame_wrap
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) ⇒ ResourceNewComponent
Returns a new instance of ResourceNewComponent.
7 8 9 10 11 12 13 |
# File 'app/components/avo/views/resource_new_component.rb', line 7 def initialize( resource: nil, model: nil ) @resource = resource @model = model end |
Instance Method Details
#back_path ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/components/avo/views/resource_new_component.rb', line 15 def back_path if via_resource? helpers.resource_path(model: params[:via_relation_class].safe_constantize, resource: relation_resource, resource_id: params[:via_resource_id]) else helpers.resources_path(resource: @resource) end end |
#can_see_the_save_button? ⇒ Boolean
The create button is dependent on the new? policy method. The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
25 26 27 |
# File 'app/components/avo/views/resource_new_component.rb', line 25 def @resource.. :new, raise_exception: false end |