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