Skip to content

Commit

Permalink
Navigation complète dans l'agrégée
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBruant committed Mar 19, 2017
1 parent 580b761 commit 5cd22ae
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ rules:
- error
- unix
quotes: off
semi:
- error
- always
semi: off
no-console: off
7 changes: 5 additions & 2 deletions src/public/js/components/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default function ({breadcrumb, textsById, onContentChange}) {
const children = [];

breadcrumb.forEach((e, i) => {
const texts = textsById.get(e);
const label = texts && texts.label || e;

if (i < breadcrumb.size - 1) {
// all but last
children.push(
Expand All @@ -24,14 +27,14 @@ export default function ({breadcrumb, textsById, onContentChange}) {
onContentChange(breadcrumb.slice(0, i + 1));
}
},
textsById.get(e).label
label
),
' / '
);
}
else {
// last
children.push(textsById.get(e).label);
children.push(label);
}
});

Expand Down
2 changes: 0 additions & 2 deletions src/public/js/components/FinanceElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export default function ({contentId, total, texts, partition, onGoDeeper}) {

const label = texts && texts.get('label');

console.log('FinanceElementProps', contentId, partition);

return React.createElement('article', {className: 'finance-element'},
React.createElement('h1', {className: label ? '' : 'missing', 'data-id': contentId}, label),
React.createElement('h2', {}, format(total, { code: 'EUR' })),
Expand Down
2 changes: 1 addition & 1 deletion src/public/js/components/TopLevel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { HOME, FINANCE_EXPERT, EXPENDITURES } from '../constants/pages';
import { HOME, FINANCE_EXPERT } from '../constants/pages';

import Breadcrumb from './Breadcrumb';
import Home from './Home';
Expand Down
17 changes: 13 additions & 4 deletions src/public/js/navigationTree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { EXPENDITURES, REVENUE, DF, RF, DI, RI } from './constants/pages';

import {levelsByRDFI} from '../../shared/js/finance/hierarchicalAggregated';
import {flattenTree} from '../../shared/js/finance/visitHierarchical';

/*
This file is mostly a json file, but some parts are generated for easier maintenance reasons
*/
Expand All @@ -9,9 +12,15 @@ const exp = {};
exp[EXPENDITURES] = [ DF, DI ];
exp[REVENUE] = [ RF, RI ];

exp[DF] = ['DF-2', 'DF-3', 'DF-4', 'DF-5', 'DF-6', 'DF-7'];
//exp[RF] = ['DF-2', 'DF-3', 'DF-4', 'DF-5', 'DF-6', 'DF-7'];


[DF, RF, DI, RI].forEach(rdfi => {
flattenTree(levelsByRDFI[rdfi]).forEach(e => {
if(typeof e === 'string'){
// leaf case
return;
}

exp[e.id] = e.children.map(c => typeof c === 'string' ? c : c.id);
})
});

export default exp;
4 changes: 2 additions & 2 deletions src/shared/js/finance/hierarchicalAggregated.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const DFparPrestationChild = {
'DF-1-6',
'DF-1-7'
]
}
};



const levelsByRDFI = {
export const levelsByRDFI = {
'RF': {
id: 'RF',
label: 'Recettes de fonctionnement',
Expand Down
6 changes: 5 additions & 1 deletion src/shared/js/finance/visitHierarchical.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export default function visit(node, f){
f(node)

if(node.children){
Array.from(node.children.values()).forEach(child => {
const children = Array.isArray(node.children) ?
node.children :
Array.from(node.children.values())

children.forEach(child => {
visit(child, f);
})
}
Expand Down

0 comments on commit 5cd22ae

Please sign in to comment.