⚙️ Refactoring

pull/15/head
Laurent Bossavit 2017-07-08 13:28:50 +02:00
parent 8d3760aa77
commit 0161fd3d7d
2 changed files with 23 additions and 4 deletions

View File

@ -126,6 +126,15 @@ export let buildNextSteps = (allRules, analysedSituation) => {
D'autres variables pourront être regroupées aussi, car elles partagent un parent, mais sans fusionner leurs questions dans l'interface. Ce sont des **groupes de type _record_ **
*/
// This is effectively a missingVariables.groupBy(questionRequired)
// but "questionRequired" does not have a clear specification
// we could look up "what formula is this variable mentioned in, and does it have a question attached"
// the problem is that we parse rules "bottom up", we would therefore need to:
// - parse rules top-down, i.e. analysedSituations = map(treatRuleRoot, rules)
// (might be a problem later on in terms of "big" rulesets, but not now)
// - decorate each rule with "mentions / depends on the following rules"
// - provide a "is mentioned by" query
return R.pipe(
R.keys,
R.curry(findVariantsAndRecords)(allRules),

View File

@ -5,10 +5,20 @@ import reduceReducers from 'reduce-reducers'
import {reducer as formReducer, formValueSelector} from 'redux-form'
import {rules} from 'Engine/rules'
import {analyse, buildNextSteps, generateGridQuestions, generateSimpleQuestions} from 'Engine/generateQuestions'
import {buildNextSteps, generateGridQuestions, generateSimpleQuestions} from 'Engine/generateQuestions'
import computeThemeColours from 'Components/themeColours'
import { EXPLAIN_VARIABLE, POINT_OUT_OBJECTIVES} from './actions'
import { STEP_ACTION, START_CONVERSATION} from './actions'
import { STEP_ACTION, START_CONVERSATION, EXPLAIN_VARIABLE, POINT_OUT_OBJECTIVES, CHANGE_THEME_COLOUR} from './actions'
import {analyseSituation} from 'Engine/traverse'
let situationGate = state =>
name => formValueSelector('conversation')(state, name)
let analyse = rootVariable => R.pipe(
situationGate,
// une liste des objectifs de la simulation (des 'rules' aussi nommées 'variables')
analyseSituation(rules, rootVariable)
)
export let reduceSteps = (state, action) => {
@ -51,7 +61,7 @@ export let reduceSteps = (state, action) => {
}
function themeColours(state = computeThemeColours(), {type, colour}) {
if (type == 'CHANGE_THEME_COLOUR')
if (type == CHANGE_THEME_COLOUR)
return computeThemeColours(colour)
else return state
}