diff options
Diffstat (limited to 'app/client/common/select.component.js')
| -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> |
