Don't mutate views when transforming queryUI to make API happy

This commit is contained in:
Andrew Kingston 2024-10-14 12:58:15 +01:00
parent 963b3ae35c
commit 4d460c2a46
No known key found for this signature in database
2 changed files with 16 additions and 7 deletions

View File

@ -6,16 +6,22 @@ import { dataFilters } from "@budibase/shared-core"
function convertToSearchFilters(view) {
// convert from SearchFilterGroup type
if (view?.query) {
view.queryUI = view.query
view.query = dataFilters.buildQuery(view.query)
return {
...view,
queryUI: view.query,
query: dataFilters.buildQuery(view.query),
}
}
return view
}
function convertToSearchFilterGroup(view) {
if (view?.queryUI) {
view.query = view.queryUI
delete view.queryUI
return {
...view,
query: view.queryUI,
queryUI: undefined,
}
}
return view
}

View File

@ -3,9 +3,12 @@ import { dataFilters } from "@budibase/shared-core"
function convertToSearchFilters(view) {
// convert from SearchFilterGroup type
if (view.query) {
view.queryUI = view.query
view.query = dataFilters.buildQuery(view.query)
if (view?.query) {
return {
...view,
queryUI: view.query,
query: dataFilters.buildQuery(view.query),
}
}
return view
}