focalboard/webapp/src/filterClause.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-10-20 12:50:53 -07:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
2020-10-20 12:52:56 -07:00
import {Utils} from './utils'
2020-10-08 09:21:27 -07:00
2020-10-20 12:50:53 -07:00
type FilterCondition = 'includes' | 'notIncludes' | 'isEmpty' | 'isNotEmpty'
2020-10-08 09:21:27 -07:00
class FilterClause {
2020-10-20 12:50:53 -07:00
propertyId: string
condition: FilterCondition
values: string[]
2020-10-08 09:21:27 -07:00
2020-10-20 12:50:53 -07:00
static filterConditionDisplayString(filterCondition: FilterCondition) {
switch (filterCondition) {
case 'includes': return 'includes'
2020-10-20 12:50:53 -07:00
case 'notIncludes': return "doesn't include"
case 'isEmpty': return 'is empty'
2020-10-20 12:52:56 -07:00
case 'isNotEmpty': return 'is not empty'
2020-10-20 12:50:53 -07:00
default: {
Utils.assertFailure()
return '(unknown)'
2020-10-20 12:50:53 -07:00
}
}
}
2020-10-08 09:21:27 -07:00
2020-10-20 12:50:53 -07:00
constructor(o: any = {}) {
2020-10-20 12:52:56 -07:00
this.propertyId = o.propertyId || ''
this.condition = o.condition || 'includes'
2020-10-20 12:50:53 -07:00
this.values = o.values?.slice() || []
}
2020-10-08 09:21:27 -07:00
2020-10-20 12:50:53 -07:00
isEqual(o: FilterClause) {
return (
2020-10-20 12:50:53 -07:00
this.propertyId === o.propertyId &&
this.condition === o.condition &&
Utils.arraysEqual(this.values, o.values)
2020-10-20 12:50:53 -07:00
)
}
2020-10-08 09:21:27 -07:00
}
2020-10-20 12:50:53 -07:00
export {FilterClause, FilterCondition}