Clean multiple user checks to simplify
This commit is contained in:
parent
07dd0bc1ae
commit
02bfaa4378
|
@ -195,20 +195,8 @@
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = filter.type
|
|
||||||
if (type === FieldType.BB_REFERENCE) {
|
|
||||||
const fieldSchema = getSchema(filter)
|
|
||||||
if (fieldSchema) {
|
|
||||||
type = {
|
|
||||||
type: fieldSchema.type,
|
|
||||||
multiple:
|
|
||||||
fieldSchema.relationshipType === RelationshipType.MANY_TO_MANY,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const operators = LuceneUtils.getValidOperatorsForType(
|
const operators = LuceneUtils.getValidOperatorsForType(
|
||||||
type,
|
filter.type,
|
||||||
filter.field,
|
filter.field,
|
||||||
datasource
|
datasource
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,22 +12,12 @@ import { deepGet } from "./helpers"
|
||||||
|
|
||||||
const HBS_REGEX = /{{([^{].*?)}}/g
|
const HBS_REGEX = /{{([^{].*?)}}/g
|
||||||
|
|
||||||
type RequestedFieldType =
|
|
||||||
| Exclude<FieldType, FieldType.BB_REFERENCE>
|
|
||||||
| { type: FieldType.BB_REFERENCE; multiple: boolean }
|
|
||||||
|
|
||||||
export function isFieldType(
|
|
||||||
r: RequestedFieldType
|
|
||||||
): r is Exclude<FieldType, FieldType.BB_REFERENCE> {
|
|
||||||
return typeof r === "string" && Object.values(FieldType).includes(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the valid operator options for a certain data type
|
* Returns the valid operator options for a certain data type
|
||||||
* @param type the data type
|
* @param type the data type
|
||||||
*/
|
*/
|
||||||
export const getValidOperatorsForType = (
|
export const getValidOperatorsForType = (
|
||||||
type: RequestedFieldType,
|
type: FieldType,
|
||||||
field: string,
|
field: string,
|
||||||
datasource: Datasource & { tableId: any } // TODO: is this table id ever populated?
|
datasource: Datasource & { tableId: any } // TODO: is this table id ever populated?
|
||||||
) => {
|
) => {
|
||||||
|
@ -70,13 +60,8 @@ export const getValidOperatorsForType = (
|
||||||
ops = numOps
|
ops = numOps
|
||||||
} else if (type === FieldType.FORMULA) {
|
} else if (type === FieldType.FORMULA) {
|
||||||
ops = stringOps.concat([Op.MoreThan, Op.LessThan])
|
ops = stringOps.concat([Op.MoreThan, Op.LessThan])
|
||||||
} else if (!isFieldType(type) && type.type === FieldType.BB_REFERENCE) {
|
} else if (type === FieldType.BB_REFERENCE) {
|
||||||
if (type.multiple) {
|
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
|
||||||
// Temporally disabled
|
|
||||||
ops = []
|
|
||||||
} else {
|
|
||||||
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only allow equal/not equal for _id in SQL tables
|
// Only allow equal/not equal for _id in SQL tables
|
||||||
|
|
Loading…
Reference in New Issue