Configuring "book a class" visibility conditions

Hi,

I’m fairly new to Glide and I’m having trouble configuring the visibility settings for a “book a class” button for a gym app. When I add the visibility settings the button disappears and I’m pretty sure it’s because I have the data table wrong. Attached are screenshots of the current configurations. I would appreciate the help with this.



1 Like

Can you show us what visibility condition you set up for the button? Is it when “Time Until Class” is > 0?

You can also try “Start Time” is after Now, but I take it you want to calculate and leave a buffer, say bookings can be made until 24 hours before the class starts, for example.

1 Like

Hi @LegacyInspiredFilms and welcome!

Based on your screenshots, I assume you’re trying to display a button only when these two conditions are met:

  1. The Class should start in more than 15 minutes (after that, it’s too late).
  2. At the time you click the button, there is at least one spot available. We can check this by subtracting the number of already booked spots from the Max Capacity column (otherwise, too many people would be in the Class)

To summarize, you have one problem for each point:

  1. Time calculations are (sometimes) a pain in Glide - not because of the tool but because of JavaScript :smiley:
  2. You need to calculate the number of available spots before using it in a Visibility condition

What is really cool is that i’s quite easy to deal with both points so here’s how :backhand_index_pointing_down:


Is there more than 15 minutes before the Class?

  • Instead of using a Math column, I recommend using a Date Difference one. That’s because when you apply the condition, I honestly don’t know how it is regarded: for example, does your condition greater than 15 means 15 hours? 15 days? 15 seconds?
    Even if it’s user-friendly, the format ##:##:## might result in strange behaviour when interpreted by a computer.

    So, the first step is to create this Date Difference (days) column:

    It will provide you with a decimal value representing a day’s duration:

    • 1 means 1 day
    • 0.5 means 12 hours
    • 0.1 means 2 hours and 24 minutes. Wait, what? Yes, there are 1440 minutes in a day so 0.1 is 144 minutes :face_with_raised_eyebrow:

    OK, so what is 15 minutes? Well, bad news, it’s an infinite decimal value because it’s about 0.01041666666… Not ideal in our case.
    But there is an easy solution, don’t worry :smiley:



Now, the visibility condition can easily be applied to that column and will work perfectly :+1:

Just a side note here: in the first column, Date Difference (days), I tried using minutes instead of days and it’s working on my computer.
However, according to Glide official documentation, valid values are days, weeks, months, or years (cf. https://www.glideapps.com/docs/date-difference), so that’s why I prefer to give you this option we an additional Math column.


Is there at least 1 available spot?

You already have a Max Capacity column in your Classes table, which is great. Now you need to also know how many people already enrolled this Class.
This information is probably available in your Bookings table - a very clever way to organize your data, well done!

I guess the structure of this table looks like this:

Class Name User
HIIT Blast alice.dupont@email.com
Power Yoga bob.martin@email.com
Strength 101 charlie.legrand@email.com
HIIT Blast diane.rousseau@email.com
Power Yoga eve.bernard@email.com

  • In your Classes table, create a Relation column (let’s call it Applicants). Relate to items where the value in Class Name matches the value in Bookings > Class Name. Check Match multiple.
    This is going to help us counting the number of appliants, by adding a second column…
  • Create a Rollup column and Summarize the values of Applicants > User by calculating the Count
  • Lastly, create a Math column to compute the difference between Max Capacity and the column created in the last step :wink:

Now, the visibility condition can also easily be applied to that column. If someone saves a spot, the calculation will automaticaly be updated. Everything’s nice and robust.


Hope this is helpful to you and that my assumptions are correct :+1:

1 Like