1
0
Fork 0
mirror of synced 2024-06-14 00:14:39 +12:00

Fix view filters not accounting for invalid column names

This commit is contained in:
Andrew Kingston 2021-10-20 14:51:44 +01:00
parent 66553f335c
commit c9abb0148e

View file

@ -82,34 +82,30 @@
function isMultipleChoice(field) {
return (
(viewTable.schema[field].constraints &&
viewTable.schema[field].constraints.inclusion &&
viewTable.schema[field].constraints.inclusion.length) ||
viewTable.schema[field].type === "boolean"
viewTable.schema[field]?.constraints?.inclusion?.length ||
viewTable.schema[field]?.type === "boolean"
)
}
function fieldOptions(field) {
return viewTable.schema[field].type === "options"
? viewTable.schema[field].constraints.inclusion
return viewTable.schema[field]?.type === "options"
? viewTable.schema[field]?.constraints.inclusion
: [true, false]
}
function isDate(field) {
return viewTable.schema[field].type === "datetime"
return viewTable.schema[field]?.type === "datetime"
}
function isNumber(field) {
return viewTable.schema[field].type === "number"
return viewTable.schema[field]?.type === "number"
}
const fieldChanged = filter => ev => {
// reset if type changed
if (
filter.key &&
ev.detail &&
viewTable.schema[filter.key].type !== viewTable.schema[ev.detail].type
) {
// Reset if type changed
const oldType = viewTable.schema[filter.key]?.type
const newType = viewTable.schema[ev.detail]?.type
if (filter.key && ev.detail && oldType !== newType) {
filter.value = ""
}
}