Using 1 popup for multi data type delete actions

@boston85719

I am working on the solution you have suggested, can you give me some idea of how to make the delete button function properly on the popup called “PU DeleteConfirmation”

I added custom states to the Popup element (there are 10 in total) as Yes/No and default=no

When the initial delete icon is clicked on the page that then sets the state to be YES, Show PU DeleteConfirmation, Go to page admin_create and I send the parameter del= parent groups things unique id

How can I change the function of the Delete button in the PU DeleteConfirmation to delete the thing who’s unique id is in the parameter “del” ? I was thinking of using an “Only when” but I’m not sure what expression to create

Or do I create 10 different “Delete thing…” actions and set them with only when conditions that mean that action will only be completed when whatever unique id is in del is contained in the data type to delete?

Maybe I’m overcomplicating this?

Thanks in advance

Not sure if this was really mentionned, but using one reusable element with 3 text states (ID, DB and if you want, Title to show something like Are you sure you want to delete “this thing title”?)

And using API Connector + Data API “DELETE” request with url like
https://myapp.bubbleapps.io/api/1.1/obj/[DB]/[ID]

So you set states > show reusable element (popup)
If user select yes > API connector DELETE action > hide popup

However, it must cost more WU using this option.

I think you’ve gotten confused from the different suggested approaches.

You need a custom state for each type of data you want to be able to delete. So for example, if I have a data type called ‘Product’ and another called ‘Order’ and I want the user to be able to delete either a product or an order from the same reusable. You need a custom state of type Product and a custom state of type Order, not custom states that are yes/no values.

When you run an action to show the popup, you will also run the action to set the state of the data type you want to delete.

Then on button click of delete button you have an action to delete a thing, one for each of the data types you want to delete. Each action has a condition for only when the custom state of the related data type is not empty.

Then you also need to use the workflow trigger when a popup is closed to set the custom state values to empty, so that every time the popup closes the custom state is removed.

So, if you have 8 data types that can be deleted, there are 8 custom states, one trigger from button click, with 8 actions to delete a thing.

Super simple to add a new data type to be deleted, just add another custom state, add another delete action. Plus you will only be charged WUs for the delete thing action.

It is a very modular approach as well since on a page like a dashboard where there may be multiple data types that can be deleted from the single page, you only need one instance of the reusable popup, which makes things much easier to maintain and debug.

Then for your text that might display something like ‘are you sure you want to delete Product ABC’ you will have a condition for each data type with the appropriate message, and use the related custom state to display details of the data type like ‘title’.

1 Like

Thanks for the clarification, I see now.

I was thinking that each state to delete each data type would be a yes/no.
So I’ve set them to be the data type of the category to be deleted.

What I did here is because the thing the use is deleting sometimes comes from a RG (I think) I need to send the unique Id as a reference point.
So I set the state to Eg del_guide to be the “parent groups guide”


, step 2 show PU deleteConfirmation, Step 3 got to page create_admin (which is always the same page) and I send parameter del= parent groups unique id

Then on click of the button delete in the popup I can delete the data type I want to delete

I am sending the url parameters with the thought that I can reference those to dynamically and conditionally change the alert messages after a thing has been deleted… But that doesn’t seem to be functioning as I thought it would (The dynamic text to change the alert message doesn’t display at the moment… *This could have something to do with the thing being deleted… and the URL no longer holding the Unique id…

, However it is SORT OF working for changing the text dynamically in the PU DeleteConfirmation… the only conditional that works is the last one in the list of conditionals… I’ll explore it more later today.

Its a work in progress, some bugs to iron out and I think some expressions to finetune but I’m getting closer. The overall action works and I can delete multiple data types from one Pop Up group using a single delete button.

Not necessary and I would remove this step

Because the thing was deleted.

I would change the conditional to reference the custom state and no the URL parameter

Also, when using URL parameters and pushing a unique ID into the value, you can on the get data from URL select the type of data it is and no need to do any contains id as Bubble will already know what entry it is…but again, in this case, remove the condition you have and reference the custom state value, also in the text remove the dynamic expression for search and reference the custom state value.

I wouldn’t bother, and I’d just write successfully deleted and be done with it.

As a side note

If there is a desire to have just a single warning popup used throughout the entire app, to build in a modular approach, you can put the warning popup into a reusable header if the header is used everywhere in the app. In order to do so, you can create custom triggers to set the custom states on the warning popup to populate which data entry is to be deleted, but these custom triggers are on the reusable header with the popup already in place. When creating the custom triggers you can use the parameters on the custom trigger, to match the custom states on the reusable popup (ie: if 10 custom states on popup, then 10 parameters on the custom trigger).

When you set up like this, then on any page anywhere in the app where the reusable header is, you can trigger a custom event from a reusable, which would be to trigger the custom event on the reusable header, send the appropriate parameters, which then has the custom state set onto the warning popup.

Please note, this is an advanced use case.

Additionally, this can be done for an error alert. In a reusable header create a trigger for when an unhandled error occurs to show a popup that displays the message. This will allow you to have a single trigger in the entire app to display just one popup in the entire app to display an error message to a user for anything that happens in the app that gets caught by the unhandled error trigger event.

1 Like

No worries I’ll remove this

I thought it was because the thing had been deleted and I was leaning to “this probably is the wrong set up”

Ok so I have really “doubled up” and made more work by add URL parameters as well as more complicated, Everything should only reference the relevant custom state…

Sounds like a much more straight forward and simple approach haha

But ooooo this is getting juicy though… I like the idea of being able to do this all from one RE and this is what I was tryin to get to with the Alert message. Although everything I’m working on deleting at the moment is on a single page, there are more pages in the app that could also benefit from this kind of functionality… BUT I’ll come back to this once I have the time to “play” with it and work around it. Its fantastic to know this can be done and how.

1 Like

SUCCESS!!!
@boston85719 I followed your suggested solution and It works well, Link for easy finding for others are in this post below. (there are other great responces that are also worth reading and knowing for anyone else that finds this post later)

LINKS
Using 1 popup for multi data type delete actions - #2 by boston85719
Using 1 popup for multi data type delete actions - #23 by boston85719

Took me some time to wrap my head completely around it all but in the end I think its running smoothly. I will delve into the RE option you suggested in the later posts at a later date… I have to iron my brain out now hahahah

Thanks again for all your help to all of you

This topic was automatically closed after 70 days. New replies are no longer allowed.