Affichage des unités
parent
5de2231267
commit
60a8558daf
|
@ -16,7 +16,7 @@ import {
|
|||
|
||||
export let makeJsx = node =>
|
||||
typeof node.jsx == 'function'
|
||||
? node.jsx(node.nodeValue, node.explanation, node.lazyEval)
|
||||
? node.jsx(node.nodeValue, node.explanation, node.lazyEval, node.unit)
|
||||
: node.jsx
|
||||
|
||||
export let collectNodeMissing = node => node.missingVariables || {}
|
||||
|
|
|
@ -10,7 +10,8 @@ import withLanguage from 'Components/utils/withLanguage'
|
|||
let Comp = withLanguage(function Composantes({
|
||||
language,
|
||||
nodeValue,
|
||||
explanation
|
||||
explanation,
|
||||
unit
|
||||
}) {
|
||||
return (
|
||||
<Node
|
||||
|
@ -18,6 +19,7 @@ let Comp = withLanguage(function Composantes({
|
|||
name="composantes"
|
||||
inline
|
||||
value={nodeValue}
|
||||
unit={unit}
|
||||
child={
|
||||
<>
|
||||
<p>
|
||||
|
@ -51,6 +53,6 @@ let Comp = withLanguage(function Composantes({
|
|||
})
|
||||
|
||||
// eslint-disable-next-line
|
||||
export default (nodeValue, explanation) => (
|
||||
<Comp {...{ nodeValue, explanation }} />
|
||||
export default (nodeValue, explanation, _, unit) => (
|
||||
<Comp {...{ nodeValue, explanation, unit }} />
|
||||
)
|
||||
|
|
|
@ -4,13 +4,14 @@ import { Trans } from 'react-i18next'
|
|||
import { Node } from './common'
|
||||
import './InversionNumérique.css'
|
||||
|
||||
export default function ProductView(nodeValue, explanation) {
|
||||
export default function ProductView(nodeValue, explanation, _, unit) {
|
||||
return (
|
||||
// The rate and factor and threshold are given defaut neutral values. If there is nothing to explain, don't display them at all
|
||||
<Node
|
||||
classes="mecanism multiplication"
|
||||
name="multiplication"
|
||||
value={nodeValue}
|
||||
unit={unit}
|
||||
child={
|
||||
<div
|
||||
style={{
|
||||
|
|
|
@ -4,21 +4,22 @@ import { makeJsx } from '../evaluation'
|
|||
import './Somme.css'
|
||||
import { Node, NodeValuePointer } from './common'
|
||||
|
||||
const SommeNode = ({ explanation, nodeValue }) => (
|
||||
const SommeNode = ({ explanation, nodeValue, unit }) => (
|
||||
<Node
|
||||
classes="mecanism somme"
|
||||
name="somme"
|
||||
value={nodeValue}
|
||||
child={<Table explanation={explanation} />}
|
||||
unit={unit}
|
||||
child={<Table explanation={explanation} unit={unit} />}
|
||||
/>
|
||||
)
|
||||
export default SommeNode
|
||||
|
||||
let Table = ({ explanation }) => (
|
||||
let Table = ({ explanation, unit }) => (
|
||||
<div className="mecanism-somme__table">
|
||||
<div>
|
||||
{explanation.map((v, i) => (
|
||||
<Row key={i} {...{ v, i }} />
|
||||
<Row key={i} {...{ v, i }} unit={unit} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +31,7 @@ class Row extends Component {
|
|||
folded: true
|
||||
}
|
||||
render() {
|
||||
let { v, i } = this.props,
|
||||
let { v, i, unit } = this.props,
|
||||
rowFormula = path(['explanation', 'formule', 'explanation'], v),
|
||||
isSomme = rowFormula && rowFormula.name == 'somme'
|
||||
|
||||
|
@ -50,13 +51,13 @@ class Row extends Component {
|
|||
)}
|
||||
</div>
|
||||
<div className="situationValue value">
|
||||
<NodeValuePointer data={v.nodeValue} />
|
||||
<NodeValuePointer data={v.nodeValue} unit={unit} />
|
||||
</div>
|
||||
</div>,
|
||||
...(isSomme && !this.state.folded
|
||||
? [
|
||||
<div className="nested" key={v.name + '-nest'}>
|
||||
<Table explanation={rowFormula.explanation} />
|
||||
<Table explanation={rowFormula.explanation} unit={unit} />
|
||||
</div>
|
||||
]
|
||||
: [])
|
||||
|
|
|
@ -12,7 +12,8 @@ import './Variations.css'
|
|||
let Comp = withLanguage(function Variations({
|
||||
language,
|
||||
nodeValue,
|
||||
explanation
|
||||
explanation,
|
||||
unit
|
||||
}) {
|
||||
let [expandedVariation, toggleVariation] = useState(null)
|
||||
|
||||
|
@ -23,6 +24,7 @@ let Comp = withLanguage(function Variations({
|
|||
classes="mecanism variations"
|
||||
name="variations"
|
||||
inline
|
||||
unit={unit}
|
||||
value={nodeValue}
|
||||
child={
|
||||
<>
|
||||
|
@ -111,6 +113,6 @@ let Comp = withLanguage(function Variations({
|
|||
)
|
||||
})
|
||||
// eslint-disable-next-line
|
||||
export default (nodeValue, explanation) => (
|
||||
<Comp {...{ nodeValue, explanation }} />
|
||||
export default (nodeValue, explanation, _, unit) => (
|
||||
<Comp {...{ nodeValue, explanation, unit }} />
|
||||
)
|
||||
|
|
|
@ -35,7 +35,7 @@ export let NodeValuePointer = ({ data, unit }) => (
|
|||
// Un élément du graphe de calcul qui a une valeur interprétée (à afficher)
|
||||
export class Node extends Component {
|
||||
render() {
|
||||
let { classes, name, value, child, inline } = this.props,
|
||||
let { classes, name, value, child, inline, unit } = this.props,
|
||||
termDefinition = contains('mecanism', classes) && name
|
||||
|
||||
return (
|
||||
|
@ -58,7 +58,7 @@ export class Node extends Component {
|
|||
{name ? (
|
||||
!isNil(value) && (
|
||||
<div className="mecanism-result">
|
||||
<NodeValuePointer data={value} />
|
||||
<NodeValuePointer data={value} unit={unit} />
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
|
@ -66,7 +66,7 @@ export class Node extends Component {
|
|||
{value !== true && value !== false && !isNil(value) && (
|
||||
<span className="operator"> = </span>
|
||||
)}
|
||||
<NodeValuePointer data={value} />
|
||||
<NodeValuePointer data={value} unit={unit} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
@ -98,7 +98,7 @@ export const Leaf = compose(
|
|||
classes,
|
||||
dottedName,
|
||||
name,
|
||||
value,
|
||||
nodeValue,
|
||||
flatRules,
|
||||
filter,
|
||||
sitePaths,
|
||||
|
@ -120,12 +120,12 @@ export const Leaf = compose(
|
|||
{rule.title || capitalise0(name)} {filter}
|
||||
</span>
|
||||
</Link>
|
||||
{!isNil(value) && (
|
||||
{!isNil(nodeValue) && (
|
||||
<span
|
||||
css={`
|
||||
margin: 0 0.3rem;
|
||||
`}>
|
||||
<NodeValuePointer data={value} unit={unit} />
|
||||
<NodeValuePointer data={nodeValue} unit={unit} />
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
|
|
|
@ -138,7 +138,8 @@ export let mecanismVariations = (recurse, k, v, devariate) => {
|
|||
jsx: Variations,
|
||||
category: 'mecanism',
|
||||
name: 'variations',
|
||||
type: 'numeric'
|
||||
type: 'numeric',
|
||||
unit: inferUnit('+', explanation.map(r => r.consequence.unit))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,8 +498,8 @@ export let mecanismSum = (recurse, k, v) => {
|
|||
return {
|
||||
evaluate,
|
||||
// eslint-disable-next-line
|
||||
jsx: (nodeValue, explanation) => (
|
||||
<Somme nodeValue={nodeValue} explanation={explanation} />
|
||||
jsx: (nodeValue, explanation, _, unit) => (
|
||||
<Somme nodeValue={nodeValue} explanation={explanation} unit={unit} />
|
||||
),
|
||||
explanation,
|
||||
category: 'mecanism',
|
||||
|
@ -620,7 +621,6 @@ export let mecanismProduct = (recurse, k, v) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export let mecanismContinuousScale = (recurse, k, v) => {
|
||||
let objectShape = {
|
||||
assiette: false,
|
||||
|
|
|
@ -201,6 +201,7 @@ let mecanismOperation = (k, operatorFunction, symbol) => (recurse, k, v) => {
|
|||
<Node
|
||||
classes={'inlineExpression ' + k}
|
||||
value={nodeValue}
|
||||
unit={unit}
|
||||
child={
|
||||
<span className="nodeContent">
|
||||
<span className="fa fa" />
|
||||
|
|
|
@ -21,7 +21,7 @@ export let parseReference = (rules, rule, parsedRules, filter) => ({
|
|||
|
||||
let parsedRule =
|
||||
parsedRules[dottedName] ||
|
||||
// the 'inversion numérique' formula should not exist. The instructions to the evaluation should be enough to infer that an inversion is necessary (assuming it is possible, the client decides this)
|
||||
// the 'inversion numérique' formula should not exist. The instructions to the evaluation should be enough to infer that an inversion is necessary (assuming it is possible, the client decides this)
|
||||
(!inInversionFormula &&
|
||||
parseRule(rules, findRuleByDottedName(rules, dottedName), parsedRules))
|
||||
|
||||
|
@ -97,14 +97,16 @@ export let parseReference = (rules, rule, parsedRules, filter) => ({
|
|||
evaluate,
|
||||
//eslint-disable-next-line react/display-name
|
||||
jsx: nodeValue => (
|
||||
<Leaf
|
||||
classes="variable filtered"
|
||||
filter={filter}
|
||||
name={fragments.join(' . ')}
|
||||
dottedName={dottedName}
|
||||
value={nodeValue}
|
||||
unit={parsedRule.unit}
|
||||
/>
|
||||
<>
|
||||
<Leaf
|
||||
classes="variable filtered"
|
||||
filter={filter}
|
||||
name={fragments.join(' . ')}
|
||||
dottedName={dottedName}
|
||||
nodeValue={nodeValue}
|
||||
unit={parsedRule.unit}
|
||||
/>
|
||||
</>
|
||||
),
|
||||
|
||||
name: partialReference,
|
||||
|
|
Loading…
Reference in New Issue