diff --git a/source/components/ComparativeTargets.js b/source/components/ComparativeTargets.js index 7645a41b9..7ae28a39c 100644 --- a/source/components/ComparativeTargets.js +++ b/source/components/ComparativeTargets.js @@ -18,7 +18,7 @@ import { } from 'Selectors/regleSelectors' import Animate from 'Ui/animate' import Montant from 'Ui/Montant' -import { validInputEnteredSelector } from '../selectors/analyseSelectors' +import { noUserInputSelector } from '../selectors/analyseSelectors' import './ComparativeTargets.css' import SchemeCard from './ui/SchemeCard' import type { @@ -33,12 +33,12 @@ const connectRègles = (situationBranchName: string) => state => { return ({ revenuDisponible: - validInputEnteredSelector(state) && + !noUserInputSelector(state) && règleAvecMontantSelector(state, { situationBranchName })('revenu disponible'), prélèvements: - validInputEnteredSelector(state) && + !noUserInputSelector(state) && règleAvecValeurSelector(state, { situationBranchName })('ratio de prélèvements') diff --git a/source/components/QuickLinks.js b/source/components/QuickLinks.js index 661ef34fb..04d5a1284 100644 --- a/source/components/QuickLinks.js +++ b/source/components/QuickLinks.js @@ -1,32 +1,32 @@ /* @flow */ -import { startConversation } from 'Actions/actions'; -import withLanguage from 'Components/utils/withLanguage'; -import { compose, toPairs } from 'ramda'; -import React from 'react'; -import { Trans } from 'react-i18next'; -import { connect } from 'react-redux'; -import { withRouter } from 'react-router'; -import { animated, Spring } from 'react-spring'; -import { validInputEnteredSelector } from 'Selectors/analyseSelectors'; +import { startConversation } from 'Actions/actions' +import withLanguage from 'Components/utils/withLanguage' +import { compose, toPairs } from 'ramda' +import React from 'react' +import { Trans } from 'react-i18next' +import { connect } from 'react-redux' +import { withRouter } from 'react-router' +import { animated, Spring } from 'react-spring' +import { noUserInputSelector } from 'Selectors/analyseSelectors' import type { Location } from 'react-router' type OwnProps = { - quickLinks: {[string]: string}, + quickLinks: { [string]: string } } type Props = OwnProps & { startConversation: (?string) => void, location: Location, - validInputEntered: boolean, + userInput: boolean, conversationStarted: boolean } const QuickLinks = ({ startConversation, - validInputEntered, + userInput, quickLinks, conversationStarted }: Props) => { - const show = validInputEntered && !conversationStarted + const show = userInput && !conversationStarted return ( ({ key: props.language, - validInputEntered: validInputEnteredSelector(state), + userInput: !noUserInputSelector(state), conversationStarted: state.conversationStarted, quickLinks: state.simulation?.config["questions à l'affiche"] }), diff --git a/source/components/Simulation.js b/source/components/Simulation.js index 84a7b3a90..8e3bb4b27 100644 --- a/source/components/Simulation.js +++ b/source/components/Simulation.js @@ -1,12 +1,16 @@ -import { resetSimulation } from 'Actions/actions'; -import { React, T } from 'Components'; -import Answers from 'Components/AnswerList'; -import Conversation from 'Components/conversation/Conversation'; -import withColours from 'Components/utils/withColours'; -import { compose } from 'ramda'; -import { connect } from 'react-redux'; -import { blockingInputControlsSelector, nextStepsSelector, noUserInputSelector, validInputEnteredSelector } from 'Selectors/analyseSelectors'; -import Animate from 'Ui/animate'; +import { resetSimulation } from 'Actions/actions' +import { React, T } from 'Components' +import Answers from 'Components/AnswerList' +import Conversation from 'Components/conversation/Conversation' +import withColours from 'Components/utils/withColours' +import { compose } from 'ramda' +import { connect } from 'react-redux' +import { + nextStepsSelector, + noUserInputSelector, + noUserInputSelector +} from 'Selectors/analyseSelectors' +import Animate from 'Ui/animate' export default compose( withColours, @@ -15,12 +19,9 @@ export default compose( conversationStarted: state.conversationStarted, previousAnswers: state.conversationSteps.foldedSteps, noNextSteps: - state.conversationStarted && - !blockingInputControlsSelector(state) && - nextStepsSelector(state).length == 0, + state.conversationStarted && nextStepsSelector(state).length == 0, noUserInput: noUserInputSelector(state), - blockingInputControls: blockingInputControlsSelector(state), - validInputEntered: validInputEnteredSelector(state) + userInput: !noUserInputSelector(state) }), { resetSimulation } ) @@ -36,14 +37,12 @@ export default compose( noUserInput, conversationStarted, resetSimulation, - blockingInputControls, showTargetsAnyway, targetsTriggerConversation } = this.props let arePreviousAnswers = previousAnswers.length > 0, displayConversation = - (!targetsTriggerConversation || conversationStarted) && - !blockingInputControls, + !targetsTriggerConversation || conversationStarted, showTargets = targetsTriggerConversation || !noUserInput || showTargetsAnyway return ( diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index c63ff6caf..8b6d21afa 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -15,7 +15,6 @@ import { Link } from 'react-router-dom' import { change, Field, formValueSelector, reduxForm } from 'redux-form' import { analysisWithDefaultsSelector, - blockingInputControlsSelector, flatRulesSelector, nextStepsSelector, noUserInputSelector @@ -41,7 +40,6 @@ export default compose( getTargetValue: dottedName => formValueSelector('conversation')(state, dottedName), analysis: analysisWithDefaultsSelector(state), - blockingInputControls: blockingInputControlsSelector(state), flatRules: flatRulesSelector(state), progress: (100 * (MAX_NUMBER_QUESTION - nextStepsSelector(state))) / @@ -67,7 +65,9 @@ export default compose(
-
+
+ +
@@ -179,15 +176,7 @@ let CurrencyField = withColours(props => { }) let TargetInputOrValue = withLanguage( - ({ - target, - targets, - activeInput, - setActiveInput, - language, - noUserInput, - blockingInputControls - }) => ( + ({ target, targets, activeInput, setActiveInput, language, noUserInput }) => ( {activeInput === target.dottedName ? ( )} @@ -219,7 +207,7 @@ const TargetValue = connect( )( class TargetValue extends Component { render() { - let { targets, target, noUserInput, blockingInputControls } = this.props + let { targets, target, noUserInput } = this.props let targetWithValue = targets && targets.find(propEq('dottedName', target.dottedName)), @@ -229,8 +217,7 @@ const TargetValue = connect(
{ - const userInputProgress = +( - !noUserInputSelector(state) && - !softCatch(blockingInputControlsSelector)(state) - ) + const userInputProgress = !noUserInputSelector(state) const questionsProgress = (state.conversationStarted && NUMBER_MAX_QUESTION_SIMULATION - nextStepsSelector(state).length) / diff --git a/test/contrôles.test.js b/test/contrôles.test.js index 7a160f573..c7a9f596b 100644 --- a/test/contrôles.test.js +++ b/test/contrôles.test.js @@ -49,31 +49,6 @@ describe('controls', function() { rules = rawRules.map(enrichRule), parsedRules = parseAll(rules) - it('Should parse blocking controls', function() { - let controls = parsedRules.find(r => r.controls).controls - expect( - controls.filter( - ({ level, isInputControl }) => level == 'bloquant' && isInputControl - ) - ).to.have.lengthOf(2) - }) - - it('Should block the engine evaluation if blocking input controls trigger', function() { - let situationGate = dottedName => ({ brut: 400 }[dottedName]), - { blockingInputControls } = analyseMany(parsedRules, ['net'])( - situationGate - ) - - expect(blockingInputControls).to.have.lengthOf(1) - }) - it('Should not block the engine evaluation if no blocking input controls trigger', function() { - let situationGate = dottedName => ({ brut: 1200 }[dottedName]), - { blockingInputControls } = analyseMany(parsedRules, ['net'])( - situationGate - ) - - expect(blockingInputControls).to.be.undefined - }) it('Should allow imbricated conditions', function() { let situationGate = dottedName => ({ brut: 2000000 }[dottedName]), { controls } = analyseMany(parsedRules, ['net'])(situationGate)