diff --git a/source/components/Simu.js b/source/components/Simu.js index b616f8d13..091336a5e 100644 --- a/source/components/Simu.js +++ b/source/components/Simu.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import { noUserInputSelector, - analysisWithDefaultsSelector + blockingInputControlsSelector } from 'Selectors/analyseSelectors' import Conversation from './conversation/Conversation' import FoldedSteps, { GoToAnswers } from './conversation/FoldedSteps' @@ -17,7 +17,7 @@ import withColours from './withColours' @withColours @connect(state => ({ noUserInput: noUserInputSelector(state), - analysis: analysisWithDefaultsSelector(state), + blockingInputControls: blockingInputControlsSelector(state), conversationStarted: state.conversationStarted })) export default class Simu extends Component { @@ -26,7 +26,7 @@ export default class Simu extends Component { colours, conversationStarted, noUserInput, - analysis: { blockingInputControls } + blockingInputControls } = this.props return ( diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index dbb4c7b19..1f8a9b2c6 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -10,7 +10,8 @@ import { change, Field, formValueSelector, reduxForm } from 'redux-form' import { analysisWithDefaultsSelector, flatRulesSelector, - noUserInputSelector + noUserInputSelector, + blockingInputControlsSelector } from 'Selectors/analyseSelectors' import BlueButton from './BlueButton' import CurrencyInput from './CurrencyInput/CurrencyInput' @@ -42,6 +43,7 @@ export let popularTargetNames = [ getTargetValue: dottedName => formValueSelector('conversation')(state, dottedName), analysis: analysisWithDefaultsSelector(state), + blockingInputControls: blockingInputControlsSelector(state), flatRules: flatRulesSelector(state), noUserInput: noUserInputSelector(state), conversationStarted: state.conversationStarted, @@ -56,7 +58,12 @@ export let popularTargetNames = [ ) export default class TargetSelection extends Component { render() { - let { conversationStarted, colours, noUserInput, analysis } = this.props + let { + conversationStarted, + colours, + noUserInput, + blockingInputControls + } = this.props return (
)} - {analysis && - analysis.blockingInputControls && ( - - )} + {blockingInputControls && ( + + )} {!noUserInput && - !(analysis && analysis.blockingInputControls) && + !blockingInputControls && !conversationStarted && (

@@ -105,7 +111,8 @@ export default class TargetSelection extends Component { activeInput, setActiveInput, analysis, - noUserInput + noUserInput, + blockingInputControls } = this.props, targets = analysis ? analysis.targets : [] @@ -130,8 +137,7 @@ export default class TargetSelection extends Component { setActiveInput, setFormValue: this.props.setFormValue, noUserInput, - blockingInputControls: - analysis && analysis.blockingInputControls + blockingInputControls }} />

diff --git a/source/engine/traverse.js b/source/engine/traverse.js index 33a2dcd56..a1b153f64 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -16,8 +16,7 @@ import { merge, keys, is, - T, - hasProp + T } from 'ramda' import { Node } from './mecanismViews/common' import { @@ -208,12 +207,14 @@ export let treatRuleRoot = (rules, rule) => { node.category === 'variable' && node.dottedName !== rule.dottedName ) + let isInputControl = !otherVariables.length + return { level: control['niveau'], test: control['si'], message: control['message'], testExpression, - ...(!otherVariables.length ? { isInputControl: true } : {}) + isInputControl } }) diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js index e8cbab5b3..7225b0bf1 100644 --- a/source/selectors/analyseSelectors.js +++ b/source/selectors/analyseSelectors.js @@ -130,6 +130,11 @@ let analysisValidatedOnlySelector = makeAnalysisSelector( validatedSituationSelector ) +export let blockingInputControlsSelector = state => { + let analysis = analysisWithDefaultsSelector(state) + return analysis && analysis.blockingInputControls +} + // TODO this should really not be fired twice in a user session... // // TODO the just input salary should be in the situation so that it is not a missing variable