Vrai score d'avancement par objectif

pull/206/head
Mael 2018-04-09 14:19:48 +02:00 committed by Laurent Bossavit
parent 166c4a77ed
commit cbbbf83cee
2 changed files with 22 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { Trans, translate } from 'react-i18next'
import formValueTypes from 'Components/conversation/formValueTypes'
import { rules, findRuleByName } from 'Engine/rules'
import { propEq, path, contains, without, curry, append, ifElse } from 'ramda'
import { propEq, isEmpty, curry } from 'ramda'
import './TargetSelection.css'
import BlueButton from './BlueButton'
import { Field, reduxForm, formValueSelector, change } from 'redux-form'
@ -111,6 +111,11 @@ export default class TargetSelection extends Component {
}
}
let computeRatio = (mvt, name) =>
!isEmpty(mvt) &&
mvt.current[name].missingVariables.length /
mvt.initial[name].missingVariables.length
let Header = ({
conversationStarted,
s,
@ -123,12 +128,13 @@ let Header = ({
className="progressCircle"
style={{
visibility: activeInput === s.dottedName ? 'hidden' : 'visible'
}}
>
}}>
{do {
let mv = missingVariablesByTarget[s.dottedName],
number = mv && mv.missingVariables.length,
ratio = number / 16
let ratio =
activeInput === s.dottedName
? 0
: computeRatio(missingVariablesByTarget, s.dottedName)
ratio === 0 ? (
<i className="fa fa-check" aria-hidden="true" />
) : (
@ -165,8 +171,7 @@ let TargetInputOrValue = ({
targets,
firstEstimationComplete,
activeInput,
setActiveInput,
clearFormValue
setActiveInput
}) => (
<span className="targetInputOrValue">
{activeInput === s.dottedName ? (

View File

@ -97,7 +97,15 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
situationGate: situationWithDefaults(state),
explainedVariable: null,
nextSteps,
missingVariablesByTarget,
// store the missingVariables when no question has been answered yet,
// to be able to compute a progress by objective
missingVariablesByTarget: {
initial:
state.foldedSteps.length === 0
? missingVariablesByTarget
: state.missingVariablesByTarget.initial,
current: missingVariablesByTarget
},
currentQuestion: head(nextSteps),
foldedSteps:
action.type === 'SET_CONVERSATION_TARGETS' && action.reset