diff options
| author | Alban Peignier | 2018-04-26 11:41:17 +0200 |
|---|---|---|
| committer | GitHub | 2018-04-26 11:41:17 +0200 |
| commit | 1aeb36eb62d6cae25c40f3a99ff442fa9fe965fb (patch) | |
| tree | a643ddfb3a635a605dbeb8b991ef677be9595890 | |
| parent | e69dfa80737402286adbfe6f29edae2efca36fd8 (diff) | |
| parent | c431b8cd24014f0ddcdfbe28fc3f51cf5774b527 (diff) | |
| download | chouette-core-1aeb36eb62d6cae25c40f3a99ff442fa9fe965fb.tar.bz2 | |
Merge pull request #531 from af83/6819-fix-vjs-custom-fields
Fix CustomFields in React views. Fixes #6819
| -rw-r--r-- | app/javascript/helpers/CustomFieldsInputs.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/javascript/helpers/CustomFieldsInputs.js b/app/javascript/helpers/CustomFieldsInputs.js index 9547021eb..0a57e7566 100644 --- a/app/javascript/helpers/CustomFieldsInputs.js +++ b/app/javascript/helpers/CustomFieldsInputs.js @@ -8,15 +8,24 @@ export default class CustomFieldsInputs extends Component { super(props) } + options(cf){ + if(cf.options){ + return cf.options + } + return { + default: "" + } + } + listInput(cf){ return( <Select2 - data={_.map(cf.options.list_values, (v, k) => { + data={_.map(this.options(cf).list_values, (v, k) => { return {id: k, text: (v.length > 0 ? v : '\u00A0')} })} ref={'custom_fields.' + cf.code} className='form-control' - defaultValue={cf.value || cf.options.default} + defaultValue={cf.value || this.options(cf).default} disabled={this.props.disabled} options={{ theme: 'bootstrap', @@ -34,7 +43,7 @@ export default class CustomFieldsInputs extends Component { ref={'custom_fields.' + cf.code} className='form-control' disabled={this.props.disabled} - value={cf.value || cf.options.default} + value={cf.value || this.options(cf).default} onChange={(e) => {this.props.onUpdate(cf.code, e.target.value); this.forceUpdate()} } /> ) @@ -47,7 +56,7 @@ export default class CustomFieldsInputs extends Component { ref={'custom_fields.' + cf.code} className='form-control' disabled={this.props.disabled} - value={cf.value || cf.options.default} + value={cf.value || this.options(cf).default} onChange={(e) => {this.props.onUpdate(cf.code, e.target.value); this.forceUpdate()} } /> ) |
