{this.state.helpVisible && this.renderHelpBox(helpText)}
{this.renderHeader(unfolded, valueType, human, helpText, wideQuestion, subquestion)}
@@ -129,16 +128,24 @@ export var FormDecorator = formType => RenderField =>
let {
name,
stepAction,
- answers,
+ answer,
themeColours
} = this.props,
- value = answers[name],
ignored = this.step.state === 'ignored'
-
return (
- stepAction(name, 'editing')}>
- {this.props.title}
-
+
+ {this.props.step.title}
+ {answer}
+
+ stepAction(name, 'editing')}
+ className="fa fa-pencil-square-o"
+ aria-hidden="true">
+
+ Modifier
+
+
+ {/* */}
)
}
diff --git a/source/components/conversation/StepAnswer.js b/source/components/conversation/StepAnswer.js
index 326382172..6fa2f3535 100644
--- a/source/components/conversation/StepAnswer.js
+++ b/source/components/conversation/StepAnswer.js
@@ -9,7 +9,6 @@ export default class StepAnswer extends Component {
} = this.props,
// Show a beautiful answer to the user, rather than the technical form value
humanFunc = human || valueType && valueType.human || (v => v)
-
return (
{humanFunc(value)}
diff --git a/source/components/conversation/conversation.css b/source/components/conversation/conversation.css
index de0fa60a9..bd926fe1f 100644
--- a/source/components/conversation/conversation.css
+++ b/source/components/conversation/conversation.css
@@ -4,7 +4,7 @@
}
.step {
- opacity: .2;
+ opacity: 1;
}
.step:first-child {
@@ -92,12 +92,32 @@
margin-bottom: 1em;
border-radius: 1.4em;
position: relative;
- cursor: pointer;
}
-/* The unfolded step is the currently focused
-question : make it visible with colors */
-.step.unfolded h1 {
- cursor: default;
+
+.fact {
+ width: 80%;
+ margin-bottom: 1em;
+ clear: both;
+}
+.fact .title {
+ font-weight: 600;
+ border-bottom: 1px solid #aaa;
+}
+.fact .answer {
+ float: right;
+}
+
+.fact .edit {
+ margin-left: 2em;
+ font-size: 75%;
+ cursor: pointer;
+ font-weight: bold;
+ padding: .1em .6em;
+ border-radius: 2px;
+}
+.step.completed .edit:hover {
+ background: #333350;
+ color: white;
}
.step-subquestion {
diff --git a/source/engine/conversation.js b/source/engine/conversation.js
index d96cbd093..d20b14d1f 100644
--- a/source/engine/conversation.js
+++ b/source/engine/conversation.js
@@ -1,7 +1,7 @@
import React from 'react'
import Explicable from '../components/conversation/Explicable'
-export let constructStepMeta = ({question, subquestion, dottedName, name}) => ({
+export let constructStepMeta = ({titre, question, subquestion, dottedName, name}) => ({
// name: dottedName.split(' . ').join('.'),
name: dottedName,
// question: question || name,
@@ -10,7 +10,7 @@ export let constructStepMeta = ({question, subquestion, dottedName, name}) => ({
name={name}
lightBackground={true}
/>,
- title: name,
+ title: titre || name,
dependencyOfVariables: ['chai pas'],
subquestion,
diff --git a/source/reducers.js b/source/reducers.js
index cf328b025..2b25224eb 100644
--- a/source/reducers.js
+++ b/source/reducers.js
@@ -17,15 +17,6 @@ import {constructStepMeta} from './engine/conversation'
import computeThemeColours from './components/themeColours'
-function steps(steps = [], {type}) {
- switch (type) {
- case UNSUBMIT_ALL:
- return []
- default:
- return steps
- }
-}
-
function themeColours(state = computeThemeColours(), {type, colour}) {
if (type == 'CHANGE_THEME_COLOUR')
return computeThemeColours(colour)
@@ -51,7 +42,9 @@ export default reduceReducers(
/* Have forms been filled or ignored ?
false means the user is reconsidering its previous input */
- steps,
+ steps: (steps=[]) => steps,
+
+ submittedSteps: (steps=[]) => steps,
analysedSituation: (state = []) => state,
@@ -66,6 +59,15 @@ export default reduceReducers(
// pour débugguer :
window.situationGate = situationGate(state)
+ let newlySubmittedSteps =
+ action.newState == 'filled'
+ ? [{
+ ...state.steps.find(s => s.name === action.name),
+ state: 'filled'
+ }]
+ : []
+
+
// on calcule la prochaine étape, à ajouter sur la pile
let
// une liste des objectifs de la simulation (des 'rules' aussi nommées 'variables')
@@ -82,11 +84,25 @@ export default reduceReducers(
missingVariablesList = R.keys(missingVariables),
+ /*
+ Certaines variables manquantes peuvent être factorisées dans des groupes.
+ Par exemple, au lieu de :
+
+ q1: "Pensez vous porlonger le CDD en CDI",
+ r1: Oui | Non
+ q2: "Pensez-vous qu'une rupture pour faute grave est susceptible d'arriver"
+ r2: Oui | Non
+
+ on préfère :
+
+ q: "Pensez-vous être confronté à l'un de ces événements ?"
+ r: Prolongation du CDD en CDI | Rupture pour faute grave
+ */
groups = R.groupBy(
parentName
)(missingVariablesList),
- // on va maintenant construire la liste des composants React correspondant aux questions pour obtenir les variables manquantes
+ // on va maintenant construire la liste des composants React qui afficheront les questions à l'utilisateur pour que l'on obtienne les variables manquantes
steps = R.pipe(
R.mapObjIndexed((variables, group) =>
R.pipe(
@@ -133,7 +149,13 @@ export default reduceReducers(
R.unnest
)(groups)
- return {...state, steps, analysedSituation}
+ console.log('submittedSteps', newlySubmittedSteps)
+ return {
+ ...state,
+ steps,
+ submittedSteps: state.submittedSteps.concat(newlySubmittedSteps),
+ analysedSituation
+ }
} else {
return state