From 0682c4bd726bcb28092e2335a1eb0701a30664b4 Mon Sep 17 00:00:00 2001 From: Gerard Date: Sun, 7 Jul 2024 16:11:04 +1200 Subject: [PATCH 1/2] added documentation for do_nothing alias --- docs/3.0/actions.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/3.0/actions.md b/docs/3.0/actions.md index a263979b..013ef9fa 100644 --- a/docs/3.0/actions.md +++ b/docs/3.0/actions.md @@ -315,12 +315,14 @@ end ``` ::: -:::option `close_modal` +:::option `close_modal`, `do_nothing` This type of response becomes useful when you are working with a form and need to execute an action without redirecting, ensuring that the form remains filled as it is. -`close_modal` will flash all the messages gathered by [action responses](#action-responses) and will close the modal using turbo streams keeping the page still. +`do_nothing` is an alias for `close_modal`. + +`close_modal` or `do_nothing` will flash all the messages gathered by [action responses](#action-responses) and will close the modal using turbo streams keeping the page still. ```ruby class Avo::Actions::CloseModal < Avo::BaseAction @@ -333,7 +335,7 @@ class Avo::Actions::CloseModal < Avo::BaseAction def handle(**args) # do_something_here succeed "Modal closed!!" - close_modal + close_modal # or do_nothing end end ``` From 80e46ece0166350a4b43df744af0dcf0777eede0 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Mon, 8 Jul 2024 14:09:42 +0300 Subject: [PATCH 2/2] wip --- docs/3.0/actions.md | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/3.0/actions.md b/docs/3.0/actions.md index 013ef9fa..90fcc227 100644 --- a/docs/3.0/actions.md +++ b/docs/3.0/actions.md @@ -315,27 +315,39 @@ end ``` ::: -:::option `close_modal`, `do_nothing` +:::option `close_modal` This type of response becomes useful when you are working with a form and need to execute an action without redirecting, ensuring that the form remains filled as it is. -`do_nothing` is an alias for `close_modal`. +`close_modal` will flash all the messages gathered by [action responses](#action-responses) and will close the modal using turbo streams keeping the page still. -`close_modal` or `do_nothing` will flash all the messages gathered by [action responses](#action-responses) and will close the modal using turbo streams keeping the page still. +```ruby{7} +class Avo::Actions::CloseModal < Avo::BaseAction + self.name = "Close modal" -```ruby + def handle(**args) + # do_something_here + succeed "Modal closed!!" + close_modal + # or + do_nothing + end +end +``` +::: + +:::option `do_nothing` +`do_nothing` is an alias for `close_modal`. + +```ruby{7} class Avo::Actions::CloseModal < Avo::BaseAction self.name = "Close modal" - self.standalone = true - self.visible = -> { - true - } def handle(**args) # do_something_here succeed "Modal closed!!" - close_modal # or do_nothing + do_nothing end end ```