From 0bcedd702856f5ca2e141f0d608f3e45da3f4e92 Mon Sep 17 00:00:00 2001 From: mama Date: Wed, 15 Nov 2017 10:49:55 +0100 Subject: [PATCH] =?UTF-8?q?Bloc=20de=20s=C3=A9lection=20des=20objectifs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entités/ok/contrat-salarié.yaml | 4 +- source/components/Home.js | 63 ++----------------- source/components/TargetSelection.js | 50 +++++++++++++++ source/containers/Layout.js | 2 +- source/engine/traverse.js | 9 ++- 5 files changed, 66 insertions(+), 62 deletions(-) create mode 100644 source/components/TargetSelection.js diff --git a/règles/rémunération-travail/entités/ok/contrat-salarié.yaml b/règles/rémunération-travail/entités/ok/contrat-salarié.yaml index ebeab32ee..be64664fe 100644 --- a/règles/rémunération-travail/entités/ok/contrat-salarié.yaml +++ b/règles/rémunération-travail/entités/ok/contrat-salarié.yaml @@ -57,7 +57,9 @@ SMIC mi-temps: 740 inversions possibles: - - contrat salarié . salaire net + - salaire net + - salaire super brut + - coût du travail références: Le salaire. Fixation et paiement: http://travail-emploi.gouv.fr/droit-du-travail/remuneration-et-participation-financiere/remuneration/article/le-salaire-fixation-et-paiement diff --git a/source/components/Home.js b/source/components/Home.js index 8013af21b..9fe20fe91 100644 --- a/source/components/Home.js +++ b/source/components/Home.js @@ -1,17 +1,12 @@ import React, { Component } from 'react' import './Home.css' -import { Link } from 'react-router-dom' import ReactPiwik from 'Components/Tracker' //TODO réintégrer Piwik -import { rules } from 'Engine/rules' -import { propEq, reject } from 'ramda' +import TargetSelection from './TargetSelection' + + +export default class Home extends Component { -export default class HomeEmbauche extends Component { - state = { - input: 'salaire de base', - targets: ['salaire net'] - } render() { - let { targets, input } = this.state return (
@@ -23,55 +18,9 @@ export default class HomeEmbauche extends Component { />

Simulateurs d'embauche

-
-

Que voulez-vous faire ?

-

Choisissez ce que vous allez saisir

- {this.renderInputList()} -
-

Choisissez ce que nous allons calculer

- {this.renderOutputList()} - - - -
+ ) } - renderInputList() { - let salaires = rules.filter(propEq('type', 'salaire')) - return ( - - ) - } - renderOutputList() { - let salaires = rules.filter(propEq('type', 'salaire')), - { targets, input } = this.state - return ( - - ) - } + } diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js new file mode 100644 index 000000000..a923ddc68 --- /dev/null +++ b/source/components/TargetSelection.js @@ -0,0 +1,50 @@ +import React, { Component } from 'react' +import { rules } from 'Engine/rules' +import { propEq, reject } from 'ramda' +import { Link } from 'react-router-dom' + +export default class TargetSelection extends Component { + state = { + targets: ['salaire net', 'coût du travail'] + } + render() { + let { targets } = this.state + + return ( +
+

Que voulez-vous faire ?

+

Choisissez un ou plusieurs objectifs de calcul

+ {this.renderOutputList()} + {targets.length !==0 && ( + + + + )} +
+ ) + } + + renderOutputList() { + let salaires = rules.filter(propEq('type', 'salaire')), + { targets } = this.state + return ( + + ) + } +} diff --git a/source/containers/Layout.js b/source/containers/Layout.js index ff2d8911b..c57c36e41 100644 --- a/source/containers/Layout.js +++ b/source/containers/Layout.js @@ -58,7 +58,7 @@ export default class Layout extends Component { - + diff --git a/source/engine/traverse.js b/source/engine/traverse.js index 2849d47e9..341a9cdf3 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -415,7 +415,9 @@ export let findInversion = (situationGate, rules, rule) => { Ex. s'il nous est demandé de calculer le salaire de base, est-ce qu'un candidat à l'inversion, comme le salaire net, a été renseigné ? */ - let fixedObjective = inversions.find(name => situationGate(name) != undefined) //TODO ça va foirer avec des espaces de nom + let fixedObjective = inversions + .map(i => disambiguateRuleReference(rules, rule, i)) + .find(name => situationGate(name) != undefined) if (fixedObjective == null) return null //par exemple, fixedObjective = 'salaire net', et v('salaire net') == 2000 return { @@ -469,8 +471,9 @@ let doInversion = (situationGate, parsedRules, r) => { export let treatRuleRoot = (rules, rule) => { let evaluate = (situationGate, parsedRules, r) => { - let inversion = situationGate(r.dottedName) == undefined // avoid the inversion loop ! - && doInversion(situationGate, parsedRules, r) + let inversion = + situationGate(r.dottedName) == undefined && // avoid the inversion loop ! + doInversion(situationGate, parsedRules, r) if (inversion) return { ...r, ...inversion } let evolveRule = R.curry(evaluateNode)(situationGate, parsedRules),