From 816b5ae598fd1668dd46d13cfcd1281bff624363 Mon Sep 17 00:00:00 2001 From: mama Date: Wed, 15 Nov 2017 11:36:56 +0100 Subject: [PATCH] Les questions peuvent changer toutes seules ce qu'elles renseignent Changer le field name de redux form --- source/components/conversation/FormDecorator.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/components/conversation/FormDecorator.js b/source/components/conversation/FormDecorator.js index 0c0d2cdcd..7f5807384 100644 --- a/source/components/conversation/FormDecorator.js +++ b/source/components/conversation/FormDecorator.js @@ -26,7 +26,8 @@ export var FormDecorator = formType => RenderField => ) class extends Component { state = { - helpVisible: false + helpVisible: false, + fieldName: this.props.step.name } render() { let { @@ -38,7 +39,6 @@ export var FormDecorator = formType => RenderField => unfolded } = this.props, { - name, possibleChoice, // should be found in the question set theoritically, but it is used for a single choice question -> the question itself is dynamic and cannot be input as code, // formerly in conversation-steps valueType, @@ -52,6 +52,8 @@ export var FormDecorator = formType => RenderField => } = this.props.step this.step = this.props.step + let {fieldName} = this.state + /* Nos propriétés personnalisées à envoyer au RenderField. Elles sont regroupées dans un objet précis pour pouvoir être enlevées des props passées à ce dernier, car React 15.2 n'aime pas les attributes inconnus @@ -63,8 +65,8 @@ export var FormDecorator = formType => RenderField => optionsURL, /* Select component's data source */ possibleChoice, /* RhetoricalQuestion component's only choice :'-( */ //TODO hack, enables redux-form/CHANGE to update the form state before the traverse functions are run - submit: () => setTimeout(() => stepAction('fold', name), 1), - setFormValue: value => setFormValue(name, value), + submit: () => setTimeout(() => stepAction('fold', fieldName), 1), + setFormValue: value => setFormValue(fieldName, value), valueType, suggestions, subquestion @@ -88,10 +90,11 @@ export var FormDecorator = formType => RenderField =>
this.setState({fieldName: name})} />
}