🐛 On ne peut rentrer un brut si c'est un objectif

pull/138/head
mama 2017-11-24 11:04:29 +01:00
parent 764df500b4
commit 70b2559256
1 changed files with 20 additions and 17 deletions

View File

@ -102,6 +102,25 @@ let buildVariantTree = (allRules, path) => {
return rec(path)
}
let buildPossibleInversion = (rule, flatRules, targetNames) => {
let inversions = R.path(['formule', 'inversion', 'avec'])(rule),
inversionObjects = inversions.map(i =>
findRuleByDottedName(
flatRules,
disambiguateRuleReference(flatRules, rule, i)
)
),
yo = R.reject(({ name }) => targetNames.includes(name))([rule].concat(inversionObjects))
return (
inversions && {
inversions: yo,
question: rule.formule.inversion.question,
title: rule.formule.inversion.titre
}
)
}
export let makeQuestion = (flatRules, targetNames) => dottedName => {
let rule = findRuleByDottedName(flatRules, dottedName)
@ -113,23 +132,7 @@ export let makeQuestion = (flatRules, targetNames) => dottedName => {
placeholder: 'votre réponse'
},
suggestions: rule.suggestions,
inversion: do {
let inversions = R.path(['formule', 'inversion', 'avec'])(rule)
inversions && {
inversions: [rule].concat(
R.reject(({ name }) => targetNames.includes(name))(
inversions.map(i =>
findRuleByDottedName(
flatRules,
disambiguateRuleReference(flatRules, rule, i)
)
)
)
),
question: rule.formule.inversion.question,
title: rule.formule.inversion.titre
}
}
inversion: buildPossibleInversion(rule, flatRules, targetNames)
})
let selectQuestion = rule => ({
component: Select,