2018-03-25 18:03:08 +00:00
|
|
|
// License: LGPL-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
const h = require('snabbdom/h')
|
|
|
|
const R = require('ramda')
|
|
|
|
|
|
|
|
const geo = require('../common/geography')
|
|
|
|
const stateCodes = geo.stateCodes
|
|
|
|
|
|
|
|
|
|
|
|
// Generate a drop
|
|
|
|
//
|
|
|
|
// options are
|
|
|
|
// {
|
|
|
|
// default: val // default value to be selected among the options
|
|
|
|
// , name: str // name attribute of the select
|
|
|
|
// }
|
|
|
|
|
|
|
|
function view(options) {
|
|
|
|
var stateOptions = R.map(
|
|
|
|
s => h('option', {props: {value: s, selected: options.default === s}}, s)
|
|
|
|
, stateCodes
|
|
|
|
)
|
|
|
|
return h('select', {props: {name: options.name }}, stateOptions)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = view
|