Sha256: a41b1de33c7117bb17481b1cd14cae3429b3d685e66a108485781fe54c193799
Contents?: true
Size: 1013 Bytes
Versions: 2
Compression:
Stored size: 1013 Bytes
Contents
# frozen_string_literal: true class Avo::Views::ResourceEditComponent < Avo::ResourceComponent include Avo::ResourcesHelper include Avo::ApplicationHelper def initialize(resource: nil) @resource = resource split_panel_fields end 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]) elsif via_index? helpers.resources_path(resource: @resource) else # via resource show page helpers.resource_path(model: @resource.model, resource: @resource) end end # 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. def can_see_the_save_button? @resource.authorization.authorize_action :edit, raise_exception: false end private def via_index? params[:via_view] == 'index' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
avo-2.7.1.pre.1 | app/components/avo/views/resource_edit_component.rb |
avo-2.7.0 | app/components/avo/views/resource_edit_component.rb |