Code review refactoring
This commit is contained in:
parent
956a826b8c
commit
f2b4ba2fb2
|
@ -21,15 +21,18 @@
|
||||||
$: schema = getSchemaForDatasource($currentAsset, datasource, true).schema
|
$: schema = getSchemaForDatasource($currentAsset, datasource, true).schema
|
||||||
$: options = getOptions(schema, type, fieldTypes)
|
$: options = getOptions(schema, type, fieldTypes)
|
||||||
|
|
||||||
const getOptions = (schema, type, fieldTypes) => {
|
const getOptions = (schema, type) => {
|
||||||
let entries = Object.entries(schema ?? {})
|
let entries = Object.entries(schema ?? {})
|
||||||
|
|
||||||
// fallback to using only field/options fields
|
let types = []
|
||||||
if (!fieldTypes) {
|
if (type === "field/options") {
|
||||||
fieldTypes = [type]
|
// allow options to be used on both options and string fields
|
||||||
|
types = [type, "field/string"]
|
||||||
|
} else {
|
||||||
|
types = [type]
|
||||||
}
|
}
|
||||||
|
|
||||||
const types = fieldTypes.map(fieldType => fieldType.split("/")[1])
|
types = types.map(type => type.split("/")[1])
|
||||||
entries = entries.filter(entry => types.includes(entry[1].type))
|
entries = entries.filter(entry => types.includes(entry[1].type))
|
||||||
|
|
||||||
return entries.map(entry => entry[0])
|
return entries.map(entry => entry[0])
|
||||||
|
|
Loading…
Reference in New Issue