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

Slider Widget now works in vertical mode

This commit is contained in:
Laura Fuentes Grau 2020-04-02 19:35:40 +02:00
parent f3d0576dd6
commit 834efecb8a
2 changed files with 12 additions and 25 deletions

View file

@ -38,9 +38,15 @@ class EditWidgetOrientation extends Component {
}
handleOrientationChange(orientation) {
console.log("handle OrinetationChange was called. the orientation: " + orientation);
this.props.handleChange({ target: { id: 'customProperties.orientation', value: orientation } });
this.handleNewDimensions(this.state.widget.width,this.state.widget.height,this.state.widget.minWidth,this.state.widget.minHeight);
}
handleNewDimensions(width,height,minWidth,minHeight){
this.props.handleChange({ target: { id: 'height', value: width } });
this.props.handleChange({ target: { id: 'width', value: height } });
this.props.handleChange({ target: { id: 'minHeight', value: minWidth } });
this.props.handleChange({ target: { id: 'minWidth', value: minHeight } });
}
render() {
@ -57,7 +63,6 @@ class EditWidgetOrientation extends Component {
Object.keys(WidgetSlider.OrientationTypes).map( (type) => {
let value = WidgetSlider.OrientationTypes[type].value;
let name = WidgetSlider.OrientationTypes[type].name;
console.log("value: " + value + " name: " + name)
return (
<FormCheck inline label={name} key={value} id={value} type='radio' title='orientation' checked={ value === this.state.widget.customProperties.orientation } onChange={(e) => this.handleOrientationChange(value)}>

View file

@ -57,7 +57,7 @@ class WidgetSlider extends Component {
if (props.widget.customProperties.default_value && state.value === undefined) {
returnState["value"] = props.widget.customProperties.default_value;
}
// Update unit (assuming there is exactly one signal for this widget)
let signalID = props.widget.signalIDs[0];
let signal = props.signals.find(sig => sig.id === signalID);
@ -76,6 +76,7 @@ class WidgetSlider extends Component {
componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot: SS): void {
// Check if the orientation changed, update the size if it did
// this part didn't work -> dimensions and constraints are now handled by the edit orientation component
if (this.props.widget.customProperties.orientation !== prevProps.widget.customProperties.orientation) {
let baseWidget = this.props.widget;
@ -125,33 +126,14 @@ class WidgetSlider extends Component {
});
return (
!isVertical? (
<div className={widgetClasses}>
<label>{ fields.name }</label>
<div className='slider'>{ fields.control }</div>
{ fields.control }
<span>{ fields.value }</span>
{this.props.widget.customProperties.showUnit && fields.unit}
</div>
) : (
<div className={widgetClasses}>
<Slider vertical min={ this.props.widget.customProperties.rangeMin } max={ this.props.widget.customProperties.rangeMax } step={ this.props.widget.customProperties.step } value={ this.state.value } disabled={ this.props.editing } onChange={ (v) => this.valueIsChanging(v) } onAfterChange={ (v) => this.valueChanged(v) }/>,
</div>
)
);
}
}
export default WidgetSlider;
/*!isVertical? (
<div className={widgetClasses}>
<label>{ fields.name }</label>
<div className='slider'>{ fields.control }</div>
<span>{ fields.value }</span>
</div>
) : (
<div className={widgetClasses}>
<label>{ fields.name }</label>
{ fields.control }
{ fields.value }
{ this.props.widget.customProperties.showUnit && fields.unit }
</div>
)*/