Forum Documentation Showcase Pricing Learn more

[HOW-TO] Create a custom Calendar using repeating group


#1

Is Full Calendar not giving you enough? Want to have complete customization over your Calendar?

Look no further! I would like to show you a brand new way to create a calendar in your Bubble App using a repeating group and a bit of Javascript.

EVERYTHING IN THIS REPEATING GROUP IS CUSTOMIZABLE
From the text colors, size font, everything is completely customizable just like any other repeating group.

Live Examples:
Preview
Editor

How to accomplish this:

MAKE SURE YOU ARE RUNNING ON BUBBLE ENGINE V1 OR ABOVE

  1. Create a repeating group with 6 rows and 7 columns, set its Type of Content to “Date”
  2. Create an element state on any element and call it “monthOffset”, set it to a number
    EX: 1f79c63eee15b31c15d12873f1e99b1e
  3. Create 2 buttons/icons that can be used to change month.
  4. Start/Edit the workflow of the two icons to the following:
  • Set State of Element with the monthOffset state, Custom State: monthOffset, Value: Element’s monthOffete (+/- 1 depending whether the button goes forward or backwards)
    EX: 132569654c8090002e7d200fffd23047
  1. Install the “Toolbox” plugin from the Bubble plugin store

  2. Place an Expression onto the page you want the calendar on

  3. Paste this code into the expression:
    function getDaysInMonth(e,t){var a=new Date(t,e,1),D=[],n=new Date(t,e,0).getDate();for(i=a.getDay()-1;i>=0;i–)D.push(new Date(t,e-1,n-i));for(;a.getMonth()===e;)D.push(new Date(a)),a.setDate(a.getDate()+1);var g=new Date(t,e+1,1);for(i=D[D.length-1].getDay();6!=i;i++)D.push(new Date(g)),g.setDate(g.getDate()+1);for(i=D.length;42!=i;i++)D.push(new Date(g)),g.setDate(g.getDate()+1);return D}

    getDaysInMonth([MonthAsNum],[YearAsNum]);

  4. Now you need to edit 1 part of the code. Go to the part where it says “[MonthAsNum]” delete that and replace it with the following Bubble expression:
    Current/date time +(months): *Element*'s monthOffset: extract month - 1
    Then you need to replac “[YearAsNum]” and replace it with the following Bubble Expression:
    Current/date time +(months): *Element*'s monthOffset: extract year

Now set “Result Type” to ‘Date’ and Check the box next to ‘Result is a list’ as below.
Ex: 8f474597c901f8b7ff7ddf14f6d64d30

  1. ALMOST THERE. Now you need to set the Data source of the repeating group to: Expression A’s Value List (Expression name can be whatever you have it set to)

YOU ARE ALL DONE! However, if it didnt turn out the same, or you want to see from a live example. Click here to see an editor of a working version.

Thank you for reading, if you have questions or issues, reply to this topic!

Thank you,
Nic | nic@codurly.com
codurly.com


Full Calendar Alternative
Calendar Plugin
Booking system help
Injecting Google Calendar Data Into Custom Calendar
Islamic calendar
[Free Template] Top Shelf Elements
#2

Amazing work!

Only took a couple of minutes to copy it from the editor and make it mobile responsive in my app, Can post steps if others want


Filtering users list of timecards and showing icon conditionally on calendar day
#3

Very well done. :smiley:

Though I ran into a syntax error when doing a cut/paste. It took me a couple of minutes, but I was able to locate it.

On the second line of the code, it reads: for(i=a.getDay()-1;i>=0;i–)

The issue is that it is an em-dash following the last “i” in the line above. This should be two en-dashes.

for(i=a.getDay()-1;i>=0;i–)


#4

Bummer, i tried to recreate this and nothing is loading in the repeating group and I am getting the following error… anyone have any thoughts?

