Affichage du bon nom de salaire entré dans foldedSteps

Mais pas encore de la valeur
pull/138/head
mama 2017-11-21 10:06:30 +01:00
parent e9207e3276
commit 4fd5d57a24
4 changed files with 36 additions and 34 deletions

View File

@ -97,7 +97,7 @@ export default class extends Component {
)
}
buildStep = ({ unfolded }) => (accessor, targetNames) => question => {
buildStep = ({ unfolded }) => (situationGate, targetNames) => question => {
let step = makeQuestion(rules, targetNames)(question)
return (
<step.component
@ -105,7 +105,7 @@ export default class extends Component {
{...step}
unfolded={unfolded}
step={step}
answer={accessor(step.name)}
situationGate={situationGate}
/>
)
}

View File

@ -5,7 +5,7 @@ import { Field, change } from 'redux-form'
import { stepAction } from '../../actions'
import StepAnswer from './StepAnswer'
import { capitalise0 } from '../../utils'
import R from 'ramda'
/*
This higher order component wraps "Form" components (e.g. Question.js), that represent user inputs,
with a header, click actions and more goodies.
@ -45,7 +45,8 @@ export var FormDecorator = formType => RenderField =>
// formerly in conversation-steps
valueType,
human,
helpText
helpText,
situationGate
} = this.props.step
let { fieldName } = this.state
@ -123,7 +124,8 @@ export var FormDecorator = formType => RenderField =>
maxWidth: wideQuestion ? '95%' : ''
}}
>
{this.props.step.question}
{R.path(['props', 'step', 'inversion', 'question'])(this) ||
this.props.step.question}
</h1>
<div
className="step-subquestion"
@ -133,17 +135,13 @@ export var FormDecorator = formType => RenderField =>
)
renderTitleAndAnswer(valueType, human) {
let {
stepAction,
answer,
themeColours,
step: { title }
} = this.props
let { step, stepAction, situationGate, themeColours, step: { title } } = this.props
let inversionTitle = R.path(['props', 'step', 'inversion', 'title'])(this)
let answer = situationGate(this.state.fieldName)
return (
<div className="foldedQuestion">
<span className="borderWrapper">
<span className="title">{capitalise0(title)}</span>
<span className="title">{capitalise0(inversionTitle || title)}</span>
<span className="answer">{answer}</span>
</span>
<button

View File

@ -79,24 +79,24 @@ export default class Input extends Component {
)
}
componentDidMount() {
let { stepProps: { inversions } } = this.props
if (inversions)
this.inverse(inversions[0].dottedName)
let { stepProps: { inversion } } = this.props
if (inversion)
this.inverse(inversion.inversions[0].dottedName)
}
renderInversions() {
let { stepProps: { inversions } } = this.props
if (!inversions) return null
let { stepProps: { inversion } } = this.props
if (!inversion) return null
if (inversions.length === 1) return (
<span className="inputPrefix">{inversions[0].title || inversions[0].name}</span>
if (inversion.inversions.length === 1) return (
<span className="inputPrefix">{inversion.inversions[0].title || inversion.inversions[0].name}</span>
)
return (
<select
defaultValue={inversions[0].dottedName}
defaultValue={inversion.inversions[0].dottedName}
onMouseDown={e => this.inverse(e.target.value)}
>
{inversions.map(({ name, title, dottedName }) => (
{inversion.inversions.map(({ name, title, dottedName }) => (
<option key={dottedName} value={dottedName}>
{title || name}
</option>
@ -105,6 +105,7 @@ export default class Input extends Component {
)
}
inverse(inversionName) {
console.log('inversion, ', inversionName)
this.props.changeFieldName(inversionName)
}
renderSuggestions(themeColours) {

View File

@ -113,19 +113,22 @@ export let makeQuestion = (flatRules, targetNames) => dottedName => {
placeholder: 'votre réponse'
},
suggestions: rule.suggestions,
inversions: do {
inversion: do {
let inversions = R.path(['formule', 'inversion', 'avec'])(rule)
inversions &&
R.reject(
({name}) => targetNames.includes(name)
)(inversions
.map(i =>
findRuleByDottedName(
flatRules,
disambiguateRuleReference(flatRules, rule, i)
)
)
.concat([rule]))
inversions && {
inversions: R.reject(({ name }) => targetNames.includes(name))(
inversions
.map(i =>
findRuleByDottedName(
flatRules,
disambiguateRuleReference(flatRules, rule, i)
)
)
.concat([rule])
),
question: rule.formule.inversion.question,
title: rule.formule.inversion.titre
}
}
})
let selectQuestion = rule => ({