import React, { Component } from 'react' // import {findRuleByName} from '../engine/rules.js' import {analyseSituation} from '../engine/traverse' import './Rule.css' import JSONTree from 'react-json-tree' import R from 'ramda' import PageTypeIcon from './PageTypeIcon' import {connect} from 'react-redux' import {formValueSelector} from 'redux-form' import mockSituation from '../engine/mockSituation.yaml' import {START_CONVERSATION} from '../actions' import classNames from 'classnames' // situationGate function useful for testing : let testingSituationGate = v => // eslint-disable-line no-unused-vars R.path(v.split('.'))(mockSituation) @connect( state => ({ // situationGate: name => formValueSelector('conversation')(state, name), analysedSituation: state.analysedSituation, form: state.form }), dispatch => ({ startConversation: () => dispatch({type: START_CONVERSATION}), }) ) export default class Rule extends Component { state = { showValues: false } componentDidMount() { // C'est ici que la génération du formulaire, et donc la traversée des variables commence this.props.startConversation() } render() { let { params: {name}, analysedSituation, form } = this.props, objectives = R.path(['formule', 'explanation', 'explanation'])(analysedSituation) if (!objectives) return null let rule = objectives.find(R.pathEq(['explanation', 'name'], name)).explanation if (!rule) { this.props.router.push('/404') return null } let situationExists = !R.isEmpty(form), showValues = situationExists && this.state.showValues return (

{rule.type} {name}

{rule.description}

Propriétés

Références

{this.renderReferences(rule)}

Pourquoi cette règle me concerne ? Comment est-elle calculée ? C'est pas très lisible pour l'instant, mais ça le deviendra

{ do { let [,cond] = R.toPairs(rule).find(([,v]) => v.rulePropType == 'cond') || [] cond != null &&

Conditions de déclenchement

{cond.jsx}
}}

Calcul

{rule['formule'].jsx}
{situationExists && }
{/*
						
				
*/}
) } renderReferences(rule) { return ( rule['référence'] &&
{rule['référence']}
) || ( rule['références'] && ) } } let JSONView = ({o, rootKey}) => (
''} theme={theme} hideRoot={true} shouldExpandNode={() => true} data={rootKey ? {[rootKey]: o} : o} />
) var theme = { scheme: 'atelier forest', author: 'bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest)', base00: '#1b1918', base01: '#2c2421', base02: '#68615e', base03: '#766e6b', base04: '#9c9491', base05: '#a8a19f', base06: '#e6e2e0', base07: '#f1efee', base08: '#f22c40', base09: '#df5320', base0A: '#d5911a', base0B: '#5ab738', base0C: '#00ad9c', base0D: '#407ee7', base0E: '#6666ea', base0F: '#c33ff3' }