From 09cf4f8bbcd68eed115777d298b4a79648371f83 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:32:52 +0000 Subject: [PATCH] Dynamic filter: Enrich columns (#9877) * WIP * Allow related fields in Dynamic Filter * REST URL check https first * Only allow related fields in dynamic filter column editor --- .../settings/controls/ColumnEditor/ColumnEditor.svelte | 8 +++++++- .../src/components/integration/RestQueryViewer.svelte | 2 +- .../src/components/app/dynamic-filter/FilterModal.svelte | 3 +++ packages/client/src/utils/schema.js | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ColumnEditor/ColumnEditor.svelte b/packages/builder/src/components/design/settings/controls/ColumnEditor/ColumnEditor.svelte index 36cc9f619d..098a8f7ed7 100644 --- a/packages/builder/src/components/design/settings/controls/ColumnEditor/ColumnEditor.svelte +++ b/packages/builder/src/components/design/settings/controls/ColumnEditor/ColumnEditor.svelte @@ -8,6 +8,7 @@ getSchemaForDatasource, } from "builderStore/dataBinding" import { currentAsset } from "builderStore" + import { getFields } from "helpers/searchFields" export let componentInstance export let value = [] @@ -21,9 +22,14 @@ $: datasource = getDatasourceForProvider($currentAsset, componentInstance) $: schema = getSchema($currentAsset, datasource) - $: options = Object.keys(schema || {}) + $: options = allowCellEditing + ? Object.keys(schema || {}) + : enrichedSchemaFields?.map(field => field.name) $: sanitisedValue = getValidColumns(value, options) $: updateBoundValue(sanitisedValue) + $: enrichedSchemaFields = getFields(Object.values(schema) || [], { + allowLinks: true, + }) const getSchema = (asset, datasource) => { const schema = getSchemaForDatasource(asset, datasource).schema diff --git a/packages/builder/src/components/integration/RestQueryViewer.svelte b/packages/builder/src/components/integration/RestQueryViewer.svelte index 0ba232cbdb..1f21ae897e 100644 --- a/packages/builder/src/components/integration/RestQueryViewer.svelte +++ b/packages/builder/src/components/integration/RestQueryViewer.svelte @@ -120,7 +120,7 @@ const cleanUrl = inputUrl => url - ?.replace(/(http)|(https)|[{}:]/g, "") + ?.replace(/(https)|(http)|[{}:]/g, "") ?.replaceAll(".", "_") ?.replaceAll("/", " ") ?.trim() || inputUrl diff --git a/packages/client/src/components/app/dynamic-filter/FilterModal.svelte b/packages/client/src/components/app/dynamic-filter/FilterModal.svelte index 5bc3e500a1..3b397761cc 100644 --- a/packages/client/src/components/app/dynamic-filter/FilterModal.svelte +++ b/packages/client/src/components/app/dynamic-filter/FilterModal.svelte @@ -57,6 +57,9 @@ const onFieldChange = (expression, field) => { // Update the field type expression.type = schemaFields.find(x => x.name === field)?.type + expression.externalType = schemaFields.find( + x => x.name === field + )?.externalType // Ensure a valid operator is set const validOperators = LuceneUtils.getValidOperatorsForType( diff --git a/packages/client/src/utils/schema.js b/packages/client/src/utils/schema.js index 433a1c5fee..e450c516d7 100644 --- a/packages/client/src/utils/schema.js +++ b/packages/client/src/utils/schema.js @@ -81,6 +81,7 @@ export const getRelationshipSchemaAdditions = async schema => { Object.keys(linkSchema || {}).forEach(linkKey => { relationshipAdditions[`${fieldKey}.${linkKey}`] = { type: linkSchema[linkKey].type, + externalType: linkSchema[linkKey].externalType, } }) }