From 3854666a9024f1590305797b667596bc042e7b57 Mon Sep 17 00:00:00 2001 From: Mael Date: Mon, 11 Jun 2018 17:59:50 +0200 Subject: [PATCH] :sparkles: Extraction de FoldedStep depuis FormDecorator --- source/components/Simu.js | 2 +- .../components/conversation/Conversation.js | 5 +- source/components/conversation/FoldedStep.js | 48 ++++++++ source/components/conversation/FoldedSteps.js | 33 +++--- .../components/conversation/FormDecorator.js | 108 +++++------------- source/engine/generateQuestions.js | 18 +-- source/selectors/analyseSelectors.js | 2 +- 7 files changed, 99 insertions(+), 117 deletions(-) create mode 100644 source/components/conversation/FoldedStep.js diff --git a/source/components/Simu.js b/source/components/Simu.js index cac929c1e..57d92989d 100644 --- a/source/components/Simu.js +++ b/source/components/Simu.js @@ -23,8 +23,8 @@ export default class Simu extends Component { return (
- {/**/}
+ {/**/} {conversationStarted && ( diff --git a/source/components/conversation/Conversation.js b/source/components/conversation/Conversation.js index 6ce897551..4445cc3fe 100644 --- a/source/components/conversation/Conversation.js +++ b/source/components/conversation/Conversation.js @@ -1,6 +1,5 @@ import React, { Component } from 'react' import { translate } from 'react-i18next' -import { pick } from 'ramda' import Aide from '../Aide' import { reduxForm } from 'redux-form' import { getInputComponent } from 'Engine/generateQuestions' @@ -33,9 +32,7 @@ export default class Conversation extends Component {
{currentQuestion && - getInputComponent({ unfolded: true })(flatRules, targetNames)( - currentQuestion - )} + getInputComponent(flatRules, targetNames)(currentQuestion)}
) diff --git a/source/components/conversation/FoldedStep.js b/source/components/conversation/FoldedStep.js new file mode 100644 index 000000000..f5d0e9840 --- /dev/null +++ b/source/components/conversation/FoldedStep.js @@ -0,0 +1,48 @@ +import React from 'react' +import { findRuleByDottedName } from 'Engine/rules' +import { capitalise0 } from '../../utils' +import { connect } from 'react-redux' +import { Trans, translate } from 'react-i18next' +import { + flatRulesSelector, + validatedSituationSelector +} from 'Selectors/analyseSelectors' +import { stepAction } from '../../actions' +import { LinkButton } from 'Components/ui/Button' + +@translate() +@connect( + state => ({ + flatRules: flatRulesSelector(state), + situation: validatedSituationSelector(state) + }), + dispatch => ({ + stepAction: (name, step, source) => dispatch(stepAction(name, step, source)) + }) +) +export default class FoldedStep extends React.Component { + render() { + let { stepAction, dottedName, flatRules, t, situation } = this.props + let { title } = findRuleByDottedName(flatRules, dottedName), + answer = situation[dottedName], + eventualEnumAnswerRule = findRuleByDottedName( + flatRules, + dottedName + ' . ' + answer + ), + translatedAnswer = + (eventualEnumAnswerRule && eventualEnumAnswerRule.title) || t(answer) + + return ( +
+ + {capitalise0(title)} + {translatedAnswer} + + stepAction('unfold', dottedName, 'unfold')}> +