Avoid filter editor sending a prop change when filter is not an array, which was causing extra 409s and causing issues with tables

This commit is contained in:
Andrew Kingston 2021-07-06 15:22:01 +01:00
parent 1ac29025a2
commit 929d1c73d4
2 changed files with 4 additions and 10 deletions

View File

@ -122,6 +122,9 @@ export const getFrontendStore = () => {
save: async screen => {
const creatingNewScreen = screen._id === undefined
const response = await api.post(`/api/screens`, screen)
if (response.status !== 200) {
return
}
screen = await response.json()
await store.actions.routing.fetch()

View File

@ -21,7 +21,7 @@
export let value = []
export let componentInstance
let drawer
let tempValue = value
let tempValue = value || []
$: numFilters = Array.isArray(tempValue)
? tempValue.length
@ -31,15 +31,6 @@
$: schemaFields = Object.values(schema || {})
$: internalTable = dataSource?.type === "table"
// Reset value if value is wrong type for the datasource.
// Lucene editor needs an array, and simple editor needs an object.
$: {
if (!Array.isArray(value)) {
tempValue = []
dispatch("change", [])
}
}
const saveFilter = async () => {
dispatch("change", tempValue)
notifications.success("Filters saved.")