Fix query params directly mutating the stored app definition
This commit is contained in:
parent
6b20d5cf46
commit
cc212d456a
|
@ -31,6 +31,7 @@
|
||||||
const arrayTypes = ["attachment", "array"]
|
const arrayTypes = ["attachment", "array"]
|
||||||
let anchorRight, dropdownRight
|
let anchorRight, dropdownRight
|
||||||
let drawer
|
let drawer
|
||||||
|
let tmpQueryParams
|
||||||
|
|
||||||
$: text = value?.label ?? "Choose an option"
|
$: text = value?.label ?? "Choose an option"
|
||||||
$: tables = $tablesStore.list.map(m => ({
|
$: tables = $tablesStore.list.map(m => ({
|
||||||
|
@ -105,12 +106,12 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleSelected(selected) {
|
const handleSelected = selected => {
|
||||||
dispatch("change", selected)
|
dispatch("change", selected)
|
||||||
dropdownRight.hide()
|
dropdownRight.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchQueryDefinition(query) {
|
const fetchQueryDefinition = query => {
|
||||||
const source = $datasources.list.find(
|
const source = $datasources.list.find(
|
||||||
ds => ds._id === query.datasourceId
|
ds => ds._id === query.datasourceId
|
||||||
).source
|
).source
|
||||||
|
@ -124,6 +125,19 @@
|
||||||
const getQueryDatasource = query => {
|
const getQueryDatasource = query => {
|
||||||
return $datasources.list.find(ds => ds._id === query?.datasourceId)
|
return $datasources.list.find(ds => ds._id === query?.datasourceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openQueryParamsDrawer = () => {
|
||||||
|
tmpQueryParams = value.queryParams
|
||||||
|
drawer.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveQueryParams = () => {
|
||||||
|
handleSelected({
|
||||||
|
...value,
|
||||||
|
queryParams: tmpQueryParams,
|
||||||
|
})
|
||||||
|
drawer.hide()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container" bind:this={anchorRight}>
|
<div class="container" bind:this={anchorRight}>
|
||||||
|
@ -134,24 +148,14 @@
|
||||||
on:click={dropdownRight.show}
|
on:click={dropdownRight.show}
|
||||||
/>
|
/>
|
||||||
{#if value?.type === "query"}
|
{#if value?.type === "query"}
|
||||||
<i class="ri-settings-5-line" on:click={drawer.show} />
|
<i class="ri-settings-5-line" on:click={openQueryParamsDrawer} />
|
||||||
<Drawer title={"Query Parameters"} bind:this={drawer}>
|
<Drawer title={"Query Parameters"} bind:this={drawer}>
|
||||||
<Button
|
<Button slot="buttons" cta on:click={saveQueryParams}>Save</Button>
|
||||||
slot="buttons"
|
|
||||||
cta
|
|
||||||
on:click={() => {
|
|
||||||
notifications.success("Query parameters saved.")
|
|
||||||
handleSelected(value)
|
|
||||||
drawer.hide()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Save
|
|
||||||
</Button>
|
|
||||||
<DrawerContent slot="body">
|
<DrawerContent slot="body">
|
||||||
<Layout noPadding>
|
<Layout noPadding>
|
||||||
{#if getQueryParams(value).length > 0}
|
{#if getQueryParams(value).length > 0}
|
||||||
<ParameterBuilder
|
<ParameterBuilder
|
||||||
bind:customParams={value.queryParams}
|
bind:customParams={tmpQueryParams}
|
||||||
parameters={getQueryParams(value)}
|
parameters={getQueryParams(value)}
|
||||||
{bindings}
|
{bindings}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue