SQLpage icon indicating copy to clipboard operation
SQLpage copied to clipboard

button should have a confirm property to trigger confirm dialog

Open setop opened this issue 9 months ago • 2 comments

a movie gallery (still)

What is your problem ?

The button component creates a clickable button that triggers an action. This action can be destructive, such as deleting or altering a record.

It would be beneficial to have a confirmation dialog appear when the button is clicked. If the user clicks "Confirm," the action will be performed; otherwise, the confirmation dialog will close, and the user will remain on the current page.

This feature would help prevent accidental deletions.

What are you currently doing ?

Living in fear :)

Describe the solution you'd like

Have additional optional properties for the component:

  • "confirm" a bolean ; enable confirm dialog when set to true ; default to false (for backward compatibility)
  • "confirm_text" a text ; message displayed in the confirmation dialog; defaults to "are you sure you want to proceed ?"
select
   'button' as component
;
select
      '/delete_item.sql?id=' || id as link
    , 'trash' as icon
    , 'danger' as color
    , 'Delete' as title
    , true as confirm
    , 'You are about  to delete item "' || title  || '". please confirm' as confirm_text
;

Image

Describe alternatives you've considered

None

setop avatar Feb 26 '25 20:02 setop

We could do even better than an alert, and use tabler's confirmation modals. I'm all for it ! Are you interested in implementing this, @setop ? Can you open a pull request ?

lovasoa avatar Feb 27 '25 09:02 lovasoa

Are you interested in implementing this, @setop ? Can you open a pull request ?

I think I'll start with #821 which is probably simpler for a start.

setop avatar Feb 27 '25 10:02 setop