Skip to content

Commit

Permalink
Rétabli l'ancienne version de l'affichage des valeurs par défaut dans…
Browse files Browse the repository at this point in the history
… ruleInput

fix #2107
  • Loading branch information
johangirod committed Apr 22, 2022
1 parent c9d7d22 commit abf177d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions site/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import './commands'

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err) => {
/*
/*
The error 'ResizeObserver loop limit exceeded' is benigne
Returning false here prevents Cypress from failing the test
cf https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
*/
if (resizeObserverLoopErrRe.test(err.message)) {
return false
}
if (resizeObserverLoopErrRe.test(err.message)) {
return false
}
})
4 changes: 2 additions & 2 deletions site/source/components/conversation/RuleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Engine, {
reduceAST,
RuleNode,
} from 'publicodes'
import { isEmpty } from 'ramda'
import React, { useContext } from 'react'
import { Choice, MultipleAnswerInput, OuiNonInput } from './ChoicesInput'
import DateInput from './DateInput'
Expand Down Expand Up @@ -81,12 +80,13 @@ export default function RuleInput<Names extends string = DottedName>({
const rule = engine.getRule(dottedName)
const evaluation = engine.evaluate({ valeur: dottedName, ...modifiers })
const value = evaluation.nodeValue
console.log(missing, evaluation.missingVariables)
const commonProps: InputProps<Names> = {
dottedName,
value,
missing:
missing ??
(!showDefaultDateValue && !isEmpty(evaluation.missingVariables)),
(!showDefaultDateValue && dottedName in evaluation.missingVariables),
onChange: (value: PublicodesExpression | undefined) =>
onChange(value, dottedName),
title: rule.title,
Expand Down
2 changes: 2 additions & 0 deletions site/source/pages/gerer/_components/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { evaluateQuestion, getMeta } from '@/utils'
import { useSSRSafeId } from '@react-aria/ssr'
import { DottedName } from 'modele-social'
import { RuleNode } from 'publicodes'
import { isEmpty } from 'ramda'
import { useCallback, useContext } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import styled from 'styled-components'
Expand Down Expand Up @@ -132,6 +133,7 @@ export function SimpleField({
aria-labelledby={displayedQuestion ? labelId : undefined}
label={displayedLabel}
required={meta.requis === 'oui'}
missing={!isEmpty(evaluation.missingVariables)}
onChange={dispatchValue}
showSuggestions={showSuggestions}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DottedName } from '@/../../modele-social'
import { resetSimulation } from '@/actions/actions'
import { resetCompany } from '@/actions/companyActions'
import { TrackPage } from '@/ATInternetTracking'
import { CompanyDetails } from '@/components/company/Details'
Expand Down Expand Up @@ -106,7 +107,14 @@ export default function Accueil() {
<WhenAlreadyDefined dottedName="entreprise . SIREN">
<CompanyDetails />

<Button size="XS" light onPress={() => dispatch(resetCompany())}>
<Button
size="XS"
light
onPress={() => {
dispatch(resetSimulation())
dispatch(resetCompany())
}}
>
<Trans>Modifier l'entreprise</Trans>
</Button>
</WhenAlreadyDefined>
Expand Down

0 comments on commit abf177d

Please sign in to comment.