fix dataBinding error
This commit is contained in:
parent
381ab45834
commit
6c5b0f88b9
|
@ -252,7 +252,7 @@ export const getSchemaForDatasource = (datasource, isForm = false) => {
|
||||||
if (datasource) {
|
if (datasource) {
|
||||||
const { type } = datasource
|
const { type } = datasource
|
||||||
if (type === "query") {
|
if (type === "query") {
|
||||||
const queries = get(queriesStores).queries
|
const queries = get(queriesStores).list
|
||||||
table = queries.find(query => query._id === datasource._id)
|
table = queries.find(query => query._id === datasource._id)
|
||||||
} else {
|
} else {
|
||||||
const tables = get(tablesStore).list
|
const tables = get(tablesStore).list
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Select, Label, Spacer } from "@budibase/bbui"
|
import { Select, Label, Layout } from "@budibase/bbui"
|
||||||
import { store, currentAsset } from "builderStore"
|
import { store, currentAsset } from "builderStore"
|
||||||
import { datasources, integrations, queries } from "stores/backend"
|
import { datasources, integrations, queries } from "stores/backend"
|
||||||
import { getBindableProperties } from "builderStore/dataBinding"
|
import { getBindableProperties } from "builderStore/dataBinding"
|
||||||
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
export let parameters
|
export let parameters
|
||||||
|
|
||||||
$: query = $queries.list.find(q => q._id === parameters.queryId)
|
$: query = $queries.list.find((q) => q._id === parameters.queryId)
|
||||||
$: datasource = $datasources.list.find(
|
$: datasource = $datasources.list.find(
|
||||||
ds => ds._id === parameters.datasourceId
|
(ds) => ds._id === parameters.datasourceId
|
||||||
)
|
)
|
||||||
$: bindableProperties = getBindableProperties(
|
$: bindableProperties = getBindableProperties(
|
||||||
$currentAsset,
|
$currentAsset,
|
||||||
|
@ -18,40 +18,44 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
function fetchQueryDefinition(query) {
|
function fetchQueryDefinition(query) {
|
||||||
const source = $datasources.list.find(ds => ds._id === query.datasourceId)
|
const source = $datasources.list.find((ds) => ds._id === query.datasourceId)
|
||||||
.source
|
.source
|
||||||
return $integrations[source].query[query.queryVerb]
|
return $integrations[source].query[query.queryVerb]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Label>Datasource</Label>
|
<Layout gap="S">
|
||||||
<Select
|
<Label>Datasource</Label>
|
||||||
bind:value={parameters.datasourceId}
|
|
||||||
option={$datasources.list}
|
|
||||||
getOptionLabel={source => source.name}
|
|
||||||
getOptionValue={source => source._id} />
|
|
||||||
|
|
||||||
<Spacer medium />
|
|
||||||
|
|
||||||
{#if parameters.datasourceId}
|
|
||||||
<Label>Query</Label>
|
|
||||||
<Select
|
<Select
|
||||||
bind:value={parameters.queryId}
|
bind:value={parameters.datasourceId}
|
||||||
options={$queries.list.filter(query => query.datasourceId === datasource._id)}
|
option={$datasources.list}
|
||||||
getOptionLabel={query => query.name}
|
getOptionLabel={(source) => source.name}
|
||||||
getOptionValue={query => query._id} />
|
getOptionValue={(source) => source._id}
|
||||||
{/if}
|
/>
|
||||||
|
|
||||||
<Spacer medium />
|
{#if parameters.datasourceId}
|
||||||
|
<Label>Query</Label>
|
||||||
|
<Select
|
||||||
|
bind:value={parameters.queryId}
|
||||||
|
options={$queries.list.filter(
|
||||||
|
(query) => query.datasourceId === datasource._id
|
||||||
|
)}
|
||||||
|
getOptionLabel={(query) => query.name}
|
||||||
|
getOptionValue={(query) => query._id}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if query?.parameters?.length > 0}
|
{#if query?.parameters?.length > 0}
|
||||||
<ParameterBuilder
|
<ParameterBuilder
|
||||||
bind:customParams={parameters.queryParams}
|
bind:customParams={parameters.queryParams}
|
||||||
parameters={query.parameters}
|
parameters={query.parameters}
|
||||||
bindings={bindableProperties} />
|
bindings={bindableProperties}
|
||||||
<IntegrationQueryEditor
|
/>
|
||||||
height={200}
|
<IntegrationQueryEditor
|
||||||
{query}
|
height={200}
|
||||||
schema={fetchQueryDefinition(query)}
|
{query}
|
||||||
editable={false} />
|
schema={fetchQueryDefinition(query)}
|
||||||
{/if}
|
editable={false}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</Layout>
|
||||||
|
|
Loading…
Reference in New Issue