diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index df752cf6a1..0a235dd9a0 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -139,10 +139,10 @@ export const getBackendUiStore = () => { }) return json }, - select: queryId => + select: query => store.update(state => { - state.selectedDatasourceId = null - state.selectedQueryId = queryId + state.selectedDatasourceId = query.datasourceId + state.selectedQueryId = query._id return state }), delete: async query => { diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index 1bcdbaca64..aa8954cb8d 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -18,13 +18,12 @@ $goto(`./datasource/${datasource._id}`) } - function onClickQuery(datasourceId, queryId) { - if ($backendUiStore.selectedQueryId === queryId) { + function onClickQuery(query) { + if ($backendUiStore.selectedQueryId === query._id) { return } - backendUiStore.actions.datasources.select(datasourceId) - backendUiStore.actions.queries.select(queryId) - $goto(`./datasource/${datasourceId}/${queryId}`) + backendUiStore.actions.queries.select(query) + $goto(`./datasource/${query.datasourceId}/${query._id}`) } onMount(() => { @@ -55,7 +54,7 @@ icon="ri-eye-line" text={query.name} selected={$backendUiStore.selectedQueryId === query._id} - on:click={() => onClickQuery(datasource._id, query._id)}> + on:click={() => onClickQuery(query)}> {/each} diff --git a/packages/builder/src/components/integration/index.svelte b/packages/builder/src/components/integration/index.svelte index ebaf63898e..1f0aa30c49 100644 --- a/packages/builder/src/components/integration/index.svelte +++ b/packages/builder/src/components/integration/index.svelte @@ -29,22 +29,24 @@ {#if schema} - {#if schema.type === QueryTypes.SQL} - - {:else if schema.type === QueryTypes.JSON} - - - {:else if schema.type === QueryTypes.FIELDS} - - {/if} + {#key query._id} + {#if schema.type === QueryTypes.SQL} + + {:else if schema.type === QueryTypes.JSON} + + + {:else if schema.type === QueryTypes.FIELDS} + + {/if} + {/key} {/if} diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/ExecuteQuery.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/ExecuteQuery.svelte index 0f56d1f7ed..34f0dbda7c 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/ExecuteQuery.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/ExecuteQuery.svelte @@ -51,7 +51,7 @@ - {#if query?.parameters.length > 0} + {#if query?.parameters?.length > 0} m._id === componentInstance.datasource.tableId) - : null + : queries.find(query => query._id === componentInstance.datasource._id) $: type = componentInstance.datasource.type + $: if (table) { options = - type === "table" || type === "link" + type === "table" || type === "link" || type === "query" ? Object.keys(table.schema) : Object.keys(table.views[componentInstance.datasource.name].schema) } diff --git a/packages/builder/src/components/userInterface/TableViewSelect.svelte b/packages/builder/src/components/userInterface/TableViewSelect.svelte index be16a9109a..ccf3751a14 100644 --- a/packages/builder/src/components/userInterface/TableViewSelect.svelte +++ b/packages/builder/src/components/userInterface/TableViewSelect.svelte @@ -122,7 +122,7 @@ {#if value.parameters.length > 0} query._id === value._id).parameters} bindings={queryBindableProperties} /> {/if} diff --git a/packages/client/src/api/datasources.js b/packages/client/src/api/datasources.js index 15e3a6fc10..ff91a9f61d 100644 --- a/packages/client/src/api/datasources.js +++ b/packages/client/src/api/datasources.js @@ -25,7 +25,7 @@ export const fetchDatasource = async (datasource, dataContext) => { } else if (type === "query") { const bindings = get(bindingStore) - // TODO: refactor. Set these defaults up somewhere else + // Set the default query params let queryParams = datasource.queryParams || {} for (let param of datasource.parameters) { if (!queryParams[param.name]) {