1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

recordForm now produces selects

This commit is contained in:
Michael Shanks 2020-02-27 22:06:53 +00:00
parent 5eaf7dbe00
commit 367bf820b5

View file

@ -32,6 +32,10 @@ const heading = record => ({
const field = (record, f) => {
if (f.type === "bool") return checkbox(record, f)
if (f.type === "string"
&& f.typeOptions
&& f.typeOptions.values
&& f.typeOptions.values.length > 0) return select(record, f)
return textField(record, f)
}
@ -54,6 +58,16 @@ const checkbox = (record, f) => ({
checked: fieldValueBinding(record, f),
})
const select = (record, f) => ({
_component: "@budibase/standard-components/select",
value: fieldValueBinding(record, f),
_children: f.typeOptions.values.map(val => ({
_component: "@budibase/standard-components/option",
value: val,
text: val
}))
})
const fieldValueBinding = (record, f) => `state.${record.name}.${f.name}`
const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1)