Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmation message triggers on "cancel" when setNoAjax is true #40

Closed
wernerkrauss opened this issue Nov 13, 2024 · 4 comments
Closed

Comments

@wernerkrauss
Copy link

Hi Lekoala,

thanks for your very useful module.

When I have a custom action with confirmation message, the message is triggerd when I click "cancel" or "ok" on a button that should download something, therefor I added setNoAjax(true):

            $exportAction = CustomLink::create('doExport', 'Export Translations');
            $exportAction->setButtonIcon(SilverStripeIcons::ICON_EXPORT);
            $exportAction->setNoAjax(true);
            $exportAction->setConfirmation(_t(self::class . '.EXPORT_CONFIRMATION', 'Export all {locale} translations?', ['locale' => $this->owner->Locale]));
            $actions->push($exportAction);

Tested in Firefox and Chrome.

PS: it would be a great pleasure to meet you at next www.stripecon.eu, as your work is very important for the European community!

@lekoala
Copy link
Owner

lekoala commented Nov 14, 2024

Hey good catch, never tried that before :-)

easy fix:
https://github.com/lekoala/silverstripe-cms-actions/releases/tag/1.7.4

PS: each year I'm looking at stripecon, but I never manage to decide myself to go to it :-D

@wernerkrauss
Copy link
Author

Thanks for looking into that. Now it triggers the action on load of the ModelAdmin item.

If you want to test it on a demo with Fluent enabled:

See https://github.com/wernerkrauss/silverstripe-fluent-export-import/

Uncomment line https://github.com/wernerkrauss/silverstripe-fluent-export-import/blob/main/src/Extension/LocaleExportImport.php#L36

@wernerkrauss
Copy link
Author

well, of course it hits my export action when I reload that link ;) But still it doesn't seem to work properly :(

@lekoala
Copy link
Owner

lekoala commented Nov 14, 2024

@wernerkrauss yep, i missed a e.preventDefault() to prevent silverstripe from sending the form

https://github.com/lekoala/silverstripe-cms-actions/releases/tag/1.7.5

@lekoala lekoala closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants