🌴 Regroupe les paquets core et react dans un dossier publicodes/

pull/1317/head
Maxime Quandalle 2020-12-15 12:46:57 +01:00
parent 3f7f3b6389
commit 50df2b3f34
158 changed files with 13 additions and 160 deletions

View File

@ -19,7 +19,7 @@ jobs:
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-v2
- run: npm install yarn
- run: yarn install
- run: yarn workspace mon-entreprise build

View File

@ -1,6 +1,6 @@
import { AssertionError } from 'chai'
import Engine, { parsePublicodes } from 'publicodes'
import { disambiguateRuleReference } from '../../publicodes/source/ruleUtils'
import { disambiguateRuleReference } from '../../publicodes/core/source/ruleUtils'
import rules from 'modele-social'
// les variables dans les tests peuvent être exprimées relativement à l'espace de nom de la règle,

View File

@ -2,7 +2,7 @@ import { expect } from 'chai'
import { parsePublicodes } from 'publicodes'
import { uniq } from 'ramda'
import rawRules from 'modele-social'
import unitsTranslations from '../../publicodes/source/locales/units.yaml'
import unitsTranslations from '../../publicodes/core/source/locales/units.yaml'
it('use unit that exists in publicode', () => {
const rules = parsePublicodes(rawRules)

View File

@ -122,8 +122,8 @@
"moso:up": "yarn workspace modele-social run up"
},
"workspaces": [
"publicodes",
"publicodes-react",
"publicodes/core",
"publicodes/react",
"modele-social",
"mon-entreprise"
]

View File

@ -1,147 +0,0 @@
import { path } from 'ramda'
import { useState } from 'react'
import Explanation from '../Explanation'
import { Mecanism, NodeValuePointer } from './common'
import styled from 'styled-components'
const SommeNode = ({ explanation, nodeValue, unit }) => (
<StyledSomme>
<Mecanism name="somme" value={nodeValue} unit={unit}>
<Table explanation={explanation} unit={unit} />
</Mecanism>
</StyledSomme>
)
export default SommeNode
// We want to put non applicable rules a the bottom of list #1055
function sortByApplicability(a, b) {
const isApplicable = (x) => x.nodeValue === false
if (isApplicable(a) === isApplicable(b)) {
return 0
}
return isApplicable(a) ? 1 : -1
}
let Table = ({ explanation, unit }) => (
<div
css={`
display: flex;
max-width: 100%;
flex-direction: column;
`}
>
<div>
{explanation.sort(sortByApplicability).map((v, i) => (
<Row key={i} {...{ v, i }} unit={unit} />
))}
</div>
</div>
)
/* La colonne peut au clic afficher une nouvelle colonne qui sera une autre somme imbriquée */
function Row({ v, i, unit }) {
let [folded, setFolded] = useState(true),
rowFormula = path(['explanation', 'formule', 'explanation'], v),
isSomme = rowFormula && rowFormula.name == 'somme'
return [
<StyledRow
key={v.name || i}
// className={isSomme ? '' : 'noNest'}
className={v.nodeValue === false ? 'notApplicable' : ''}
onClick={() => setFolded(!folded)}
>
<div className="element">
<Explanation node={v} />
{isSomme && (
<button className="unfoldIndication ui__ notice small static simple button">
{folded ? 'déplier' : 'replier'}
</button>
)}
</div>
{v.nodeValue != null && (
<div className="situationValue value">
<NodeValuePointer data={v.nodeValue} unit={v.unit} />
</div>
)}
</StyledRow>,
...(isSomme && !folded
? [
<div className="nested" key={v.name + '-nest'}>
<Table explanation={rowFormula.explanation} unit={v.unit || unit} />
</div>,
]
: []),
]
}
const StyledSomme = styled.div`
/* mécanisme somme */
table {
width: 100%;
border-collapse: collapse;
}
tr .element {
text-align: left;
padding: 0.2rem 0.4rem;
}
tr .value span {
text-align: right;
}
.nested {
padding: 0;
}
`
const StyledRow = styled.div`
display: flex;
align-items: center;
flex-flow: row nowrap;
:nth-child(2n) {
background-color: var(--lightestColor);
}
&.notApplicable {
opacity: 0.6;
}
.element .result,
.element > .variable > .nodeHead > .nodeValue {
display: none;
}
:first-child {
border-top: none;
}
.element {
flex: 1;
max-width: 100%;
display: flex;
align-items: baseline;
padding: 0.1em 0.4em;
padding-top: 0.2em;
overflow: hidden;
}
.element .unfoldIndication {
text-transform: capitalize;
flex: 1;
margin-left: 0.6rem;
text-align: left;
}
.element .variable,
.element .nodeHead {
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
.element .situationValue {
display: none !important;
}
/* Nested Mecanism */
+ .nested {
padding-left: 2em;
border-top: 1px dashed rgba(51, 51, 80, 0.15);
}
`

View File

@ -13,7 +13,7 @@ import {
import { Rule, RuleNode } from './rule'
import * as utils from './ruleUtils'
import { reduceAST } from './AST'
import mecanismsDoc from '../docs/mecanisms.yaml'
import mecanismsDoc from '../../docs/mecanisms.yaml'
const emptyCache = () => ({
_meta: { contextRule: [] },

View File

@ -13,7 +13,7 @@ import {
Temporal,
temporalAverage,
} from '../temporal'
import { mergeAllMissing } from './../evaluation'
import { mergeAllMissing } from '../evaluation'
export type VariationNode = {
explanation: Array<{

Some files were not shown because too many files have changed in this diff Show More