Class: Avo::Views::ResourceEditComponent

Inherits:
ResourceComponent
  • Object
show all
Includes:
ApplicationHelper, ResourcesHelper
Defined in:
app/components/avo/views/resource_edit_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) ⇒ ResourceEditComponent

Returns a new instance of ResourceEditComponent.



7
8
9
# File 'app/components/avo/views/resource_edit_component.rb', line 7

def initialize(resource: nil)
  @resource = resource
end

Instance Method Details

#back_pathObject



11
12
13
14
15
16
17
# File 'app/components/avo/views/resource_edit_component.rb', line 11

def back_path
  if via_resource?
    helpers.resource_path(model: params[:via_resource_class].safe_constantize, resource: relation_resource, resource_id: params[:via_resource_id])
  else
    helpers.resource_path(model: @resource.model, 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.

Returns:

  • (Boolean)


21
22
23
# File 'app/components/avo/views/resource_edit_component.rb', line 21

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