Skip to content

Commit

Permalink
fix: redirect on action when no_confirmation = true
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Nov 17, 2023
1 parent d07d77f commit c129b65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/javascript/js/controllers/action_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Controller } from '@hotwired/stimulus'
import { castBoolean } from '../helpers/cast_boolean'

export default class extends Controller {
static targets = ['controllerDiv', 'resourceIds', 'form', 'selectedAllQuery']
static targets = ['controllerDiv', 'resourceIds', 'submit', 'selectedAllQuery']

connect() {
this.resourceIdsTarget.value = this.resourceIds
Expand All @@ -13,7 +13,7 @@ export default class extends Controller {
}

if (this.noConfirmation) {
this.formTarget.submit()
this.submitTarget.click()
} else {
this.controllerDivTarget.classList.remove('hidden')
}
Expand Down
12 changes: 7 additions & 5 deletions lib/avo/base_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ class << self
def form_data_attributes
# We can't respond with a file download from Turbo se we disable it on the form
if may_download_file
{turbo: turbo || false, remote: false, action_target: :form}
{turbo: turbo || false, remote: false}
else
{turbo: turbo, turbo_frame: :_top, action_target: :form}.compact
{turbo: turbo, turbo_frame: :_top}.compact
end
end

# We can't respond with a file download from Turbo se we disable close the modal manually after a while (it's a hack, we know)
def submit_button_data_attributes
attributes = { action_target: "submit" }

if may_download_file
{action: "click->modal#delayedClose"}
else
{}
attributes[:action] = "click->modal#delayedClose"
end

attributes
end
end

Expand Down

0 comments on commit c129b65

Please sign in to comment.