From b2e8522b7b3ca6ac7bd66e01d3a37dc4531b1f2e Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 24 Nov 2022 18:24:38 +0000 Subject: [PATCH 1/2] Don't add numbering to primary key --- .../settings/controls/FilterEditor/FilterEditor.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte index ea54afc0ee..05ee0adda8 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte @@ -28,7 +28,11 @@ function addNumbering(filters) { let count = 1 for (let value of filters) { - if (value.field && value.field?.match(QUERY_START_REGEX) == null) { + if ( + value.field && + value.field?.match(QUERY_START_REGEX) == null && + value.field !== "_id" + ) { value.field = `${count++}:${value.field}` } } From 9b6bd124995ce110807004897f89c473865e207a Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 29 Nov 2022 11:00:54 +0000 Subject: [PATCH 2/2] Remove _id from filter field list in external dbs --- .../settings/controls/FilterEditor/FilterDrawer.svelte | 7 ++++++- .../settings/controls/FilterEditor/FilterEditor.svelte | 7 ++----- packages/builder/src/helpers/searchFields.js | 10 +++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index a419f5ad46..019a61a3bf 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -30,9 +30,14 @@ export let allowBindings = true export let allOr = false export let fillWidth = false + export let tableId $: dispatch("change", filters) - $: enrichedSchemaFields = getFields(schemaFields || []) + $: enrichedSchemaFields = getFields( + schemaFields || [], + { allowLinks: true }, + tableId + ) $: fieldOptions = enrichedSchemaFields.map(field => field.name) || [] $: valueTypeOptions = allowBindings ? ["Value", "Binding"] : ["Value"] diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte index 05ee0adda8..72913aeb17 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte @@ -28,11 +28,7 @@ function addNumbering(filters) { let count = 1 for (let value of filters) { - if ( - value.field && - value.field?.match(QUERY_START_REGEX) == null && - value.field !== "_id" - ) { + if (value.field && value.field?.match(QUERY_START_REGEX) == null) { value.field = `${count++}:${value.field}` } } @@ -92,6 +88,7 @@ filters={initialFilters} {bindings} {schemaFields} + tableId={dataSource.tableId} bind:allOr on:change={event => { toSaveFilters = event.detail diff --git a/packages/builder/src/helpers/searchFields.js b/packages/builder/src/helpers/searchFields.js index a9c837d570..29a5f77a0d 100644 --- a/packages/builder/src/helpers/searchFields.js +++ b/packages/builder/src/helpers/searchFields.js @@ -16,7 +16,11 @@ export function getTableFields(linkField) { })) } -export function getFields(fields, { allowLinks } = { allowLinks: true }) { +export function getFields( + fields, + { allowLinks } = { allowLinks: true }, + tableId +) { let filteredFields = fields.filter( field => !BannedSearchTypes.includes(field.type) ) @@ -30,5 +34,9 @@ export function getFields(fields, { allowLinks } = { allowLinks: true }) { const staticFormulaFields = fields.filter( field => field.type === "formula" && field.formulaType === "static" ) + const table = get(tables).list.find(table => table._id === tableId) + if (table?.type === "external") { + filteredFields = filteredFields.filter(field => field.name !== "_id") + } return filteredFields.concat(staticFormulaFields) }