Recalcul des résultats en temps réel pendant la saisie numérique
parent
4753e1f535
commit
cc1f25e4d7
|
@ -75,11 +75,11 @@ export var FormDecorator = formType => RenderField =>
|
|||
props passées à ce dernier, car React 15.2 n'aime pas les attributes inconnus
|
||||
des balises html, <input> dans notre cas.
|
||||
*/
|
||||
//TODO hack, enables redux-form/CHANGE to update the form state before the traverse functions are run
|
||||
let submit = () => setTimeout(() => stepAction('fold', fieldName), 1),
|
||||
stepProps = {
|
||||
...this.props.step,
|
||||
inverted,
|
||||
//TODO hack, enables redux-form/CHANGE to update the form state before the traverse functions are run
|
||||
submit,
|
||||
setFormValue: (value, name = fieldName) => setFormValue(name, value)
|
||||
}
|
||||
|
|
|
@ -50,10 +50,17 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
|
|||
// Optimization - don't parse on each analysis
|
||||
if (!state.parsedRules) state.parsedRules = parseAll(flatRules)
|
||||
|
||||
if (![START_CONVERSATION, STEP_ACTION].includes(action.type)) return state
|
||||
if (
|
||||
![START_CONVERSATION, STEP_ACTION, '@@redux-form/CHANGE'].includes(
|
||||
action.type
|
||||
)
|
||||
)
|
||||
return state
|
||||
|
||||
let targetNames =
|
||||
action.type == START_CONVERSATION ? action.targetNames : state.targetNames
|
||||
action.type == START_CONVERSATION
|
||||
? action.targetNames
|
||||
: state.targetNames || []
|
||||
|
||||
let sim =
|
||||
targetNames.length === 1 ? findRuleByName(flatRules, targetNames[0]) : {},
|
||||
|
@ -66,9 +73,14 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
|
|||
situationWithDefaults = assume(intermediateSituation, rulesDefaults)
|
||||
|
||||
let analysis = analyseMany(state.parsedRules, targetNames)(
|
||||
situationWithDefaults(state)
|
||||
),
|
||||
nextWithDefaults = getNextSteps(situationWithDefaults(state), analysis),
|
||||
situationWithDefaults(state)
|
||||
)
|
||||
|
||||
if (action.type === '@@redux-form/CHANGE') {
|
||||
return { ...state, analysis, situationGate: situationWithDefaults(state) }
|
||||
}
|
||||
|
||||
let nextWithDefaults = getNextSteps(situationWithDefaults(state), analysis),
|
||||
assumptionsMade = !isEmpty(rulesDefaults),
|
||||
done = nextWithDefaults.length == 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue