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 4bc1938966
commit c4b7428aed
2 changed files with 4 additions and 10 deletions

View File

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

View File

@ -21,7 +21,7 @@
export let value = [] export let value = []
export let componentInstance export let componentInstance
let drawer let drawer
let tempValue = value let tempValue = value || []
$: numFilters = Array.isArray(tempValue) $: numFilters = Array.isArray(tempValue)
? tempValue.length ? tempValue.length
@ -31,15 +31,6 @@
$: schemaFields = Object.values(schema || {}) $: schemaFields = Object.values(schema || {})
$: internalTable = dataSource?.type === "table" $: 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 () => { const saveFilter = async () => {
dispatch("change", tempValue) dispatch("change", tempValue)
notifications.success("Filters saved.") notifications.success("Filters saved.")