From 137675f542dee32f19b28e82825e945c594312cf Mon Sep 17 00:00:00 2001 From: Mael Thomas Date: Thu, 28 Jul 2016 19:12:15 +0200 Subject: [PATCH] =?UTF-8?q?Travail=20sur=20la=20page=20variable;=20afficha?= =?UTF-8?q?ge=20des=20calculs=20lin=C3=A9aires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SelectedVariable.css | 50 +++++++++++++++++++++ components/SelectedVariable.js | 80 ++++++++++++++++++++++++++++++++- components/TagMap.js | 13 ++++++ components/TagNavigation.js | 12 ++--- containers/App.css | 9 ++-- reducers.js | 2 +- 6 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 components/SelectedVariable.css create mode 100644 components/TagMap.js diff --git a/components/SelectedVariable.css b/components/SelectedVariable.css new file mode 100644 index 000000000..71bbaa475 --- /dev/null +++ b/components/SelectedVariable.css @@ -0,0 +1,50 @@ +#calculable-items>li { + margin-top: 4em; + padding-bottom: 2em; + border-bottom: 1px solid #eee; +} + +.item .left { + display: inline-block; + width: 30%; +} +.item .right { + display: inline-block; + width: 40%; +} +/* Display formulas */ + +.calc { + text-align: center; +} +.calc h3 { + font-weight: 300; + font-size: 100%; + color: #666; + text-transform: uppercase; +} +.linear { + font-size: 130%; +} +.linear .label { + font-size: 70%; + color: #333; + color: #2980b9; +} + +.linear .operator { + margin: 0 1em; + color: #2980b9; + font-size: 150%; +} + +.linear .limit { + margin-top: 1em; +} +.linear .limit .label { + margin-right: 1em; +} + +.linear .base, .calc .rate { + display: inline-block; +} diff --git a/components/SelectedVariable.js b/components/SelectedVariable.js index 4836036ee..9dcf75ba5 100644 --- a/components/SelectedVariable.js +++ b/components/SelectedVariable.js @@ -1,4 +1,7 @@ import React, { Component } from 'react' +import './SelectedVariable.css' +import TagMap from './TagMap' +import R from 'ramda' export default class SelectedVariable extends Component { render() { @@ -8,14 +11,26 @@ export default class SelectedVariable extends Component { first: { description }, - tags + tags, + calculable }, selectedTags - } = this.props + } = this.props, + + tagsList = R.pluck('tags', calculable), + commonTags = R.tail(tagsList).reduce( + (result, next) => R.intersection(result, R.toPairs(next)), + R.toPairs(R.head(tagsList)) + ), + itemsWithUniqueTags = R.map(item => [item, R.fromPairs(R.difference(R.toPairs(item.tags), commonTags))], calculable) + + return (

{name}

{description}

+ + {/*
    {Object.keys(tags) .filter(name => !selectedTags.find(([n]) => name == n)) @@ -25,6 +40,67 @@ export default class SelectedVariable extends Component { )}
+ */} +
) } } + +class Items extends Component { + render() { + let {itemsWithUniqueTags} = this.props + + return ( + + ) + } +} + +let Item = ({item: {linear, marginalRateTaxScale}, tags}) => +
  • +
    + +
    +
    + { linear && + || marginalRateTaxScale && + } +
    +
  • + + +let Linear = ({data: { + base, + limit, + historique +}}) =>
    +

    Calcul linéaire

    +
    +
    +
    base
    +
    {base}
    +
    + + ✕ + +
    +
    Taux
    +
    { + historique[(Object.keys(historique).sort()[0])] + }
    +
    + { limit != null &&
    + dans la limite de : + {limit} +
    } +
    +
    + +let TaxScale = ({data}) =>
    +

    Règle de calcul: barème

    + {JSON.stringify(data)} +
    diff --git a/components/TagMap.js b/components/TagMap.js new file mode 100644 index 000000000..b84639aa0 --- /dev/null +++ b/components/TagMap.js @@ -0,0 +1,13 @@ +import React from 'react' +import R from 'ramda' + +let TagMap = ({data}) => + + +export default TagMap diff --git a/components/TagNavigation.js b/components/TagNavigation.js index 600eb9671..538713311 100644 --- a/components/TagNavigation.js +++ b/components/TagNavigation.js @@ -1,5 +1,5 @@ import React from 'react' - +import TagMap from './TagMap' export default class TagNavigation extends React.Component { render(){ @@ -10,13 +10,7 @@ export default class TagNavigation extends React.Component {
    {selectedTags.length > 0 &&
    -
      - {selectedTags.map(([name, value]) =>
    • - {name}: - {value} -
    • ) - } -
    +
    } @@ -38,7 +32,7 @@ class Tag extends React.Component { {name} - ({number} variables) + ({number} variable{number > 1 ? 's' : ''})