fix dataBinding error

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-28 15:18:12 +02:00
parent e63e2b369a
commit f833c1a5a0
2 changed files with 37 additions and 33 deletions

View File

@ -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

View File

@ -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>
<Select
bind:value={parameters.datasourceId} bind:value={parameters.datasourceId}
option={$datasources.list} option={$datasources.list}
getOptionLabel={source => source.name} getOptionLabel={(source) => source.name}
getOptionValue={source => source._id} /> getOptionValue={(source) => source._id}
/>
<Spacer medium /> {#if parameters.datasourceId}
{#if parameters.datasourceId}
<Label>Query</Label> <Label>Query</Label>
<Select <Select
bind:value={parameters.queryId} bind:value={parameters.queryId}
options={$queries.list.filter(query => query.datasourceId === datasource._id)} options={$queries.list.filter(
getOptionLabel={query => query.name} (query) => query.datasourceId === datasource._id
getOptionValue={query => query._id} /> )}
{/if} getOptionLabel={(query) => query.name}
getOptionValue={(query) => query._id}
/>
{/if}
<Spacer medium /> {#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 <IntegrationQueryEditor
height={200} height={200}
{query} {query}
schema={fetchQueryDefinition(query)} schema={fetchQueryDefinition(query)}
editable={false} /> editable={false}
{/if} />
{/if}
</Layout>