Great! To start this, I made a few changes to your original set up. Instead of using Shape elements to create the white square titles, I used the Group element to create the same effect. Then I placed the circular Button and Title within that Group.
Then, I created a new Data Type called âProjectâ (shown below):
In your app, you have 6 Project data entries (if you count âOtherâ as the sixth data entry). Here are those in the App Data tab:
I created the Title field for each Projectâs title (âTitleâ, Type: Text, List: No), and the Initial field for the Circular Button Letter (âInitialâ, Type: Text, List: No).
Then I went back to the UI editor and created the repeating group with 3 rows and 2 columns (for the 6 Projects).
In the above screenshot, the white Group element (discussed at the beginning) is repeated within each Cell of the Repeating Group. Repeating Groups have to have a Type of Content, and Groups also need a Type of Content (since youâre usually using Repeating Groups or Groups to display data in an app). In our case, we want the white Group to display the data of the cell that it is in, which is why the data source of the white Group is: Current Cellâs Project.
Within the white group, are our two elements (the circular Button, and the title Text). Our data source for the text and button must begin with âParent Groupâs Projectâ; âCurrent Cellâ is not a dynamic option to select because the button and title are technically housed within the white Group. Regardless, the button and the title are dynamically displaying the Current Cellâs data, itâs just called 'Parent Groupâs data since theyâre in a group. Since the white Groupâs data source is Current Cell, thatâs why the button and the title are displaying the same data they would if they were directly housed within the Current Cell, instead of the Group.
So, then we set the dynamic data of the button to be âParent Groupâs Projectâs Initialâ (shown below):
And then the title Textâs dynamic data is âParent Groupâs Projectâs Titleâ (shown below):
Ok, now weâve got the repeating group set up, and itâs displaying the correct data in preview mode
The next step is to create the functionality where a User can easily click any Project, and âselectâ it, causing the selected Itemâs circular Buttonâs background color to become light blue (or any color).
The first thing weâre going to do is to create a completely transparent Group element, around the size of one cell:
I named this Group element âClickable Group Selectorâ. This makes everything easier on us so that, instead of creating identical workflows on the white Group, the circular button and the title (tedious), we can just create one workflow for this Group and place it over the top over all three of those elements. That way, the User can click anywhere in the cell and select the Project. So I just dragged that Clickable Group Selector into the first cell of the Repeating Group (shown below):
And then set the data source of the Clickable Group Selector to be âCurrent Cellâs Projectâ:
Now we need the workflows and custom states to create the selected, and unselected functionality, since weâre not using checkbox elements itâs a little tricky, but will definitely make more sense after you do this a few more times.
Custom states are great to use because weâre not making any changes to our database using custom states. Our list of Projects that the User selected are stored within the custom state, not our database - which means that weâre not making any changes to the database, and therefore we arenât charged any workflows using custom states. When the page is refreshed, the data within a custom state is cleared. There are a lot of examples in the forum which explain custom states more in detail, but for this example, weâre going to create one custom state on the page âproject_cloneâ (since thatâs the page name). Hereâs how to do this:
The workflow I first set up is: When âClickable Group Selectorâ is clicked â Element Actions â Set State â Element: project_clone, Custom State: create a new custom stateâŚ
Since our repeating groupâs Data Type is Project, we need the data type of this Selected Projects list to be Project. And then we tell Bubble it is a list (by checking the box), since a User can select more than one Project cell at a time. If a User could only select one at a time before proceeding, it would not be a list and we wouldnât check that box. In the workflow, the event will then look like this:
Now we need to set the âvalueâ of the custom state. Right now, we only have a list, and we need to specify when to add a Project to that Selected_Projects list. We want all Projects that are clicked by the User to be added to this Selected_Projects list. So weâre going to say the value of this list is the following:
project_cloneâsSelected_Projects(our list, which is empty on every initial page load):plus itemCurrent Cellâs Project.
So if we were just to leave things as they are:
Then every time a User clicks a Project, it will be added to our Selected_Projects list. Thatâs great and thatâs getting closer to what we need, but we also need to allow a User to deselect that Project (or âremoveâ it from our Selected_Projects list). In our first workflow, we used the â:plusitemâ option, but there isnât a â:minusitemâ or â:removeitemâ option in Bubble. This is where things get a little trickier!
As a workaround, we are going to tell Bubble that when the Clickable Group Selector is clicked AND when project_cloneâsSelected_Projectâs [already] contains Current Cellâs Project (the User is trying to deselect a Project they previously selected), then we need to set the value of the our custom state to be this:
The difference here is that weâre using âfilteredâ as a way to remove an item from our Selected_Projects list. We are âfilteringâ out Projects that are deselected by the User. If you click on filtered youâll see the following:
Here weâre just telling Bubble that if a User clicked an already selected Project, our Project_Clone list must be filtered, in that it canât contain any Projects with the unique ID of the Current Cellâs Project which was just deselected by the User. Itâs a little difficult to explain this, but if you can just remember that this is the only way to tell Bubble to âdeselectâ the Project from our Selected_Projects list, since we donât have a â:minusâ option.
Now we have our two workflows (almost there!):
Our add this Project to our Selected_Projects list, Workflow:
And our remove this Project if it is clicked, and already within our Select_Projects list, Workflow:
So our last step is to create a few more conditions to our workflow when a Project is clicked for the first time, or if itâs been deselected and clicked again. First, we need to specify to Bubble that we only want to add Projects to our Selected Projects list during the following times:
- When that Project isnât already within our Selected_Projects list
- When that Project was selected, deselected, and selected again
So for that second item, we need to tell Bubble to re-add the Project to our Selected_Projects list if the Selected_Projects:filtered list contains them (our âRemovedâ list of Projects contains them).
For example, if a User clicked Windows, itâs added or ':plusâed to Selected_Projects. Then if the User clicks on Windows again (after itâs already in the Selected_Projects list), itâs now within (Selected_Projects:filtered) - meaning the User wants to âdeselect itâ. Then the User changes their mind again, and wants to actually select Windows after all, so Bubble knows to then âmoveâ the Windows Project from Selected_Projects:filtered, back to Selected_Projects.
The complete workflow is set up like this:
âWhenâ:
âActionâ:
To make sure everything is selected/deselected as it should be, I created the repeating group to the side with the following data structure:
The data source is our project_cloneSelected_Projectâs list of Projects. The repeating group is going to display only the Projects the User has selected.
Last but not least, we need to change the color of the Button to notify the User that they have selected a Project. So weâll go to the Conditional Formatting of the circular Button and set up the following statement:
The statement there is pretty straightforward, when project_cloneâsSelected_Projects contains Current Cellâs Project, the background color of this button is a light blue.
Now weâve done the hard part of selecting and deselecting projects using custom states. How do we save that? To do this, I created a new data type called âEstimateâ (though it could be anything you want).
When a User has successfully selected all of the Projects they need, the User clicks next, and this workflow occurs:
Here weâre doing â Data â Create a New Thing â Type: Estimate â Field to change: Projects List add list project_cloneâsSelectedProjects. Of course thereâs more functionality, and data structuring to be done, but this is how you could start to collect the information that a User chooses from that Select a Project screen.
And those are the steps! Iâm sorry I didnât realize there were so many steps, and I hope this isnât too overwhelming. Custom states are very tricky at first, but definitely become easier as time goes on. If any of this was confusing or if I can re-explain anything that didnât make sense, please feel free to let me know.