|
|
|
@ -10,6 +10,7 @@ |
|
|
|
export let componentInstance |
|
|
|
export let value |
|
|
|
export let type |
|
|
|
export let fieldTypes |
|
|
|
|
|
|
|
$: form = findClosestMatchingComponent( |
|
|
|
$currentAsset.props, |
|
|
|
@ -18,14 +19,19 @@ |
|
|
|
) |
|
|
|
$: datasource = getDatasourceForProvider($currentAsset, form) |
|
|
|
$: schema = getSchemaForDatasource($currentAsset, datasource, true).schema |
|
|
|
$: options = getOptions(schema, type) |
|
|
|
$: options = getOptions(schema, type, fieldTypes) |
|
|
|
|
|
|
|
const getOptions = (schema, fieldType) => { |
|
|
|
const getOptions = (schema, type, fieldTypes) => { |
|
|
|
let entries = Object.entries(schema ?? {}) |
|
|
|
if (fieldType) { |
|
|
|
fieldType = fieldType.split("/")[1] |
|
|
|
entries = entries.filter(entry => entry[1].type === fieldType) |
|
|
|
|
|
|
|
// fallback to using only field/options fields |
|
|
|
if (!fieldTypes) { |
|
|
|
fieldTypes = [type] |
|
|
|
} |
|
|
|
|
|
|
|
const types = fieldTypes.map(fieldType => fieldType.split("/")[1]) |
|
|
|
entries = entries.filter(entry => types.includes(entry[1].type)) |
|
|
|
|
|
|
|
return entries.map(entry => entry[0]) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|