Add format option to ui settings to display textarea, change existing to text and select
import React from 'react';
-import { Select, Form, Input, Table } from 'semantic-ui-react';
+import { Select, Form, Input, Table, TextArea } from 'semantic-ui-react';
function groupSettingsFromUI(ui) {
let settingGroups = [];
@@ -61,29 +61,45 @@ const GeneratedUI = ({settings, ui, changeSettingsCallback}) => {
// Switch input type based on ui specification
let dataEntryElement;
- switch (data.type) {
- case 'str': {
+ switch (data.ui_format) {
+ case 'text': {
dataEntryElement = (<Input
type='text'
value={settings[ui_name]}
- onChange={(event, data) => { handleStrChange(ui_name, data)}}/>
- ); /* TODO */
+ onChange={(event, data) => {
+ handleStrChange(ui_name, data)
+ }}/>);
+ }
+ break;
+ case 'textarea': {
+ dataEntryElement = (<TextArea
+ value={settings[ui_name]}
+ onChange={(event, data) => {
+ handleStrChange(ui_name, data)
+ }}/>);
}
break;
case 'int': {
dataEntryElement = (<Input type='number'/>); /* TODO */
}
break;
- default: /*ENUM*/ {
+ case 'select': {
let options = [];
data.type.forEach(v => {
// <Select> does not like to display text if the key or value (?) is null.
// So convert null to string "- not selected -".
if (v === null) {
- console.log("pushing: ", {key: "- not selected -", value: "- not selected -", text: "- not selected -"});
- options.push({key: "- not selected -", value: "- not selected -", text: "- not selected -"})
- }
- else {
+ console.log("pushing: ", {
+ key: "- not selected -",
+ value: "- not selected -",
+ text: "- not selected -"
+ });
+ options.push({
+ key: "- not selected -",
+ value: "- not selected -",
+ text: "- not selected -"
+ })
+ } else {
console.log("pushing: ", {key: v, value: v, text: v});
options.push({key: v, value: v, text: v})
}
@@ -105,6 +121,9 @@ const GeneratedUI = ({settings, ui, changeSettingsCallback}) => {
/>);
// TODO: add a onChange that dispatches the setting (do this for int and string as well)
}
+ break;
+ default: {
+ }
}
// Construct row for individual setting
