Confirmation modal on queries to be conditional

A simple "only run when" or "don't run if" would be ideal.
Use case for this is running a query only if there's no unsaved changes and popping up the warning/confirmation beforehand if there is.

1 Like

Sounds like what you want is a conditional on running the query at all.

Run if true = {{myFormIsDirty.value}} // true

If the form is dirty, the confirmation asks if you want to save changes. Query runs if user says yes.

Run if true = {{myFormIsDirty.value}} // false

The form is not dirty the query is not even run so the confirmation never needs to be displayed in the first place.

I could get behind this. I usually enable/disable the Save button based on form state, but I could see cases where this might be a better solution.

Yea, this is what the confirmation does for me, it's the easiest way to have a "click to confirm action" if they're likely to lose changes etc.
I had an idea of making a modal module (say saying that 10 times fast) for the popup but it was just replicating the confirmation dialog and I'd rather use the built-in components where I can.

At the moment I have 2 handlers on the action button, 1 if it's clean and 1 if it's dirty. Then 2 queries, 1 with confirm and 1 without. Clunky...

1 Like

Indeed, I have the exact same need!

I need to display a confirmation dialog if one input is missing an optional value (as it is needed most times, but not all)

Now I've solved it with a script, triggering one of two queries, that are exactly the same, minus the confirmation.

1 Like

Came across the need for this today whilst trying to implement a cascading delete.

I have a query deleteGrandparent which on success, I was having call deleteParent and then in turn it would call deleteChild.

Everything seems to be working properly, the only slight irritation is that because I am unable to conditionally decide whether or not to show the confirmation, I get confirmations at every level when what I would actually like to do is disable the notifications if triggered from the level above.

I have a possible workaround for you.

Make a js query for each of your delete scenarios and call them rather than the SQL delete queries directly. Add your confirmation on the js query instead of each SQL delete query

// jsDeleteChild
await qryDeleteChild.trigger()
// jsDeleteParent
await qryDeleteChild.trigger()
await qryDeleteParent.trigger()
// jsDeleteGrandParent
await qryDeleteChild.trigger()
await qryDeleteParent.trigger()
await qryDeleteGrandParent.trigger()

I try to avoid chaining onSuccess handlers more than one level as it gets hard to follow real quick. Using js query like this makes it more obvious what the flow is.

1 Like