appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
33.82k stars 3.65k forks source link

[Feature] New Confirmation Action showDialog() #7483

Closed daemons2000 closed 2 years ago

daemons2000 commented 3 years ago

Please implement modal dialog functionality to return a modal result from the dialog to the caller.

Motivation/Use case: For a delete action, we need to display a confirmation popup with extended information (so that e.g. an ordinary JS alert() would not suffice). Once the user confirms his choice, the deletion carries on. Currently, we need to put the action handler into modal's OK button. Not only does this complicate code maintenance, also this makes impossible using the same modal for many other similar actions.

Possible implementations:

  1. Make a call to Dialog1.run() synchronous and return value dependent on a button clicked.
  2. Make Dialog1.run() async but allow to specify a "then" handler and return the code of the button that was clicked.
Nikhil-Nandagopal commented 3 years ago

@daemons2000 you can achieve this by enabling the confirmation option in the settings of the delete action. Modals alerts are not synchronous in JS so I think an async / callback approach makes sense as a new function

daemons2000 commented 3 years ago

Modals alerts are not synchronous in JS

Sorry for the confusion. Here I'm not talking how it's done in JS. I am talking about the fact that you own developer's experience and you might choose to make this experience convenient and let the developer feel as if the call is sync. Behind the scenes it still may use a promise but syntactically and logically the developer would use it as a sync call -- which is more practical in case of confirmation modals.

Anyway, simple callbacks would certainly work here.

I did not notice the confirmation flag you mentioned but I tried it now and I can say that the use cases I am referring to require much more flexible functionality: I need inputs, texts, sometimes tables. By reviewing the contents of these controls, the user would be able to decide if he's going to proceed with the action or cancel.

Nikhil-Nandagopal commented 3 years ago

@daemons2000 if underneath the hood it is asynchronous, there is no way for us to make it synchronous that I know of. Would be happy to hear your ideas if you have any. We use javascript everywhere in appsmith so we follow its paradigms, reap its benefits, and are restricted by its limitations.

Nikhil-Nandagopal commented 2 years ago

Closing this since it doesn't align with the product