Fix filter assert
This commit is contained in:
parent
efba614765
commit
9ac8d2b0f9
2 changed files with 20 additions and 6 deletions
|
@ -55,22 +55,31 @@ class CardFilter {
|
|||
case "isNotEmpty": {
|
||||
return !!value
|
||||
}
|
||||
}
|
||||
default: {
|
||||
Utils.assertFailure(`Invalid filter condition ${filter.condition}`)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
static propertiesThatMeetFilterGroup(filterGroup: FilterGroup, templates: IPropertyTemplate[]): Record<string, any> {
|
||||
static propertiesThatMeetFilterGroup(filterGroup: FilterGroup, templates: IPropertyTemplate[]): Record<string, string> {
|
||||
// TODO: Handle filter groups
|
||||
const filters = filterGroup.filters.filter(o => !FilterGroup.isAnInstanceOf(o))
|
||||
if (filters.length < 1) { return [] }
|
||||
if (filters.length < 1) { return {} }
|
||||
|
||||
if (filterGroup.operation === "or") {
|
||||
// Just need to meet the first clause
|
||||
const property = this.propertyThatMeetsFilterClause(filters[0] as FilterClause, templates)
|
||||
return [property]
|
||||
const result: Record<string, string> = {}
|
||||
result[property.id] = property.value
|
||||
return result
|
||||
} else {
|
||||
return filters.map(filterClause => this.propertyThatMeetsFilterClause(filterClause as FilterClause, templates))
|
||||
const result: Record<string, string> = {}
|
||||
filters.forEach(filterClause => {
|
||||
const p = this.propertyThatMeetsFilterClause(filterClause as FilterClause, templates)
|
||||
result[p.id] = p.value
|
||||
})
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { Card } from "../card"
|
|||
import { CardFilter } from "../cardFilter"
|
||||
import ViewMenu from "../components/viewMenu"
|
||||
import { Constants } from "../constants"
|
||||
import { randomEmojiList } from "../emojiList"
|
||||
import { Menu as OldMenu } from "../menu"
|
||||
import { Mutator } from "../mutator"
|
||||
import { OctoUtils } from "../octoUtils"
|
||||
|
@ -309,9 +310,11 @@ class BoardComponent extends React.Component<Props, State> {
|
|||
}
|
||||
case "testAdd100Cards": {
|
||||
this.testAddCards(100)
|
||||
break
|
||||
}
|
||||
case "testAdd1000Cards": {
|
||||
this.testAddCards(1000)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +325,7 @@ class BoardComponent extends React.Component<Props, State> {
|
|||
const { mutator, boardTree } = this.props
|
||||
const { board, activeView } = boardTree
|
||||
|
||||
const startCount = boardTree?.cards?.length
|
||||
let optionIndex = 0
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
|
@ -333,7 +337,8 @@ class BoardComponent extends React.Component<Props, State> {
|
|||
const option = boardTree.groupByProperty.options[optionIndex]
|
||||
optionIndex = (optionIndex + 1) % boardTree.groupByProperty.options.length
|
||||
card.properties[boardTree.groupByProperty.id] = option.value
|
||||
card.title = `Test Card ${i + 1}`
|
||||
card.title = `Test Card ${startCount + i + 1}`
|
||||
card.icon = BlockIcons.shared.randomIcon()
|
||||
}
|
||||
await mutator.insertBlock(card, "test add card")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue