diff --git a/source/components/PageRule.css b/source/components/PageRule.css new file mode 100644 index 000000000..51c4c6151 --- /dev/null +++ b/source/components/PageRule.css @@ -0,0 +1,14 @@ +#toSimulation { + background: #333350; + margin: 0 auto 1em; + display: block; + width: 20em; + color: white; + font-size: 180%; + text-align: center; + padding: .2em .6em; +} + +#toSimulation i { + margin: 0 .6em +} diff --git a/source/components/RulePage.js b/source/components/RulePage.js index b89932d74..a351e1b4a 100644 --- a/source/components/RulePage.js +++ b/source/components/RulePage.js @@ -4,17 +4,30 @@ import Rule from 'Components/rule/Rule' import { analyse } from 'Engine/traverse' import { head, path } from 'ramda' import { decodeRuleName, nameLeaf, findRuleByName } from 'Engine/rules.js' +import {encodeRuleName} from 'Engine/rules' +import {pipe, pluck, join, map} from 'ramda' +import { Link } from 'react-router-dom' +import {animateScroll} from 'react-scroll' +import './PageRule.css' @connect(state => ({ situationGate: state.situationGate, - parsedRules: state.parsedRules + parsedRules: state.parsedRules, + analysis: state.analysis })) export default class RulePage extends Component { nameFromParams = path(['match', 'params', 'name']) componentWillMount() { this.setRule(this.nameFromParams(this.props)) } - + componentDidMount(){ + animateScroll.scrollToTop({duration: 300}) + } + componentWillReceiveProps(nextProps) { + if (this.nameFromParams(nextProps) !== this.nameFromParams(this.props)) { + this.setRule(this.nameFromParams(nextProps)) + } + } setRule(name) { let ruleName = nameLeaf(decodeRuleName(name)), rule = findRuleByName(this.props.parsedRules, ruleName) @@ -24,17 +37,19 @@ export default class RulePage extends Component { .targets ) } - // Est-ce nécessaire ? Pour naviguer dans les Rules ? - // componentWillReceiveProps(nextProps) { - // let get = R.path(['match', 'params', 'name']) - // if (get(nextProps) !== get(this.props)) { - // this.setRule(get(nextProps)) - // this.setState({ example: null, showValues: true }) - // } - // } render() { if (!this.rule) return - return + let targets = path(['analysis', 'targets'], this.props) + + return (<> + {targets && } + + ) } } + +let BackToSimulation = ({targets}) => + + Reprendre la simulation +