1
0
Fork 0
mirror of synced 2024-08-31 01:31:18 +12:00

Remove _id from filter field list in external dbs

This commit is contained in:
Mel O'Hagan 2022-11-29 11:00:54 +00:00
parent 57f695ac3c
commit 2e5744eedd
3 changed files with 17 additions and 7 deletions

View file

@ -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"]

View file

@ -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

View file

@ -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)
}