More powerful filters everywhere!
changelog/20225-complex-flexible-filters
Hey there 🙂
Last week, we pushed 3 big changes to WeWeb that all make filters more powerful.
You can now:
- add filters to dynamic collections 🥳,
- bind formulas to filters, not just variables, and
- add complex condition groups in filters, to display data based on user role for example.
1- Add Filters to Dynamic Collections
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.
2- Add Formulas to Filters
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:
- look at the "Category" field of items in our collection,
- filter all items where the value in the "Category" field matches the value in the select dropdown variable named "selectedCategory"
3- Add Condition Groups to Filters
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.
Different Roles, Different Filters
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:
- car category = Luxury
- car mileage < 1,000
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 🙂
Learn more about WeWeb
- Join our Community
- Watch new tutorials every week
- Get help during Office Hours, every Wednesday at 12pm EST