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) {
const { type } = datasource
if (type === "query") {
const queries = get(queriesStores).queries
const queries = get(queriesStores).list
table = queries.find(query => query._id === datasource._id)
} else {
const tables = get(tablesStore).list

View File

@ -1,5 +1,5 @@
<script>
import { Select, Label, Spacer } from "@budibase/bbui"
import { Select, Label, Layout } from "@budibase/bbui"
import { store, currentAsset } from "builderStore"
import { datasources, integrations, queries } from "stores/backend"
import { getBindableProperties } from "builderStore/dataBinding"
@ -8,9 +8,9 @@
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(
ds => ds._id === parameters.datasourceId
(ds) => ds._id === parameters.datasourceId
)
$: bindableProperties = getBindableProperties(
$currentAsset,
@ -18,40 +18,44 @@
)
function fetchQueryDefinition(query) {
const source = $datasources.list.find(ds => ds._id === query.datasourceId)
const source = $datasources.list.find((ds) => ds._id === query.datasourceId)
.source
return $integrations[source].query[query.queryVerb]
}
</script>
<Layout gap="S">
<Label>Datasource</Label>
<Select
bind:value={parameters.datasourceId}
option={$datasources.list}
getOptionLabel={source => source.name}
getOptionValue={source => source._id} />
<Spacer medium />
getOptionLabel={(source) => source.name}
getOptionValue={(source) => source._id}
/>
{#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} />
options={$queries.list.filter(
(query) => query.datasourceId === datasource._id
)}
getOptionLabel={(query) => query.name}
getOptionValue={(query) => query._id}
/>
{/if}
<Spacer medium />
{#if query?.parameters?.length > 0}
<ParameterBuilder
bind:customParams={parameters.queryParams}
parameters={query.parameters}
bindings={bindableProperties} />
bindings={bindableProperties}
/>
<IntegrationQueryEditor
height={200}
{query}
schema={fetchQueryDefinition(query)}
editable={false} />
editable={false}
/>
{/if}
</Layout>