From 9056b0e49da6e1fcc2eb985df0d242c206e1db34 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 21 Jan 2021 10:42:14 +0000 Subject: [PATCH] Enrich datasources so that data can be correctly fetched reactively using only the datasource definition --- .../PropertyControls/TableViewSelect.svelte | 12 ++++--- packages/client/src/api/datasources.js | 26 +++++--------- .../client/src/utils/enrichDataBinding.js | 34 +++++++++++++++---- packages/standard-components/src/List.svelte | 15 +++----- .../src/charts/BarChart.svelte | 2 +- .../src/charts/CandleStickChart.svelte | 2 +- .../src/charts/LineChart.svelte | 2 +- .../src/charts/PieChart.svelte | 2 +- .../src/grid/Component.svelte | 16 ++++----- 9 files changed, 61 insertions(+), 50 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte index 274975770b..bf88c8e9eb 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte @@ -37,6 +37,7 @@ $: queries = $backendUiStore.queries.map(query => ({ label: query.name, name: query.name, + tableId: query._id, ...query, schema: query.schema, parameters: query.parameters, @@ -59,9 +60,12 @@ providerId: property.providerId, label: property.readableBinding, fieldName: property.fieldSchema.name, - name: `all_${property.fieldSchema.tableId}`, tableId: property.fieldSchema.tableId, type: "link", + // These properties will be enriched by the client library and provide + // details of the parent row of the relationship field, from context + rowId: `{{ ${property.providerId}._id }}`, + rowTableId: `{{ ${property.providerId}.tableId }}`, } }) @@ -84,12 +88,12 @@ class="dropdownbutton" bind:this={anchorRight} on:click={dropdownRight.show}> - {value.label ? value.label : 'Table / View / Query'} + {value?.label ? value.label : 'Choose option'} -{#if value.type === 'query'} +{#if value?.type === 'query'} - +