Skip to content

Commit

Permalink
complete via args
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Jul 16, 2024
1 parent 7772685 commit a9cce7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 10 additions & 4 deletions app/components/avo/views/resource_edit_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,23 @@ def form_method
end

def form_url
via_args = {
via_relation_class: params[:via_relation_class],
via_relation: params[:via_relation],
via_record_id: params[:via_record_id],
related_name: params[:related_name]
}.compact

if is_edit?
helpers.resource_path(
record: @resource.record,
resource: @resource
resource: @resource,
**via_args
)
else
helpers.resources_path(
resource: @resource,
via_relation_class: params[:via_relation_class],
via_relation: params[:via_relation],
via_record_id: params[:via_record_id]
**via_args
)
end
end
Expand Down
5 changes: 3 additions & 2 deletions app/components/avo/views/resource_show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def edit_path
{
via_resource_class: params[:via_resource_class],
via_record_id: params[:via_record_id],
via_relation: params[:via_relation]
via_relation: params[:via_relation],
related_name: params[:related_name]
}
elsif @parent_resource.present?
{
Expand All @@ -50,7 +51,7 @@ def edit_path
{}
end

helpers.edit_resource_path(record: @resource.record, resource: @resource, **args)
helpers.edit_resource_path(record: @resource.record, resource: @resource, **args.compact)
end

def controls
Expand Down

0 comments on commit a9cce7e

Please sign in to comment.