-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows a scene to trigger another scene
- Loading branch information
1 parent
13c875c
commit 009b4f5
Showing
12 changed files
with
281 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
front/src/routes/scene/edit-scene/actions/StartSceneParams.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import { Text } from 'preact-i18n'; | ||
import Select from 'react-select'; | ||
|
||
import actions from '../../../../actions/scene'; | ||
|
||
@connect('scenes', actions) | ||
class StartSceneParams extends Component { | ||
handleChange = selectedOption => { | ||
if (selectedOption) { | ||
this.props.updateActionProperty(this.props.columnIndex, this.props.index, 'scene', selectedOption.value); | ||
} else { | ||
this.props.updateActionProperty(this.props.columnIndex, this.props.index, 'scene', null); | ||
} | ||
}; | ||
|
||
refreshSelectedOptions = nextProps => { | ||
let selectedOption = null; | ||
let scenes = this.state.scenes || []; | ||
const currentScene = nextProps.scene.selector; | ||
|
||
if (scenes.length === 0 && nextProps.scenes) { | ||
scenes = nextProps.scenes | ||
.filter(scene => scene.selector !== currentScene) | ||
.map(scene => ({ | ||
value: scene.selector, | ||
label: scene.name | ||
})); | ||
} | ||
|
||
if (nextProps.action.scene && scenes.length > 0) { | ||
selectedOption = scenes.find(scene => scene.value === nextProps.action.scene) || null; | ||
} | ||
|
||
this.setState({ selectedOption, scenes }); | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
selectedOption: null | ||
}; | ||
} | ||
|
||
async componentDidMount() { | ||
await this.props.getScenes(); | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
this.refreshSelectedOptions(nextProps); | ||
} | ||
|
||
render(props, { selectedOption, scenes }) { | ||
return ( | ||
<div class="form-group"> | ||
<div class="alert alert-info"> | ||
<Text id="editScene.actionsCard.scene.notice" /> | ||
</div> | ||
<label class="form-label"> | ||
<Text id="editScene.actionsCard.scene.label" /> | ||
</label> | ||
<Select value={selectedOption} onChange={this.handleChange} options={scenes} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default StartSceneParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters