Portal list configuration

This commit is contained in:
2020-03-03 16:05:27 -06:00
parent 8ab376a581
commit 2117659510
3 changed files with 47 additions and 8 deletions

View File

@@ -86,15 +86,19 @@ class Configuration extends IPCContainer {
const itemList = Object const itemList = Object
.keys(config) .keys(config)
.map(key => { .map(key => {
return { const ret = {
advanced: template[key] ? template[key].advanced : false, advanced: template[key] ? template[key].advanced : false,
hide_remote: template[key] ? template[key].hide_remote : false, hide_remote: template[key] ? template[key].hide_remote : false,
label: key, label: key,
remote: template[key] ? template[key].remote : false, remote: template[key] ? template[key].remote : false,
type: template[key] ? template[key].type : null,
value: (template[key] && (template[key].type === 'object')) ? value: (template[key] && (template[key].type === 'object')) ?
config[key] :
(template[key] && (template[key].type === 'string_array')) ?
config[key] : config[key] :
config[key].toString(), config[key].toString(),
}; };
return ret;
}) })
.filter(i=> { .filter(i=> {
let ret = template[i.label]; let ret = template[i.label];
@@ -114,7 +118,7 @@ class Configuration extends IPCContainer {
const itemList = [ const itemList = [
...this.state.ItemList ...this.state.ItemList
]; ];
itemList[idx].value = target.value.toString(); itemList[idx].value = target.type === 'textarea' ? target.string_array : target.value.toString();
this.setState({ this.setState({
ItemList: itemList ItemList: itemList
}); });
@@ -128,7 +132,7 @@ class Configuration extends IPCContainer {
...this.state.ObjectLookup, ...this.state.ObjectLookup,
}; };
itemList[idx].value = target.value.toString(); itemList[idx].value = target.type === 'textarea' ? target.string_array : target.value.toString();
objectLookup[name] = itemList; objectLookup[name] = itemList;
this.setState({ this.setState({
ObjectLookup: objectLookup, ObjectLookup: objectLookup,
@@ -203,7 +207,9 @@ class Configuration extends IPCContainer {
for (const item of this.state.ChangedItems) { for (const item of this.state.ChangedItems) {
changedItems.push({ changedItems.push({
Name: item.label, Name: item.label,
Value: item.value, Value: item.type === 'string_array' ?
item.value.join(';') :
item.value,
}); });
} }
@@ -212,7 +218,9 @@ class Configuration extends IPCContainer {
for (const item of this.state.ChangedObjectLookup[key]) { for (const item of this.state.ChangedObjectLookup[key]) {
changedItems.push({ changedItems.push({
Name: key + '.' + item.label, Name: key + '.' + item.label,
Value: item.value, Value: item.type === 'string_array' ?
item.value.join(';') :
item.value,
}); });
} }
} }

View File

@@ -16,6 +16,23 @@ input.ConfigurationItemInput {
box-sizing: border-box; box-sizing: border-box;
} }
textarea.ConfigurationItemInput {
display: block;
margin: 0;
padding: 2px;
border-radius: var(--border_radius);
background: rgba(160, 160, 160, 0.1);
border: none;
box-shadow: none;
outline: none;
color: var(--text_color);
box-sizing: border-box;
resize: none;
overflow-y: scroll;
overflow:-moz-scrollbars-horizontal;
white-space: nowrap;
}
.ConfigurationInfo { .ConfigurationInfo {
cursor: pointer; cursor: pointer;
} }

View File

@@ -19,6 +19,8 @@ export default connect(null, mapDispatchToProps)(props => {
const target = e.target; const target = e.target;
if (target.type === 'checkbox') { if (target.type === 'checkbox') {
target.value = e.target.checked ? 'true' : 'false'; target.value = e.target.checked ? 'true' : 'false';
} else if (target.type === 'textarea') {
e.target.string_array = String(e.target.value).replace(/\r\n/g,'\n').split('\n');
} }
props.changed(target); props.changed(target);
}; };
@@ -118,6 +120,18 @@ export default connect(null, mapDispatchToProps)(props => {
value={props.value}/>; value={props.value}/>;
break; break;
case 'string_array':
data = (
<textarea autoFocus={props.autoFocus}
disabled={props.readOnly}
rows={4}
cols={40}
onChange={e=>handleChanged(e)}
className={'ConfigurationItemInput'}
value={props.value.join('\n')} />
);
break;
default: default:
data = <div>{props.value}</div>; data = <div>{props.value}</div>;
} }
@@ -130,7 +144,7 @@ export default connect(null, mapDispatchToProps)(props => {
<tr> <tr>
{infoDisplay ? {infoDisplay ?
<td width='100%'>{infoDisplay} {props.label}</td> : <td width='100%'>{infoDisplay} {props.label}</td> :
<td width='100%'>{props.label}</td>} <td width='100%' valign={'top'}>{props.label}</td>}
<td>{data}</td> <td>{data}</td>
</tr> </tr>
</tbody> </tbody>