The plugin Toolbox threw the following error: SyntaxError: Invalid or unexpected token
at eval (eval at _.create_code (https://dhtiece9044ep.cloudfront.net/package/run_debug_js/b50053a25e289472b46a845558628ca9b106ab8ec5ea4a7937d3bd1b1e733626/xfalse/x0:96:27803), :13:32)
at https://dhtiece9044ep.cloudfront.net/package/run_debug_js/b50053a25e289472b46a845558628ca9b106ab8ec5ea4a7937d3bd1b1e733626/xfalse/x0:97:15818
at T (https://dhtiece9044ep.cloudfront.net/package/run_debug_js/b50053a25e289472b46a845558628ca9b106ab8ec5ea4a7937d3bd1b1e733626/xfalse/x0:97:8404)


#5

nevermind i got it working somehow… something must have been wrong in the code i guess

BUT… the month of FEB does not load… it does not work on yours either. I dont know if that has to do with it being the previous month from the current date OR just something else… but yea? Any ideas on why FEB is just being skipped?

Update: Your demo and my reproduction of your demo are actually skipping over multiple months AND freezing on other months. Are you seeing this?


#6

I noticed it is actually skipping because it is looking for April 31st and the skipping is only happening because today is March 31st. Since April 31st does not exist (only 30 days in April), the month will not show.

There is a discussion here and I am sure someone smarter than me will be able to figure it out for our code.


#7

Yep, I noticed it is skipping over months and freezing. This is something that wasnt happening before and must be because it is the 31st.
EDIT:
Nothing is wrong in the custom javascript, it is an error on how my bubble determines the current month to show. The fix seems to be extracting the month before adding the offset. I will update my tutorial soon.


#8

thank you so much for that… and thank you very much for the tutorial btw!!! :grinning:


#9

Your CAL with drag N drop groups… check it out!!!

DOWNLOAD VIDEO


#10

looks awesome!


#11

How did you create that? In Bubble?


#12

This is nice looking calendar but i did run into an issue with this too that I can’t solve. When I click a date I open a pop up window with repeating group for events in it. I just don’t know how i can filter those results by day in that case?


#13

yes i just used Levons (zerocode) tutorial calendar and just added a few more things.


#14

Maybe you should release it as a paid plugin if possible - if not, it will be good to hear more on what you did.


#15

This is likely happening as you are trying to say find events whose date = current cell’s date. This will only work for events that occur at the exact same date AND exact same time of day.

So when you display the Events in the repeating group, you will need to make sure the Event falls within the date range of that specific day

Here is a quick example of when a date is clicked on the repeating group calendar:

Display List of Events in Repeating group

Source: Do a search for events

Constraints
Start date/time > current cell’s date:change hours to 0 change minutes to 0, change seconds to 0
Start date/time < current cell’s date:change hours to 23 change minutes to 59 change seconds to 59


Geoff | Top Shelf Templates
Check out a Best Selling Bubble Template
Check out one of The Most Used Bubble Template (FREE)


#16

Thanks for your tips.
I get a bit confused here. I know I need to pass data from calendar to pop-up but i don’t know how to do this properly.

I think my issue it that my source for repeating group calendar is date and for my repeating group event’s it’s events but I can’t make filtering work based on the parents’ cells data because it’s not the same source.

Preview:

Ps. How do I share link to editor?


#17

Noticed an additional bug.

When back workflow is run from the current month, the calendar does not change. (Ie. if current month is March, and back arrow is clicked, no visible changes to February. But another click advances to January.

When going forward from January, February is completely skipped (no second click needed).


#18

In that Action in your screenshot, For the ‘Element’ field, set it as a the Repeating Group in your popup, this repeating group should have the data type as Event

Then for the the ‘Data to Display’ field put: Do a Search For Event

In this search, use the constraints I mentioned above.

For a link to the editor, you will need to set your application rights to allow people to view it (under the Settings tab), and just copy the link in your browser while you are on the page in the Editor


#19

Awesome news! Bubble has updated their engine to account for the months not having a date. This was the only problem with creating a calendar with native bubble but it appears that is no more.

IF YOU ARE GOING TO USE THIS PLANNER BE SURE YOU ARE ON BUBBLE ENGINE V1+

You can do this by going into your settings>versions

Read more about it here:

Thank you,
Nic


#20

I can’t figure it out but I made this project public. It’s probably easier to help me out. https://bubble.is/page?type=page&name=events_calendar&id=calendar-popup&tab=tabs-2

Ps. I have been checking your CRM template too. It has a lot of functions I’m interested in having.