Hey there 🙂
Last week, we pushed 3 big changes to WeWeb that all make filters more powerful.
You can now:
You could already add filters to static (great for SEO because the data is pre-rendered and static) and cached collections (perfect to limit the number of calls to a third-party API).
You can now add filters to dynamic collections.
This is ideal if you're working with a fairly small collection of data and want to keep your frontend and backend synced at all times without having to add a "Sync Record" action to your workflows or worrying about refetching your collection's cache.
You could already bind filters to variables, to filter a collection on the email address of the user who's logged in for example:
Now, you can bind filters to formulas.
In the example below, we're saying:
You could already add several condition groups to filters, to build complex and/or filters on top of one another. For example, if user selects marketing and full-time jobs, display x but if user selects marketing and full-time or remote, display y.
Now, you have more flexibility to apply condition groups if they match a certain criteria, for example based on a user role or permission.
In order to do that, all you have to do is click on the "Apply if…" option below your condition group.
Revisiting our example from above, where we were filtering the collection based on the selectedCategory variable, we could say that the filter only applies if the selectedCategory variable is not empty:
This is just one example. The "Add condition group" and "Apply if…" options become really powerful when you're working with user roles and permissions.
Let's say for example that we're a rental car company. When a premium user logs in, we only want to show them luxury cars with a low mileage, but when a regular user or admin logs in, we want to show them all the cars available.
We could add a condition group where:
We would then apply this condition group if the user was identified as a "Premium customer" in Auth0.
This opens endless possibilities and makes it much easier to maintain web apps with complex dynamic filters.
We hope you enjoy these updates and, as always, we're here for you if you need any help with your WeWeb projects 🙂