|
|
@ -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> |
|
|
{#if query?.parameters?.length > 0} |
|
|
<Select |
|
|
<ParameterBuilder |
|
|
bind:value={parameters.queryId} |
|
|
bind:customParams={parameters.queryParams} |
|
|
options={$queries.list.filter( |
|
|
parameters={query.parameters} |
|
|
(query) => query.datasourceId === datasource._id |
|
|
bindings={bindableProperties} /> |
|
|
)} |
|
|
<IntegrationQueryEditor |
|
|
getOptionLabel={(query) => query.name} |
|
|
height={200} |
|
|
getOptionValue={(query) => query._id} |
|
|
{query} |
|
|
/> |
|
|
schema={fetchQueryDefinition(query)} |
|
|
{/if} |
|
|
editable={false} /> |
|
|
|
|
|
{/if} |
|
|
{#if query?.parameters?.length > 0} |
|
|
|
|
|
<ParameterBuilder |
|
|
|
|
|
bind:customParams={parameters.queryParams} |
|
|
|
|
|
parameters={query.parameters} |
|
|
|
|
|
bindings={bindableProperties} |
|
|
|
|
|
/> |
|
|
|
|
|
<IntegrationQueryEditor |
|
|
|
|
|
height={200} |
|
|
|
|
|
{query} |
|
|
|
|
|
schema={fetchQueryDefinition(query)} |
|
|
|
|
|
editable={false} |
|
|
|
|
|
/> |
|
|
|
|
|
{/if} |
|
|
|
|
|
</Layout> |
|
|
|