Updating filter modal to manage invalid schemas when view created.
This commit is contained in:
parent
0623dc2981
commit
1003c0d55e
|
@ -69,6 +69,7 @@
|
||||||
({ _id }) => _id === $views.selected?.tableId
|
({ _id }) => _id === $views.selected?.tableId
|
||||||
)
|
)
|
||||||
$: fields = viewTable && Object.keys(viewTable.schema)
|
$: fields = viewTable && Object.keys(viewTable.schema)
|
||||||
|
$: schema = viewTable && viewTable.schema ? viewTable.schema : {}
|
||||||
|
|
||||||
function saveView() {
|
function saveView() {
|
||||||
views.save(view)
|
views.save(view)
|
||||||
|
@ -90,29 +91,29 @@
|
||||||
|
|
||||||
function isMultipleChoice(field) {
|
function isMultipleChoice(field) {
|
||||||
return (
|
return (
|
||||||
viewTable.schema[field]?.constraints?.inclusion?.length ||
|
schema[field]?.constraints?.inclusion?.length ||
|
||||||
viewTable.schema[field]?.type === "boolean"
|
schema[field]?.type === "boolean"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function fieldOptions(field) {
|
function fieldOptions(field) {
|
||||||
return viewTable.schema[field]?.type === "options"
|
return schema[field]?.type === "options"
|
||||||
? viewTable.schema[field]?.constraints.inclusion
|
? schema[field]?.constraints.inclusion
|
||||||
: [true, false]
|
: [true, false]
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDate(field) {
|
function isDate(field) {
|
||||||
return viewTable.schema[field]?.type === "datetime"
|
return schema[field]?.type === "datetime"
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNumber(field) {
|
function isNumber(field) {
|
||||||
return viewTable.schema[field]?.type === "number"
|
return schema[field]?.type === "number"
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldChanged = filter => ev => {
|
const fieldChanged = filter => ev => {
|
||||||
// Reset if type changed
|
// Reset if type changed
|
||||||
const oldType = viewTable.schema[filter.key]?.type
|
const oldType = schema[filter.key]?.type
|
||||||
const newType = viewTable.schema[ev.detail]?.type
|
const newType = schema[ev.detail]?.type
|
||||||
if (filter.key && ev.detail && oldType !== newType) {
|
if (filter.key && ev.detail && oldType !== newType) {
|
||||||
filter.value = ""
|
filter.value = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue