mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-27 08:31:20 +02:00
Case-insensitive filter for text (#4153)
* Case-sensetive filter for text * Nit * Resolved merge conflict * Update: added check if the value is present
This commit is contained in:
parent
51a9ca83de
commit
18d3978b82
@ -335,6 +335,19 @@ describe('src/cardFilter', () => {
|
||||
expect(result[0]).toEqual(card1)
|
||||
})
|
||||
})
|
||||
describe('verfiy applyFilterGroup method for case-sensitive search', () => {
|
||||
test('should return array with card1 when search by test as Card1', () => {
|
||||
const filterClauseNotContains = createFilterClause({propertyId: 'title', condition: 'contains', values: ['Card1']})
|
||||
const filterGroup = createFilterGroup({
|
||||
operation: 'and',
|
||||
filters: [
|
||||
filterClauseNotContains,
|
||||
],
|
||||
})
|
||||
const result = CardFilter.applyFilterGroup(filterGroup, [], [card1])
|
||||
expect(result.length).toEqual(1)
|
||||
})
|
||||
})
|
||||
describe('verify applyFilter for title', () => {
|
||||
test('should not return array with card1', () => {
|
||||
const filterClauseNotContains = createFilterClause({propertyId: 'title', condition: 'notContains', values: ['card1']})
|
||||
|
@ -46,7 +46,7 @@ class CardFilter {
|
||||
static isClauseMet(filter: FilterClause, templates: readonly IPropertyTemplate[], card: Card): boolean {
|
||||
let value = card.fields.properties[filter.propertyId]
|
||||
if (filter.propertyId === 'title') {
|
||||
value = card.title
|
||||
value = card.title.toLowerCase()
|
||||
}
|
||||
switch (filter.condition) {
|
||||
case 'includes': {
|
||||
@ -77,43 +77,43 @@ class CardFilter {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return filter.values[0] === value
|
||||
return filter.values[0]?.toLowerCase() === value
|
||||
}
|
||||
case 'contains': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return (value as string || '').includes(filter.values[0])
|
||||
return (value as string || '').includes(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'notContains': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return !(value as string || '').includes(filter.values[0])
|
||||
return !(value as string || '').includes(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'startsWith': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return (value as string || '').startsWith(filter.values[0])
|
||||
return (value as string || '').startsWith(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'notStartsWith': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return !(value as string || '').startsWith(filter.values[0])
|
||||
return !(value as string || '').startsWith(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'endsWith': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return (value as string || '').endsWith(filter.values[0])
|
||||
return (value as string || '').endsWith(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'notEndsWith': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
return !(value as string || '').endsWith(filter.values[0])
|
||||
return !(value as string || '').endsWith(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
default: {
|
||||
Utils.assertFailure(`Invalid filter condition ${filter.condition}`)
|
||||
|
Loading…
Reference in New Issue
Block a user