Rétabli l'ancienne version de l'affichage des valeurs par défaut dans ruleInput

fix #2107
pull/2109/head v1.22.0
Johan Girod 2022-04-22 10:54:13 +02:00
parent c9d7d221d6
commit abf177d959
4 changed files with 17 additions and 7 deletions

View File

@ -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
}
})

View File

@ -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'
@ -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,

View File

@ -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'
@ -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}
/>

View File

@ -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'
@ -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>