1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Update naming conventions in filter drawer

This commit is contained in:
Andrew Kingston 2022-09-28 15:36:35 +01:00
parent bcecc45f75
commit 05b707da64

View file

@ -68,7 +68,7 @@
return schemaFields.find(field => field.name === filter.field) return schemaFields.find(field => field.name === filter.field)
} }
const validateTypes = filter => { const santizeTypes = filter => {
// Update type based on field // Update type based on field
const fieldSchema = enrichedSchemaFields.find(x => x.name === filter.field) const fieldSchema = enrichedSchemaFields.find(x => x.name === filter.field)
filter.type = fieldSchema?.type filter.type = fieldSchema?.type
@ -77,7 +77,7 @@
filter.externalType = getSchema(filter)?.externalType filter.externalType = getSchema(filter)?.externalType
} }
const validateOperator = filter => { const santizeOperator = filter => {
// Ensure a valid operator is selected // Ensure a valid operator is selected
const operators = getValidOperatorsForType(filter.type).map(x => x.value) const operators = getValidOperatorsForType(filter.type).map(x => x.value)
if (!operators.includes(filter.operator)) { if (!operators.includes(filter.operator)) {
@ -92,7 +92,7 @@
filter.noValue = noValueOptions.includes(filter.operator) filter.noValue = noValueOptions.includes(filter.operator)
} }
const validateValue = filter => { const santizeValue = filter => {
// Check if the operator allows a value at all // Check if the operator allows a value at all
if (filter.noValue) { if (filter.noValue) {
filter.value = null filter.value = null
@ -110,18 +110,18 @@
} }
const onFieldChange = filter => { const onFieldChange = filter => {
validateTypes(filter) santizeTypes(filter)
validateOperator(filter) santizeOperator(filter)
validateValue(filter) santizeValue(filter)
} }
const onOperatorChange = filter => { const onOperatorChange = filter => {
validateOperator(filter) santizeOperator(filter)
validateValue(filter) santizeValue(filter)
} }
const onValueTypeChange = filter => { const onValueTypeChange = filter => {
validateValue(filter) santizeValue(filter)
} }
const getFieldOptions = field => { const getFieldOptions = field => {