[Solved] I'm saving dates as 'draft'. When I close popup, they should delete

Hello,

I was testing out my calendar system and noticed an issue. Users can add dates to their calendar, and before they click ‘update’ schedule, the dates are saved as ‘Status = Draft’. When user closes the popup (rather than clicks the update button), the dates with ‘Status = Draft’ are deleted.

The issue is when the user opens the popup again and adds more dates, it doesn’t delete them a second time around, but I can’t work out why.

This is what the popup looks like with dates added. They currently have a Status of Draft.

1 Like

One thing you could try is to also reset the pop-up’s data when you close it.

Thanks, I changed my ‘reset’ to the whole popup and at first I thought it was working, but the issue is still there. It works maybe 60% of the time.

When I close my popup, this is what I run. I’m deleting the list of CalendarSchedulings (with Status = Draft) and resetting my popup.

When I add dates, this is how they appear:

Closing the popup first time works great - the dates are deleted (as they are set as ‘draft’).

When I re-open the popup for the same listing and add dates again, I can then close and re-open the popup and some or all of the dates will still be there (even though I can see that they are deleted from the DB).

I wish there was a better solution to creating a ‘frequency’ calendar system. This has been the trickiest part of my build so far!

Instead of saving ‘draft’ dates as status = draft (into the database), I wonder if there’s any way to save them locally by setting a state (not sure if ‘set state’ can work like that)?

@louisadekoya I THINK I’ve diagnosed this issue, I just can’t figure out how to fix it.

Seems like the issue only occurs when I close a popup before all dates have been added to the repeating group/saved to the DB.

For example, if I’m adding dates from 9th Jan until 23rd Jan, this can take 8 seconds or so to fully add them to my repeating group/DB. If I close the popup after 5 seconds and re-open the popup, the dates will still be there (although they will have been deleted from the DB).

If I do that again, but I wait for all the dates to be added to my repeating group and then I close the popup, all dates are successfully deleted for when I next open the popup.

Not sure what this means in terms of a fix though!

Why delete them ? Just leave them there and start again.

So when you click “Add Dates” generate some sort of unique-id for your schedule and save on the Schedule Group, and then when they “Save” update the status from Draft.

Tie your Repeating Group into the id.

That way if they come back in, you will generate a whole new set.

Storage is cheap, and you can clear up every so often. And it gives you an idea how many people are leaving before they “Save”.

Although I would suggest a more elegant way is not to store each event, but to store the template (period, start, end) and exceptions.

1 Like

@NigelG

I followed Dave Auld’s ‘calendar scheduling’ build to create the calendar system so that seemed the easiest way forward for me.

I’m not sure how to implement your suggestions unfortunately - what action would I run to generate a unique-id?

• Should I set a state and give it a random number string using ‘Calculate Formula’?

• How do I tie my repeating group to the ID?

• Do I still run ‘Create a new calendar scheduling’ and the ‘Trigger’ actions?

Just a bit lost with how to proceed.

Thanks!

Yes, that would be the way (I think).

Generate an ID, then use a custom state on the repeating group to store it. Use this on your creates in the same way.

So first time in you would generate 3h373jfj or whatever, and they get created with that id.

If they close and re-open, you would generate a new id, so they would not get read back.

Will try to put an example up later.

image

image

image

There are probably more elegant ways (doing stuff with creation date would be messy I think) but that looks like it works for now.

1 Like

Thanks for working on this Nigel, much appreciated. Have been super busy so have only just had a chance to take a proper look.

Looks like it’s working except for one thing – in the add/remove dates popup, I need to show all dates with the status = Live for that class listing.

For example,

If the user has classes between 1st and 20th Jan scheduled, they should appear every time I open the popup for that particular listing, which is where I think the ID solution is problematic?

They need to appear because the user can add OR remove existing class dates. If they can’t make a particular class, they will want to remove it from their list of dates, so displaying existing dates (past current date/time) is important.

Currently, the popup is ‘fresh’ every time because it’s a new ID, whereas in reality it should show all existing ‘Live’ dates, but when I close the popup, any ‘draft’ dates (not saved as Status = Live’ should disappear).

Not sure if we can tweak the ID solution in order to accommodate this?

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