From dd8c5f89cfb910c21d9cfc48c3c9ebd55faed8f7 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 10 Jan 2019 15:07:47 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20les=20simulateurs=20indidividue?= =?UTF-8?q?ls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/components/ComparativeTargets.css | 9 +++-- source/components/SimpleSimulation.js | 3 +- source/components/TargetSelection.js | 35 +++++++++++++++---- .../simulationConfigs/assimilé.yaml | 1 - .../simulationConfigs/indépendant.yaml | 4 +-- .../rémunération-dirigeant.yaml | 1 + source/selectors/analyseSelectors.js | 11 ++++-- .../pages/SocialSecurity/AssimiléSalarié.js | 2 +- .../pages/SocialSecurity/Indépendant.js | 2 +- .../pages/SocialSecurity/MicroEntreprise.js | 2 +- 10 files changed, 48 insertions(+), 22 deletions(-) diff --git a/source/components/ComparativeTargets.css b/source/components/ComparativeTargets.css index 1d50d2ed2..780e59226 100644 --- a/source/components/ComparativeTargets.css +++ b/source/components/ComparativeTargets.css @@ -5,17 +5,16 @@ flex-wrap: wrap; } #comparative-targets ul { - width: 100%; + padding: 0; display: flex; justify-content: space-around; - /* align-items: center; */ flex-wrap: wrap; } #comparative-targets li { - margin: 1em; + margin: 0.8rem; background: var(--colour); - padding: 1em; - width: 12em; + padding: 1rem; + width: 12rem; display: flex; flex-direction: column; justify-content: space-between; diff --git a/source/components/SimpleSimulation.js b/source/components/SimpleSimulation.js index 2e96c9cd3..b33f905d6 100644 --- a/source/components/SimpleSimulation.js +++ b/source/components/SimpleSimulation.js @@ -46,8 +46,7 @@ export default compose(

Vous avez atteint l'estimation la plus précise.

)} - - {!noUserInput && {children}} + {!noUserInput && {children}} ) } diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index 290b5c502..144f54650 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -16,7 +16,8 @@ import { analysisWithDefaultsSelector, blockingInputControlsSelector, flatRulesSelector, - noUserInputSelector + noUserInputSelector, + situationBranchesSelector } from 'Selectors/analyseSelectors' import { normalizeBasePath } from '../utils' import AnimatedTargetValue from './AnimatedTargetValue' @@ -85,7 +86,8 @@ export default compose( analysis, noUserInput, blockingInputControls, - match + match, + keepFormValues } = this.props, targets = analysis ? analysis.targets : [] @@ -107,11 +109,13 @@ export default compose( @@ -185,6 +189,7 @@ let TargetInputOrValue = withLanguage( setActiveInput, language, noUserInput, + keepFormValues, blockingInputControls }) => ( @@ -201,6 +206,7 @@ let TargetInputOrValue = withLanguage( target, activeInput, setActiveInput, + keepFormValues, noUserInput, blockingInputControls }} @@ -212,17 +218,26 @@ let TargetInputOrValue = withLanguage( ) const TargetValue = connect( - null, + state => ({ situation: situationBranchesSelector(state) }), dispatch => ({ setFormValue: (field, name) => dispatch(change('conversation', field, name)) }) )( class TargetValue extends Component { render() { - let { targets, target, noUserInput, blockingInputControls } = this.props + let { + targets, + target, + noUserInput, + blockingInputControls, + situation + } = this.props let targetWithValue = targets && targets.find(propEq('dottedName', target.dottedName)), - value = targetWithValue && targetWithValue.nodeValue + value = + situation[target.dottedName] || + (targetWithValue && targetWithValue.nodeValue) + console.log(target.dottedName, situation[target.dottedName]) return (
{ if (!target.question) return if (value != null) setFormValue(target.dottedName, Math.floor(value) + '') - if (activeInput) setFormValue(activeInput, '') + if (activeInput && !keepFormValues) setFormValue(activeInput, '') setActiveInput(target.dottedName) } } diff --git a/source/components/simulationConfigs/assimilé.yaml b/source/components/simulationConfigs/assimilé.yaml index 394695dcf..e82182c1d 100644 --- a/source/components/simulationConfigs/assimilé.yaml +++ b/source/components/simulationConfigs/assimilé.yaml @@ -8,7 +8,6 @@ objectifs: - entreprise . chiffre d'affaires - entreprise . charges - revenu disponible - situation: micro entreprise: non indépendant: non diff --git a/source/components/simulationConfigs/indépendant.yaml b/source/components/simulationConfigs/indépendant.yaml index 0ac32c020..8f47fbb1a 100644 --- a/source/components/simulationConfigs/indépendant.yaml +++ b/source/components/simulationConfigs/indépendant.yaml @@ -5,9 +5,9 @@ titre: | - L'impôt sur le revenu est calculé pour un célibataire sans enfants et sans autre revenu. objectifs: - - entreprise . rémunération totale du dirigeant + - entreprise . chiffre d'affaires + - entreprise . charges - revenu disponible - situation: indépendant: oui micro entreprise: non diff --git a/source/components/simulationConfigs/rémunération-dirigeant.yaml b/source/components/simulationConfigs/rémunération-dirigeant.yaml index 45fd3077f..ad456ff53 100644 --- a/source/components/simulationConfigs/rémunération-dirigeant.yaml +++ b/source/components/simulationConfigs/rémunération-dirigeant.yaml @@ -11,6 +11,7 @@ questions: - entreprise . chiffre d'affaires - entreprise . catégorie d'activité - entreprise . charges + branches: - nom: Micro-entreprise situation: diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js index c6f05026f..7ae822192 100644 --- a/source/selectors/analyseSelectors.js +++ b/source/selectors/analyseSelectors.js @@ -15,6 +15,7 @@ import { analyse, analyseMany, parseAll } from 'Engine/traverse' import { add, contains, + difference, dissoc, equals, head, @@ -226,12 +227,18 @@ export let missingVariablesByTargetSelector = createSelector( export let nextStepsSelector = createSelector( [ currentMissingVariablesByTargetSelector, - state => state.simulationConfig?.questions + state => state.simulationConfig?.questions, + state => state.simulationConfig?.objectifs ], (mv, questions) => { let nextSteps = getNextSteps(mv) - if (questions) return intersection(nextSteps, questions) + if (questions && questions.blacklist) { + return difference(nextSteps, questions.blacklist) + } + if (questions) { + return intersection(nextSteps, questions) + } return nextSteps } ) diff --git a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js index 029efe9fb..fe1b24ea9 100644 --- a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js +++ b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js @@ -27,7 +27,7 @@ const AssimiléSalarié = () => ( quelques exceptions près (chômage en moins).

- + ) diff --git a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Indépendant.js b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Indépendant.js index d5431e399..af87f4e28 100644 --- a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Indépendant.js +++ b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/Indépendant.js @@ -33,7 +33,7 @@ const Indépendant = () => ( professionnel peut souscrire volontairement des assurances spécifiques.

- + ) diff --git a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/MicroEntreprise.js b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/MicroEntreprise.js index 5aaab9435..8d3da14e0 100644 --- a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/MicroEntreprise.js +++ b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/MicroEntreprise.js @@ -27,7 +27,7 @@ const MicroEntreprise = () => ( professionnel peut souscrire volontairement des assurances spécifiques.

- + )