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
This commit is contained in:
parent
c1f38699a5
commit
09cf4f8bbc
|
@ -8,6 +8,7 @@
|
||||||
getSchemaForDatasource,
|
getSchemaForDatasource,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
import { currentAsset } from "builderStore"
|
import { currentAsset } from "builderStore"
|
||||||
|
import { getFields } from "helpers/searchFields"
|
||||||
|
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
export let value = []
|
export let value = []
|
||||||
|
@ -21,9 +22,14 @@
|
||||||
|
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
$: schema = getSchema($currentAsset, datasource)
|
$: schema = getSchema($currentAsset, datasource)
|
||||||
$: options = Object.keys(schema || {})
|
$: options = allowCellEditing
|
||||||
|
? Object.keys(schema || {})
|
||||||
|
: enrichedSchemaFields?.map(field => field.name)
|
||||||
$: sanitisedValue = getValidColumns(value, options)
|
$: sanitisedValue = getValidColumns(value, options)
|
||||||
$: updateBoundValue(sanitisedValue)
|
$: updateBoundValue(sanitisedValue)
|
||||||
|
$: enrichedSchemaFields = getFields(Object.values(schema) || [], {
|
||||||
|
allowLinks: true,
|
||||||
|
})
|
||||||
|
|
||||||
const getSchema = (asset, datasource) => {
|
const getSchema = (asset, datasource) => {
|
||||||
const schema = getSchemaForDatasource(asset, datasource).schema
|
const schema = getSchemaForDatasource(asset, datasource).schema
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
|
|
||||||
const cleanUrl = inputUrl =>
|
const cleanUrl = inputUrl =>
|
||||||
url
|
url
|
||||||
?.replace(/(http)|(https)|[{}:]/g, "")
|
?.replace(/(https)|(http)|[{}:]/g, "")
|
||||||
?.replaceAll(".", "_")
|
?.replaceAll(".", "_")
|
||||||
?.replaceAll("/", " ")
|
?.replaceAll("/", " ")
|
||||||
?.trim() || inputUrl
|
?.trim() || inputUrl
|
||||||
|
|
|
@ -57,6 +57,9 @@
|
||||||
const onFieldChange = (expression, field) => {
|
const onFieldChange = (expression, field) => {
|
||||||
// Update the field type
|
// Update the field type
|
||||||
expression.type = schemaFields.find(x => x.name === 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
|
// Ensure a valid operator is set
|
||||||
const validOperators = LuceneUtils.getValidOperatorsForType(
|
const validOperators = LuceneUtils.getValidOperatorsForType(
|
||||||
|
|
|
@ -81,6 +81,7 @@ export const getRelationshipSchemaAdditions = async schema => {
|
||||||
Object.keys(linkSchema || {}).forEach(linkKey => {
|
Object.keys(linkSchema || {}).forEach(linkKey => {
|
||||||
relationshipAdditions[`${fieldKey}.${linkKey}`] = {
|
relationshipAdditions[`${fieldKey}.${linkKey}`] = {
|
||||||
type: linkSchema[linkKey].type,
|
type: linkSchema[linkKey].type,
|
||||||
|
externalType: linkSchema[linkKey].externalType,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue