From 75068ee582145b50c7ffb56203397161e87db30b Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 7 Sep 2018 13:15:02 +0200 Subject: [PATCH] :art: Surlignage de la variation satisfaite --- source/engine/mecanismViews/Barème.css | 3 -- source/engine/mecanismViews/Variations.css | 3 ++ source/engine/mecanismViews/Variations.js | 63 ++++++++++------------ source/engine/mecanisms.js | 2 +- 4 files changed, 31 insertions(+), 40 deletions(-) diff --git a/source/engine/mecanismViews/Barème.css b/source/engine/mecanismViews/Barème.css index 0e35ab704..39442e64c 100644 --- a/source/engine/mecanismViews/Barème.css +++ b/source/engine/mecanismViews/Barème.css @@ -27,6 +27,3 @@ .barème .tranche.activated { background: yellow !important ; } -.barème .tranche.activated:last-of-type { - background: chartreuse; -} diff --git a/source/engine/mecanismViews/Variations.css b/source/engine/mecanismViews/Variations.css index 33c0d7f0c..487c698ff 100644 --- a/source/engine/mecanismViews/Variations.css +++ b/source/engine/mecanismViews/Variations.css @@ -5,3 +5,6 @@ margin-bottom: 1em; list-style: circle; } +.variations > ul > li.satisfied .consequence { + background: yellow; +} diff --git a/source/engine/mecanismViews/Variations.js b/source/engine/mecanismViews/Variations.js index d95a95f95..baccde14a 100644 --- a/source/engine/mecanismViews/Variations.js +++ b/source/engine/mecanismViews/Variations.js @@ -2,44 +2,35 @@ import React from 'react' import { Node } from './common' import { makeJsx } from '../evaluation' import './Variations.css' -import { ShowValuesConsumer } from 'Components/rule/ShowValuesContext' +import classNames from 'classnames' export default function Variations(nodeValue, explanation) { return ( - - {showValues => ( - - {explanation.map( - c => - console.log('c', c) || ( -
  • -
    - {c.condition && ( - <> - Si {makeJsx(c.condition)} - - )} -
    - {c.condition ? 'Alors : ' : 'Sinon : '} - - {makeJsx(c.consequence)} - -
    -
    -
  • - ) - )} - - } - /> - )} -
    + + {explanation.map(({ condition, consequence, satisfied }) => ( +
  • +
    + {condition && ( + <> + Si {makeJsx(condition)} + + )} +
    + {condition ? 'Alors : ' : 'Sinon : '} + {makeJsx(consequence)} +
    +
    +
  • + ))} + + } + /> ) } diff --git a/source/engine/mecanisms.js b/source/engine/mecanisms.js index 3cc9b057e..2bb6a768d 100644 --- a/source/engine/mecanisms.js +++ b/source/engine/mecanisms.js @@ -193,7 +193,7 @@ export let mecanismVariations = (recurse, k, v, devariate) => { rightMissing = mergeAllMissing(pluck('consequence', candidateVariations)), missingVariables = mergeMissing(bonus(leftMissing), rightMissing) - return rewriteNode(node, nodeValue, evaluatedExplanation, missingVariables) + return rewriteNode(node, nodeValue, resolvedExplanation, missingVariables) } // TODO - find an appropriate representation