summaryrefslogtreecommitdiff
path: root/app/client/common/select.component.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-03 21:05:52 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-03 21:05:52 +0200
commitc34ecb4aacb1d27913088ff2b4546f1504d8dd86 (patch)
tree79e96caf8e4aa7be440b8469b2172060b2f1d300 /app/client/common/select.component.js
parent02dc913860b162991db7fb0e2015a76570fbf33e (diff)
import form
Diffstat (limited to 'app/client/common/select.component.js')
-rw-r--r--app/client/common/select.component.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/client/common/select.component.js b/app/client/common/select.component.js
index 90bc6dc..3147dc4 100644
--- a/app/client/common/select.component.js
+++ b/app/client/common/select.component.js
@@ -1,7 +1,6 @@
import { h, Component } from 'preact'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
-import * as liveActions from '../live/live.actions'
class Select extends Component {
constructor(props){
@@ -11,14 +10,17 @@ class Select extends Component {
handleChange(e){
clearTimeout(this.timeout)
let new_value = e.target.value
- this.props.actions.set_param(this.props.name, new_value)
- this.props.onChange && this.props.onChange(new_value)
+ this.props.onChange && this.props.onChange(this.props.name, new_value)
}
render() {
const value = this.props.opt[this.props.name]
const options = (this.props.options || []).map((key,i) => {
let name, value
- if (typeof key == 'string') {
+ if (typeof key === 'object' && key.length) {
+ [name, value] = key
+ console.log(name, value)
+ }
+ else if (typeof key === 'string') {
name = key.length < 4 ? key.toUpperCase() : key
value = key
} else {
@@ -53,12 +55,11 @@ function capitalize(s){
return (s || "").replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
}
-const mapStateToProps = state => ({
- opt: state.live.opt,
+const mapStateToProps = (state, props) => ({
+ opt: props.opt || state.live.opt,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
- actions: bindActionCreators(liveActions, dispatch)
})
export default connect(mapStateToProps, mapDispatchToProps)(Select)