Merge pull request #8911 from Budibase/bug/sev2/custom-sql-query-bindings

Update custom sql query in design when changed in the data section
This commit is contained in:
melohagan 2023-01-10 16:51:27 +00:00 committed by GitHub
commit 88bda769a4
2 changed files with 14 additions and 1 deletions

View File

@ -144,6 +144,11 @@
drawer.show() drawer.show()
} }
const getQueryValue = queries => {
value = queries.find(q => q._id === value._id) || value
return value
}
const saveQueryParams = () => { const saveQueryParams = () => {
handleSelected({ handleSelected({
...value, ...value,
@ -175,7 +180,7 @@
{/if} {/if}
<IntegrationQueryEditor <IntegrationQueryEditor
height={200} height={200}
query={value} query={getQueryValue(queries)}
schema={fetchQueryDefinition(value)} schema={fetchQueryDefinition(value)}
datasource={getQueryDatasource(value)} datasource={getQueryDatasource(value)}
editable={false} editable={false}

View File

@ -105,6 +105,7 @@
{#if !query.fields.steps?.length} {#if !query.fields.steps?.length}
<div class="controls"> <div class="controls">
<Button <Button
disabled={!editable}
secondary secondary
slot="buttons" slot="buttons"
on:click={() => { on:click={() => {
@ -131,6 +132,7 @@
{#if index > 0} {#if index > 0}
<ActionButton <ActionButton
quiet quiet
disabled={!editable}
on:click={() => { on:click={() => {
updateEditorsOnSwap(index, index - 1) updateEditorsOnSwap(index, index - 1)
const target = query.fields.steps[index - 1].key const target = query.fields.steps[index - 1].key
@ -144,6 +146,7 @@
{#if index < query.fields.steps.length - 1} {#if index < query.fields.steps.length - 1}
<ActionButton <ActionButton
quiet quiet
disabled={!editable}
on:click={() => { on:click={() => {
updateEditorsOnSwap(index, index + 1) updateEditorsOnSwap(index, index + 1)
const target = query.fields.steps[index + 1].key const target = query.fields.steps[index + 1].key
@ -156,6 +159,7 @@
{/if} {/if}
</div> </div>
<ActionButton <ActionButton
disabled={!editable}
on:click={() => { on:click={() => {
updateEditorsOnDelete(index) updateEditorsOnDelete(index)
query.fields.steps.splice(index, 1) query.fields.steps.splice(index, 1)
@ -169,6 +173,7 @@
<div class="fields"> <div class="fields">
<div class="block-field"> <div class="block-field">
<Select <Select
disabled={!editable}
value={step.key} value={step.key}
options={schema.steps.map(s => s.key)} options={schema.steps.map(s => s.key)}
on:change={({ detail }) => { on:change={({ detail }) => {
@ -178,6 +183,7 @@
<Editor <Editor
bind:this={stepEditors[index]} bind:this={stepEditors[index]}
editorHeight={height / 2} editorHeight={height / 2}
readOnly={!editable}
mode="json" mode="json"
value={typeof step.value === "string" value={typeof step.value === "string"
? step.value ? step.value
@ -194,9 +200,11 @@
<div class="separator" /> <div class="separator" />
{#if index === query.fields.steps.length - 1} {#if index === query.fields.steps.length - 1}
<Icon <Icon
disabled={!editable}
hoverable hoverable
name="AddCircle" name="AddCircle"
size="S" size="S"
readOnly={!editable}
on:click={() => { on:click={() => {
query.fields.steps = [ query.fields.steps = [
...query.fields.steps, ...query.fields.steps,