1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-16 00:00:03 +01:00

Merge branch 'develop' of git.rwth-aachen.de:acs/public/villas/web into develop

This commit is contained in:
Sonja Happ 2020-04-01 09:26:17 +02:00
commit 9f6ee37720

View file

@ -22,28 +22,58 @@ class EditWidgetHTMLContent extends React.Component {
constructor(props) {
super(props);
this.state = {
widget: {}
};
}
let value = "";
let parts = props.controlId.split('.');
if (parts.length === 1) {
// not a customProperty
value=props.widget[props.controlId]
} else if(parts.length === 2){
// a custom property
value=props.widget[parts[0]][parts[1]]
} else {
value="controlID contains too many dots"
}
handleKeyIgnore(event){
// This function prevents a keystroke from beeing handled by dialog.js
event.stopPropagation();
this.state = {
value: value
};
}
static getDerivedStateFromProps(props, state){
let value = "";
let parts = props.controlId.split('.');
if (parts.length === 1) {
// not a customProperty
value=props.widget[props.controlId]
} else if(parts.length === 2){
// a custom property
value=props.widget[parts[0]][parts[1]]
} else {
value="controlID contains too many dots"
}
return {
widget: props.widget
};
value: value
}
}
handleKeyIgnore(event){
// This function prevents a keystroke from beeing handled by dialog.js
event.stopPropagation();
}
render() {
return <FormGroup controlId={this.props.controlId}>
<FormLabel>HTML Content</FormLabel>
<FormControl onKeyPress={this.handleKeyIgnore} componentClass="textarea" style={{ height: 200 }} placeholder={this.props.placeholder} value={this.state.widget[this.props.controlId] || this.state.widget.customProperties[this.props.controlId] || ''} onChange={e => this.props.handleChange(e)} />
</FormGroup>;
return (
<FormGroup controlId={this.props.controlId}>
<FormLabel>HTML Content</FormLabel>
<FormControl type="text" onKeyPress={this.handleKeyIgnore} componentclass="textarea" style={{ height: 200 }} placeholder={this.props.placeholder} value={this.state.value} onChange={e => this.props.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
);
}
}
export default EditWidgetHTMLContent;