diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 6857eb8b6..d11b116c0 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -10,7 +10,7 @@ https://github.com/atom/atom/blob/master/CONTRIBUTING.md#git-commit-messages - đ `:green_heart:` when fixing the CI build - â `:white_check_mark:` when adding tests - âŹïž `:arrow_up:` when upgrading dependencies - +- :sparkles: `:sparkles: ` when formatting files Et ceux spĂ©cifiques au projet : - :gear: `:gear:` pour une contribution au moteur qui traite les YAML diff --git a/source/components/conversation/FormDecorator.js b/source/components/conversation/FormDecorator.js index b9a623079..0eaa1b367 100644 --- a/source/components/conversation/FormDecorator.js +++ b/source/components/conversation/FormDecorator.js @@ -1,10 +1,10 @@ import React, { Component } from 'react' import classNames from 'classnames' import { connect } from 'react-redux' -import {Field, change} from 'redux-form' -import {stepAction} from '../../actions' +import { Field, change } from 'redux-form' +import { stepAction } from '../../actions' import StepAnswer from './StepAnswer' -import {capitalise0} from '../../utils' +import { capitalise0 } from '../../utils' /* This higher order component wraps "Form" components (e.g. Question.js), that represent user inputs, @@ -15,13 +15,15 @@ to understand those precious higher order components. */ export var FormDecorator = formType => RenderField => - @connect( //... this helper directly to the redux state to avoid passing more props + @connect( + //... this helper directly to the redux state to avoid passing more props state => ({ themeColours: state.themeColours }), dispatch => ({ stepAction: (name, step) => dispatch(stepAction(name, step)), - setFormValue: (field, value) => dispatch(change('conversation', field, value)) + setFormValue: (field, value) => + dispatch(change('conversation', field, value)) }) ) class extends Component { @@ -31,29 +33,29 @@ export var FormDecorator = formType => RenderField => } render() { let { - stepAction, - themeColours, - setFormValue, - /* Une Ă©tape dĂ©jĂ rĂ©pondue est marquĂ©e 'folded'. Dans ce dernier cas, un rĂ©sumĂ© + stepAction, + themeColours, + setFormValue, + /* Une Ă©tape dĂ©jĂ rĂ©pondue est marquĂ©e 'folded'. Dans ce dernier cas, un rĂ©sumĂ© de la rĂ©ponse est affichĂ© */ - unfolded - } = this.props, + unfolded + } = this.props, { - 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, - attributes, - choices, - optionsURL, - human, - helpText, - suggestions, - subquestion, - inversions - } = this.props.step + 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, + attributes, + choices, + optionsURL, + human, + helpText, + suggestions, + subquestion, + inversions + } = this.props.step this.step = this.props.step - let {fieldName} = this.state + 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 @@ -61,10 +63,10 @@ export var FormDecorator = formType => RenderField => des balises html, dans notre cas. */ let stepProps = { - attributes, /* Input component's html attributes */ - choices, /* Question component's radio choices */ - optionsURL, /* Select component's data source */ - possibleChoice, /* RhetoricalQuestion component's only choice :'-( */ + attributes /* Input component's html attributes */, + choices /* Question component's radio choices */, + 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', fieldName), 1), setFormValue: value => setFormValue(fieldName, value), @@ -77,18 +79,25 @@ export var FormDecorator = formType => RenderField => /* There won't be any answer zone here, widen the question zone */ let wideQuestion = formType == 'rhetorical-question' && !possibleChoice - let {pre = (v => v), test, error} = valueType ? valueType.validator : {}, - validate = test && ( v => - ( v && test(pre(v)) ) ? undefined : error - ) + let { pre = v => v, test, error } = valueType ? valueType.validator : {}, + validate = test && (v => (v && test(pre(v)) ? undefined : error)) return ( -
{helpText}
) : - helpText + typeof helpText === 'string' ?{helpText}
: helpText - return