Skip to content

Commit

Permalink
fix(ui): bugs with checkbox filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Jul 22, 2023
1 parent 6bf7437 commit 2ddc1f0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/ui/src/components/TableFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
usesFilterStateOr,
usesFilterStateSingle,
} from '../types'
import { carbonCopyState, whereClausesEqual } from '../utils'
import { whereClausesEqual } from '../utils'
const props = defineProps<{
collection: CollectionInstance<any>
Expand All @@ -29,21 +29,23 @@ onMounted(() => {
}
})
function setCheckbox(whereClause: WhereClause, to: boolean) {
function setCheckbox(whereClause: WhereClause, to: boolean): void {
const { filter, filterState } = props
if (!usesFilterStateOr(filter, filterState)) return undefined
const newState = !filterState
? { or: new Set<WhereClause>() }
: { or: carbonCopyState(filterState.or) }
if (!usesFilterStateOr(filter, filterState)) return
const or = !filterState ? new Set<WhereClause>() : filterState.or
if (!to) {
newState.or.delete(whereClause)
or.delete(whereClause)
} else {
newState.or.add(whereClause)
or.add(whereClause)
}
if (or.size === 0) {
emit('setFilter', null)
} else {
emit('setFilter', { or })
}
return emit('setFilter', newState)
}
function setRadioTo(whereClause: WhereClause | null) {
function setRadioTo(whereClause: WhereClause | null): void {
if (!whereClause) return emit('setFilter', null)
return emit('setFilter', whereClause)
}
Expand Down

0 comments on commit 2ddc1f0

Please sign in to comment.