From aac32399d5ada89e3fefd4b36bd78a5a1802de25 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 31 Jan 2019 16:18:14 +0100 Subject: [PATCH] =?UTF-8?q?:bug:=20r=C3=A9pare=20le=20changement=20de=20p?= =?UTF-8?q?=C3=A9riode=20mois/ann=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/actions/actions.js | 6 +-- source/engine/treatVariable.js | 31 ++++++------ source/selectors/analyseSelectors.js | 41 ++++------------ .../layout/Navigation/Navigation.js | 27 +++++----- .../pages/SocialSecurity/Home.js | 49 +++++++++++-------- 5 files changed, 69 insertions(+), 85 deletions(-) diff --git a/source/actions/actions.js b/source/actions/actions.js index ce67350df..648e1e155 100644 --- a/source/actions/actions.js +++ b/source/actions/actions.js @@ -7,18 +7,18 @@ import type { SetSimulationConfigAction, SetSituationBranchAction } from 'Types/ActionsTypes' -import { reset } from 'redux-form' -import { deletePersistedSimulation } from '../storage/persistSimulation' +import { reset } from 'redux-form'; +import { deletePersistedSimulation } from '../storage/persistSimulation'; import type { RouterHistory } from 'react-router-dom' export const resetSimulation = () => (dispatch: any => void): void => { - dispatch(reset('conversation')) dispatch( ({ type: 'RESET_SIMULATION' }: ResetSimulationAction) ) + dispatch(reset('conversation')) } export const setSituationBranch = (id: number): SetSituationBranchAction => ({ diff --git a/source/engine/treatVariable.js b/source/engine/treatVariable.js index ec1e8a3c8..2ec74e5cc 100644 --- a/source/engine/treatVariable.js +++ b/source/engine/treatVariable.js @@ -1,13 +1,9 @@ -import React from 'react' -import { Trans } from 'react-i18next' -import { evaluateNode, makeJsx, rewriteNode } from './evaluation' -import { Leaf, Node } from './mecanismViews/common' -import { - disambiguateRuleReference, - findParentDependency, - findRuleByDottedName -} from './rules' -import { getSituationValue } from './variables' +import React from 'react'; +import { Trans } from 'react-i18next'; +import { evaluateNode, makeJsx, rewriteNode } from './evaluation'; +import { Leaf, Node } from './mecanismViews/common'; +import { disambiguateRuleReference, findParentDependency, findRuleByDottedName } from './rules'; +import { getSituationValue } from './variables'; export let treatVariable = (rules, rule, filter) => parseResult => { let evaluate = (cache, situation, parsedRules, node) => { @@ -147,22 +143,23 @@ export let treatVariableTransforms = (rules, rule) => parseResult => { rule.dottedName }, qui appelle une variable à période flexible, ${ ruleToTransform.dottedName - }, c'est suspect ! + }, c'est suspect ! ` ) return filteredNode } if (!ruleToTransform.période) return filteredNode - let environmentPeriod = situation('période') || 'mois' + console.log(rule.dottedName, environmentPeriod) let callingPeriod = - inlinePeriodTransform || - (rule.période == 'flexible' ? environmentPeriod : rule.période) + inlinePeriodTransform || + (rule.période === 'flexible' ? environmentPeriod : rule.période) let calledPeriod = - ruleToTransform.période == 'flexible' - ? environmentPeriod - : ruleToTransform.période + ruleToTransform.période === 'flexible' + ? environmentPeriod + : ruleToTransform.période + let transformedNodeValue = callingPeriod === 'mois' && calledPeriod === 'année' diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js index 043f598af..e8be0d0b6 100644 --- a/source/selectors/analyseSelectors.js +++ b/source/selectors/analyseSelectors.js @@ -1,31 +1,10 @@ -import { - collectMissingVariablesByTarget, - getNextSteps -} from 'Engine/generateQuestions' -import { - collectDefaults, - disambiguateExampleSituation, - findRuleByDottedName, - formatInputs, - nestedSituationToPathMap, - rules as baseRulesEn, - rulesFr as baseRulesFr -} from 'Engine/rules' -import { analyse, analyseMany, parseAll } from 'Engine/traverse' -import { - add, - contains, - difference, - equals, - head, - intersection, - isNil, - mergeDeepWith, - pick -} from 'ramda' -import { getFormValues } from 'redux-form' -import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect' -import { softCatch } from '../utils' +import { collectMissingVariablesByTarget, getNextSteps } from 'Engine/generateQuestions'; +import { collectDefaults, disambiguateExampleSituation, findRuleByDottedName, formatInputs, nestedSituationToPathMap, rules as baseRulesEn, rulesFr as baseRulesFr } from 'Engine/rules'; +import { analyse, analyseMany, parseAll } from 'Engine/traverse'; +import { add, contains, difference, equals, head, intersection, isNil, mergeDeepWith, pick } from 'ramda'; +import { getFormValues } from 'redux-form'; +import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect'; +import { softCatch } from '../utils'; // create a "selector creator" that uses deep equal instead of === const createDeepEqualSelector = createSelectorCreator(defaultMemoize, equals) @@ -103,13 +82,13 @@ const createSituationBrancheSelector = situationSelector => (situation, branches, configSituation) => { if (branches) { return branches.map(({ situation: branchSituation }) => ({ - ...situation, ...configSituation, - ...branchSituation + ...branchSituation, + ...situation, })) } if (configSituation) { - return { ...situation, ...configSituation } + return { ...configSituation, ...situation } } return situation } diff --git a/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js b/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js index f1085f8cc..76298148f 100644 --- a/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js +++ b/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js @@ -1,16 +1,16 @@ /* @flow */ -import { React, T } from 'Components' -import withSitePaths from 'Components/utils/withSitePaths' -import { compose } from 'ramda' -import { withNamespaces } from 'react-i18next' -import { connect } from 'react-redux' -import { NavLink, withRouter } from 'react-router-dom' -import companySvg from '../../images/company.svg' -import estimateSvg from '../../images/estimate.svg' -import hiringSvg from '../../images/hiring.svg' -import './Navigation.css' -import NavOpener from './NavOpener' -import SideBar from './SideBar' +import { React, T } from 'Components'; +import withSitePaths from 'Components/utils/withSitePaths'; +import { compose } from 'ramda'; +import { withNamespaces } from 'react-i18next'; +import { connect } from 'react-redux'; +import { NavLink, withRouter } from 'react-router-dom'; +import companySvg from '../../images/company.svg'; +import estimateSvg from '../../images/estimate.svg'; +import hiringSvg from '../../images/hiring.svg'; +import './Navigation.css'; +import NavOpener from './NavOpener'; +import SideBar from './SideBar'; import type { TFunction } from 'react-i18next' @@ -199,6 +199,7 @@ const StepsHeader = ({ t, sitePaths, companyStatusChoice }: Props) => ( }>