Skip to content

Commit

Permalink
Set loaded value
Browse files Browse the repository at this point in the history
  • Loading branch information
atrovato committed Jan 20, 2023
1 parent a15a490 commit f8fcf7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions front/src/config/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,12 @@ const data = {
device_feature: 'main-lamp-binary',
operator: '=',
value: 1
},
{
type: 'device.new-state',
device_feature: 'button-click',
operator: '=',
value: 2
}
],
actions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class ButtonClickDeviceState extends Component {
this.getOptions();
}

render(props, { options }) {
render({ trigger }, { options }) {
const defaultValue = options.find(option => trigger.value === option.value);

return (
<Fragment>
<div class="col-2 col-md-1">
Expand All @@ -40,7 +42,7 @@ class ButtonClickDeviceState extends Component {
</div>
<div class="col-10 col-md-5">
<div class="form-group">
<Select defaultValue={''} onChange={this.handleValueChange} options={options} />
<Select defaultValue={defaultValue || ''} onChange={this.handleValueChange} options={options} />
</div>
</div>
</Fragment>
Expand Down

0 comments on commit f8fcf7d

Please sign in to comment.