Merge pull request #61 from sgmap/show-values

Affiche les valeurs de la simulation par défaut
pull/62/merge
Laurent Bossavit 2017-09-26 14:06:44 +02:00 committed by GitHub
commit a6d398eca3
3 changed files with 14 additions and 17 deletions

View File

@ -12,11 +12,10 @@ let RuleWithoutFormula = () =>
doit donc être renseignée directement.
</p>
@AttachDictionary(knownMecanisms)
export default class Algorithm extends React.Component {
state = {
showValues: false
showValues: true
}
render(){
let {traversedRule: rule, showValues} = this.props

View File

@ -42,27 +42,18 @@ export default class Examples extends Component {
render() {
let examples = this.runExamples(),
focusedExample = R.path(['focusedExample', 'nom'])(this.props),
{clearInjection, inject, situationExists , showValues} = this.props
{inject, situationExists , showValues} = this.props
return (
<div id="examples">
<h2 className="subtitled">Exemples de calcul</h2>
<p className="subtitle">Cliquez sur un exemple pour le visualiser</p>
{situationExists && <div>
<button
className={classNames({selected: !focusedExample && showValues})}
id="injectSituation"
onClick={() => showValues ? clearInjection(): inject()}>
<i className="fa fa-rocket" aria-hidden="true"></i> &nbsp;{focusedExample || !showValues ? 'Injecter votre situation' : 'Cacher votre situation'}
</button>
</div>
}
{R.isEmpty(examples) ?
<p><i className="fa fa-exclamation-triangle" aria-hidden="true"></i><em>Cette règle manque d'exemples...</em></p>
: <ul>{
examples.map(({nom, ok, rule, 'valeur attendue': expected}) =>
<li key={nom} className={classNames("example", {ok, selected: focusedExample == nom})}
onClick={() => focusedExample == nom ? clearInjection() : inject({nom, ok, rule})}
onClick={() => focusedExample == nom ? false : inject({nom, ok, rule})}
>
<span> {
ok ?
@ -84,6 +75,14 @@ export default class Examples extends Component {
}
</ul>
}
{(situationExists && focusedExample) && <div>
<button
id="injectSituation"
onClick={() => inject()}>
Revenir à votre situation
</button>
</div>
}
<button
id="reportError">
<a href={"mailto:contact@embauche.beta.gouv.fr?subject=Erreur dans une règle " + name}>

View File

@ -31,13 +31,13 @@ let testingSituationGate = v => // eslint-disable-line no-unused-vars
)
export default class Rule extends Component {
state = {
example: null, showValues: false
example: null, showValues: true
}
componentWillReceiveProps(nextProps){
let get = R.path(['match', 'params', 'name'])
if (get(nextProps) !== get(this.props)) {
this.setRule(get(nextProps))
this.setState({example: null, showValues: false})
this.setState({example: null, showValues: true})
}
}
setRule(name){
@ -105,13 +105,12 @@ export default class Rule extends Component {
</div>
</section>
<section id="rule-calc">
<Algorithm {...{traversedRule: R.path(['example', 'rule'])(this.state) || this.rule, showValues: this.state.showValues}}/>
<Algorithm {...{traversedRule: R.path(['example', 'rule'])(this.state) || this.rule, showValues: situationExists || this.state.example != null}}/>
<Examples
situationExists={situationExists}
rule={this.rule}
focusedExample={this.state.example}
showValues={this.state.showValues}
clearInjection={() => this.setState({example: null, showValues: false})}
inject={example => this.setState({example, showValues: true})}/>
</section>
</div>