Class: Avo::Views::ResourceNewComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ApplicationHelper, ResourcesHelper
Defined in:
app/components/avo/views/resource_new_component.rb

Instance Method Summary collapse

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_pathObject



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.

Returns:

  • (Boolean)


25
26
27
# File 'app/components/avo/views/resource_new_component.rb', line 25

def can_see_the_save_button?
  @resource.authorization.authorize_action :new, raise_exception: false
end