diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-07 17:58:42 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-07 17:58:42 +0200 |
| commit | 588431b988b138047aa4d7343c23d22d99285631 (patch) | |
| tree | 17f3975c161bbbd111af2e834dc54bfbb669d2bf /app/client/common | |
| parent | 584dbf9e5fd4bfb2c54b65bcc96ef0c35c5a24aa (diff) | |
fix module
Diffstat (limited to 'app/client/common')
| -rw-r--r-- | app/client/common/select.component.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/app/client/common/select.component.js b/app/client/common/select.component.js index f1e441f..fc69e87 100644 --- a/app/client/common/select.component.js +++ b/app/client/common/select.component.js @@ -13,21 +13,29 @@ class Select extends Component { this.props.onChange && this.props.onChange(this.props.name, new_value) } render() { - const value = this.props.opt[this.props.name] + const currentValue = this.props.opt[this.props.name] let lastValue const options = (this.props.options || []).map((key,i) => { let name, value - if (typeof key === 'object' && key.length) { - [name, value] = key - } - else if (typeof key === 'string') { + if (typeof key === 'string') { name = key.length < 4 ? key.toUpperCase() : key value = key - } else { - let frames = Math.round(key.count / 30) + ' s.' - name = key.name.replace(/_/g, ' ') + ' (' + frames + ')' - value = key.name } + else if (typeof key === 'object') { + if (key.length) { + [name, value] = key + } + else if (key.count) { + let frames = Math.round(key.count / 30) + ' s.' + name = key.name.replace(/_/g, ' ') + ' (' + frames + ')' + value = key.name + } + else { + name = key.name + value = key.value || key.name + } + } + console.log(key, name, value) lastValue = value return ( <option value={value} key={i}> @@ -41,7 +49,7 @@ class Select extends Component { <span>{this.props.title}</span> <select onChange={this.handleChange} - value={value || lastValue} + value={currentValue || lastValue} > {options} </select> |
