diff options
| author | Zog | 2018-04-26 11:38:02 +0200 | 
|---|---|---|
| committer | Zog | 2018-04-26 11:38:02 +0200 | 
| commit | c431b8cd24014f0ddcdfbe28fc3f51cf5774b527 (patch) | |
| tree | a643ddfb3a635a605dbeb8b991ef677be9595890 /app/javascript/helpers/CustomFieldsInputs.js | |
| parent | e69dfa80737402286adbfe6f29edae2efca36fd8 (diff) | |
| download | chouette-core-c431b8cd24014f0ddcdfbe28fc3f51cf5774b527.tar.bz2 | |
Refs #6819; Fix CustomFields in React views6819-fix-vjs-custom-fields
Diffstat (limited to 'app/javascript/helpers/CustomFieldsInputs.js')
| -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()} }          />      ) | 
