diff --git a/source/components/Controls.css b/source/components/Controls.css new file mode 100644 index 000000000..e3ceef793 --- /dev/null +++ b/source/components/Controls.css @@ -0,0 +1,4 @@ +.controls { + text-align: center; + font-size: 150%; +} diff --git a/source/components/Controls.js b/source/components/Controls.js new file mode 100644 index 000000000..69735fba1 --- /dev/null +++ b/source/components/Controls.js @@ -0,0 +1,6 @@ +import React from 'react' +import './Controls.css' + +export default ({ blockingInputControls }) => ( +

{blockingInputControls[0].message}

+) diff --git a/source/components/Simu.js b/source/components/Simu.js index 05f1452e9..b616f8d13 100644 --- a/source/components/Simu.js +++ b/source/components/Simu.js @@ -1,6 +1,9 @@ import React, { Component } from 'react' import { connect } from 'react-redux' -import { noUserInputSelector } from 'Selectors/analyseSelectors' +import { + noUserInputSelector, + analysisWithDefaultsSelector +} from 'Selectors/analyseSelectors' import Conversation from './conversation/Conversation' import FoldedSteps, { GoToAnswers } from './conversation/FoldedSteps' import GoToExplanations from './GoToExplanations' @@ -14,11 +17,17 @@ import withColours from './withColours' @withColours @connect(state => ({ noUserInput: noUserInputSelector(state), + analysis: analysisWithDefaultsSelector(state), conversationStarted: state.conversationStarted })) export default class Simu extends Component { render() { - let { colours, conversationStarted, noUserInput } = this.props + let { + colours, + conversationStarted, + noUserInput, + analysis: { blockingInputControls } + } = this.props return (
@@ -32,10 +41,10 @@ export default class Simu extends Component { )} - {!noUserInput && } + {!noUserInput && !blockingInputControls && }
- {!noUserInput && } - + {!noUserInput && !blockingInputControls && } + {!blockingInputControls && } ) } diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index e378016f8..dbb4c7b19 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -18,6 +18,7 @@ import ProgressCircle from './ProgressCircle/ProgressCircle' import { RuleValue } from './rule/RuleValueVignette' import './TargetSelection.css' import withLanguage from './withLanguage' +import Controls from './Controls' let salaries = [ 'contrat salarié . salaire . total', @@ -55,7 +56,7 @@ export let popularTargetNames = [ ) export default class TargetSelection extends Component { render() { - let { conversationStarted, colours, noUserInput } = this.props + let { conversationStarted, colours, noUserInput, analysis } = this.props return (
{noUserInput && ( -

+

Entrez un salaire mensuel -

+

)} + {analysis && + analysis.blockingInputControls && ( + + )} + {!noUserInput && + !(analysis && analysis.blockingInputControls) && !conversationStarted && (

@@ -122,7 +129,9 @@ export default class TargetSelection extends Component { activeInput, setActiveInput, setFormValue: this.props.setFormValue, - noUserInput + noUserInput, + blockingInputControls: + analysis && analysis.blockingInputControls }} />

@@ -175,7 +184,15 @@ let CurrencyField = props => { } let TargetInputOrValue = withLanguage( - ({ target, targets, activeInput, setActiveInput, language, noUserInput }) => ( + ({ + target, + targets, + activeInput, + setActiveInput, + language, + noUserInput, + blockingInputControls + }) => ( {activeInput === target.dottedName ? ( ) : ( )} @@ -200,28 +224,32 @@ let TargetInputOrValue = withLanguage( class TargetValue extends Component { render() { let { - targets, - target, - setFormValue, - activeInput, - setActiveInput, - noUserInput - } = this.props, - targetWithValue = targets.find(propEq('dottedName', target.dottedName)), + targets, + target, + setFormValue, + activeInput, + setActiveInput, + noUserInput, + blockingInputControls + } = this.props + + let targetWithValue = + targets && targets.find(propEq('dottedName', target.dottedName)), value = targetWithValue && targetWithValue.nodeValue return ( { if (!target.question) return - if (value != null) { + if (value != null) setFormValue(target.dottedName, Math.floor(value) + '') - setFormValue(activeInput, '') - } + + if (activeInput) setFormValue(activeInput, '') setActiveInput(target.dottedName) }}> diff --git a/source/engine/traverse.js b/source/engine/traverse.js index 5e3286a03..33a2dcd56 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -194,10 +194,6 @@ export let treatRuleRoot = (rules, rule) => { } })(rule) - // let evaluateControl = () => { - //evaluate with situation - //return message or null - //} let controls = rule['contrôles'] && rule['contrôles'].map(control => { @@ -215,6 +211,7 @@ export let treatRuleRoot = (rules, rule) => { return { level: control['niveau'], test: control['si'], + message: control['message'], testExpression, ...(!otherVariables.length ? { isInputControl: true } : {}) } diff --git a/source/règles/base.yaml b/source/règles/base.yaml index acef1ec75..ec5f91615 100644 --- a/source/règles/base.yaml +++ b/source/règles/base.yaml @@ -677,12 +677,12 @@ salaire médian: 2300 SMIC: 1500 contrôles: + - si: brut de base < 300 + message: Entrez un salaire mensuel + niveau: bloquant # - si: brut de base < smic mensuel # message: Le salaire saisi semble inférieur au SMIC. # niveau: avertissement - - si: brut de base < 200 - message: Le simulateur ne prend pour l'instant que des salaires mensuels - niveau: bloquant - si: brut de base > 100000 message: N'avez-vous pas saisi un zéro de trop ? niveau: information @@ -865,6 +865,10 @@ description: | C'est le montant que le salarié touche à la fin du mois. formule: salaire . net - avantages en nature . montant + contrôles: + - si: net à payer < 200 + message: Entrez un salaire mensuel + niveau: bloquant - espace: contrat salarié nom: coût du travail @@ -891,6 +895,10 @@ Des [aides différées](/règle/aides employeur) peuvent venir diminuer ce montant. formule: salaire . total sans réduction - réductions de cotisations + contrôles: + - si: total < 400 + message: Entrez un salaire mensuel + niveau: bloquant - espace: contrat salarié nom: réductions de cotisations