From c431b8cd24014f0ddcdfbe28fc3f51cf5774b527 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 26 Apr 2018 11:38:02 +0200 Subject: Refs #6819; Fix CustomFields in React views --- app/javascript/helpers/CustomFieldsInputs.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/javascript/helpers/CustomFieldsInputs.js') 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( { + 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()} } /> ) -- cgit v1.2.3