1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-10 23:50:12 +00:00

Merge branch '211-default-filter_type-set-to-or' into 'develop'

Resolve "Default `filter_type` set to `OR`?"

Closes 

See merge request 
This commit is contained in:
Bram Wiepjes 2020-12-06 09:14:34 +00:00
commit b3190723cf
2 changed files with 17 additions and 0 deletions
changelog.md
web-frontend/modules/database/store/view

View file

@ -1,5 +1,7 @@
# Changelog
* Fixed bug where if you have no filters, but the filter type is set to `OR` it always
results in a not matching row state in the web-frontend.
* Fixed bug where the arrow navigation didn't work for the dropdown component in
combination with a search query.
* Fixed bug where the page refreshes if you press enter in an input in the row modal.

View file

@ -534,20 +534,35 @@ export const actions = {
*/
updateMatchFilters({ commit }, { view, row, overrides = {} }) {
const isValid = (filters, values) => {
// If there aren't any filters then it is not possible to check if the row
// matches any of the filters, so we can mark it as valid.
if (filters.length === 0) {
return true
}
for (const i in filters) {
const filterType = this.$registry.get('viewFilter', filters[i].type)
const filterValue = filters[i].value
const rowValue = values[`field_${filters[i].field}`]
const matches = filterType.matches(rowValue, filterValue)
if (view.filter_type === 'AND' && !matches) {
// With an `AND` filter type, the row must match all the filters, so if
// one of the filters doesn't match we can mark it as isvalid.
return false
} else if (view.filter_type === 'OR' && matches) {
// With an 'OR' filter type, the row only has to match one of the filters,
// that is the case here so we can mark it as valid.
return true
}
}
if (view.filter_type === 'AND') {
// When this point has been reached with an `AND` filter type it means that
// the row matches all the filters and therefore we can mark it as valid.
return true
} else if (view.filter_type === 'OR') {
// When this point has been reached with an `OR` filter type it means that
// the row matches none of the filters and therefore we can mark it as invalid.
return false
}
}