* Constructor * @param {string} name Field name; expected to be camel cased * @param {object} [spec] Field spec * @param {string} [spec.label] Field label, defaults to title cased name * @param {mixed} [spec.value] Default field value * @param {object} [spec.delegate] Field delegate
(name, spec = {})
| 31 | * gets requested, returns randomly chosen value. |
| 32 | */ |
| 33 | constructor (name, spec = {}) { |
| 34 | super() |
| 35 | this._viewPrototype = FieldView |
| 36 | |
| 37 | this._name = name |
| 38 | this._value = spec.value !== undefined ? spec.value : null |
| 39 | this._delegate = spec.delegate || null |
| 40 | this._randomizable = spec.randomizable !== false |
| 41 | |
| 42 | // Validation |
| 43 | this._valid = true |
| 44 | this._message = null |
| 45 | this._messageKey = null |
| 46 | |
| 47 | // Custom validate, filter and randomize functions |
| 48 | this._validateValueCallback = spec.validateValue || null |
| 49 | this._filterValueCallback = spec.filterValue || null |
| 50 | this._randomizeValueCallback = spec.randomizeValue || null |
| 51 | |
| 52 | // View related properties |
| 53 | this._label = spec.label || StringUtil.camelCaseToRegular(name) |
| 54 | this._visible = spec.visible !== false |
| 55 | this._priority = spec.priority !== undefined ? spec.priority : 0 |
| 56 | this._width = spec.width || 12 |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns field name. |
nothing calls this directly
no test coverage detected