demo-contrôles
parent
32fa9b3459
commit
060cb43de0
|
@ -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')
|
||||
|
|
|
@ -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 (
|
||||
<Spring
|
||||
to={{
|
||||
|
@ -67,7 +67,7 @@ export default (compose(
|
|||
connect(
|
||||
(state, props) => ({
|
||||
key: props.language,
|
||||
validInputEntered: validInputEnteredSelector(state),
|
||||
userInput: !noUserInputSelector(state),
|
||||
conversationStarted: state.conversationStarted,
|
||||
quickLinks: state.simulation?.config["questions à l'affiche"]
|
||||
}),
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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(
|
|||
<div id="targetSelection">
|
||||
<QuickLinks />
|
||||
<Controls controls={analysis.controls} />
|
||||
<div style={{height: '10px'}}><Progress percent={progress}/></div>
|
||||
<div style={{ height: '10px' }}>
|
||||
<Progress percent={progress} />
|
||||
</div>
|
||||
<section
|
||||
className="ui__ plain card"
|
||||
style={{
|
||||
|
@ -95,7 +95,6 @@ export default compose(
|
|||
setActiveInput,
|
||||
analysis,
|
||||
noUserInput,
|
||||
blockingInputControls,
|
||||
match
|
||||
} = this.props,
|
||||
targets = analysis ? analysis.targets : []
|
||||
|
@ -111,8 +110,7 @@ export default compose(
|
|||
match,
|
||||
target,
|
||||
conversationStarted,
|
||||
isActiveInput: activeInput === target.dottedName,
|
||||
blockingInputControls
|
||||
isActiveInput: activeInput === target.dottedName
|
||||
}}
|
||||
/>
|
||||
<TargetInputOrValue
|
||||
|
@ -122,8 +120,7 @@ export default compose(
|
|||
activeInput,
|
||||
setActiveInput,
|
||||
setFormValue: this.props.setFormValue,
|
||||
noUserInput,
|
||||
blockingInputControls
|
||||
noUserInput
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -179,15 +176,7 @@ let CurrencyField = withColours(props => {
|
|||
})
|
||||
|
||||
let TargetInputOrValue = withLanguage(
|
||||
({
|
||||
target,
|
||||
targets,
|
||||
activeInput,
|
||||
setActiveInput,
|
||||
language,
|
||||
noUserInput,
|
||||
blockingInputControls
|
||||
}) => (
|
||||
({ target, targets, activeInput, setActiveInput, language, noUserInput }) => (
|
||||
<span className="targetInputOrValue">
|
||||
{activeInput === target.dottedName ? (
|
||||
<Field
|
||||
|
@ -202,8 +191,7 @@ let TargetInputOrValue = withLanguage(
|
|||
target,
|
||||
activeInput,
|
||||
setActiveInput,
|
||||
noUserInput,
|
||||
blockingInputControls
|
||||
noUserInput
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
@ -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(
|
|||
<div
|
||||
className={classNames({
|
||||
editable: target.question,
|
||||
attractClick:
|
||||
target.question && (noUserInput || blockingInputControls)
|
||||
attractClick: target.question && noUserInput
|
||||
})}
|
||||
tabIndex="0"
|
||||
onClick={this.showField(value)}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* @flow */
|
||||
import { createSelector, createStructuredSelector } from 'reselect'
|
||||
import {
|
||||
blockingInputControlsSelector,
|
||||
nextStepsSelector,
|
||||
noUserInputSelector
|
||||
} from 'Selectors/analyseSelectors'
|
||||
|
@ -45,10 +44,7 @@ const NUMBER_MAX_QUESTION_SIMULATION = 18
|
|||
const START_SIMULATION_COEFFICIENT = 0.15
|
||||
const QUESTIONS_COEFFICIENT = 0.85
|
||||
export const estimationProgressSelector = (state: any) => {
|
||||
const userInputProgress = +(
|
||||
!noUserInputSelector(state) &&
|
||||
!softCatch(blockingInputControlsSelector)(state)
|
||||
)
|
||||
const userInputProgress = !noUserInputSelector(state)
|
||||
const questionsProgress =
|
||||
(state.conversationStarted &&
|
||||
NUMBER_MAX_QUESTION_SIMULATION - nextStepsSelector(state).length) /
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue