From 279c12d237ce802a1595a18849346ea3b3ea541b Mon Sep 17 00:00:00 2001 From: mama Date: Fri, 13 Oct 2017 12:02:26 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20du=20jsx=20de=20somme=20dans?= =?UTF-8?q?=20un=20nouveau=20r=C3=A9pertoire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/mecanismViews/Somme.js | 50 ++++++++++++++++++++++++++++ source/engine/mecanisms.js | 38 ++------------------- 2 files changed, 52 insertions(+), 36 deletions(-) create mode 100644 source/engine/mecanismViews/Somme.js diff --git a/source/engine/mecanismViews/Somme.js b/source/engine/mecanismViews/Somme.js new file mode 100644 index 000000000..7c973e39a --- /dev/null +++ b/source/engine/mecanismViews/Somme.js @@ -0,0 +1,50 @@ +import React, { Component } from "react" +import {makeJsx} from '../evaluation' +import {path} from 'ramda' +import {Node, NodeValue} from '../traverse-common-jsx' + + +export default class Somme extends Component { + render() { + let {explanation, nodeValue} = this.props + return + } + renderTable = explanation => ( + + + {explanation.map((v, i) => { + let rowFormula = path(["explanation", "formule", "explanation"], v), + isSomme = rowFormula && rowFormula.name == "somme" + + return [ + + + + + , + ...(isSomme + ? [ + + + + ] + : []) + ] + })} + +
+
{i != 0 && "+"}{makeJsx(v)} + +
+ + {this.renderTable(rowFormula.explanation)} +
+ ) +} diff --git a/source/engine/mecanisms.js b/source/engine/mecanisms.js index c4b5de7df..b3001e797 100644 --- a/source/engine/mecanisms.js +++ b/source/engine/mecanisms.js @@ -8,6 +8,7 @@ import {findRuleByName} from './rules' import 'react-virtualized/styles.css' import {Table, Column} from 'react-virtualized' import taux_versement_transport from 'Règles/rémunération-travail/cotisations/ok/liste-taux.json' +import Somme from './mecanismViews/Somme' let constantNode = constant => ({nodeValue: constant, jsx: nodeValue => {nodeValue}}) @@ -315,45 +316,10 @@ export let mecanismSum = (recurse,k,v) => { let evaluate = evaluateArray(R.add,0) - let renderTable = explanation => - - {explanation.map((v, i) => { - let rowFormula = R.path(['explanation', 'formule', 'explanation'], v), - isSomme = rowFormula && rowFormula.name == 'somme' - - return [ - - - - , - ... isSomme ? [ - - ] : []] - })} - -
-
{i != 0 && '+'} - {makeJsx(v)} - - -
- {renderTable(rowFormula.explanation)}
- - let jsx = (nodeValue, explanation) => ( - - ) - return { evaluate, - jsx, + jsx: (nodeValue, explanation) => , explanation, category: 'mecanism', name: 'somme',