🐛 fix la possibilité d'avoir choix obligatoire = non pour le mécanisme une possibilité

pull/1291/head
Johan Girod 2020-12-09 17:41:29 +01:00
parent 0535e67fe5
commit 1a628879a2
2 changed files with 5 additions and 2 deletions

View File

@ -87,6 +87,7 @@ export default function RuleInput<Name extends string = DottedName>({
required: true,
}
if (getVariant(engine.getParsedRules()[dottedName])) {
console.log(buildVariantTree(engine.getParsedRules(), dottedName))
return (
<Question
{...commonProps}
@ -200,7 +201,9 @@ export const buildVariantTree = <Name extends string>(
const node = allRules[path]
if (!node) throw new Error(`La règle ${path} est introuvable`)
const variant = getVariant(node)
const canGiveUp = variant && !variant['choix obligatoire']
const canGiveUp =
variant &&
(!variant['choix obligatoire'] || variant['choix obligatoire'] === 'non')
return Object.assign(
node,
variant

View File

@ -5,7 +5,7 @@ import { Context } from '../parsePublicodes'
export type PossibilityNode = {
explanation: Array<ASTNode>
'choix obligatoire'?: 'oui'
'choix obligatoire'?: 'oui' | 'non'
context: string
nodeKind: 'une possibilité'
}