Rebuild /dashboard with charts, add Grand livre/Dashboard nav

Nav: a small "Grand livre" / "Dashboard" switcher, top-right on both
pages, with the current page highlighted. Needed hook_theme() to
declare current_route as an accepted variable for both theme hooks --
same class of bug as the earlier can_view_history fix: an undeclared
variable passed via the render array is silently dropped rather than
reaching Twig.

Dashboard: replaced the old "solde par compte / par client" tables
(computed client-side from a full unwindowed JSON:API fetch of every
node -- the same performance problem the /lignes sliding window was
built to avoid, just not yet felt at 1500+ lines) with a single
aggregate endpoint (DashboardStatsController, plain SQL GROUP BY) and
five chart panels: CA par année, solde par compte (diverging,
red/green), solde par compte trend (small multiples per compte),
répartition par type, top clients par CA. No charting library --
small dependency-free div/CSS bar charts (HBarChart/ColumnChart/
MiniTrend components in dashboard.js), consistent with this project
vendoring its own JS.

Two data-correctness fixes along the way: (1) the historical stray
mistyped dates (0213-06-15, 2015-08-29 -- preserved as-is per this
module's policy) needed excluding from per-year buckets without
excluding their money from all-time totals, so the filtering happens
per-output-field in PHP rather than as a blanket SQL date range. (2)
PHP silently casts numeric-looking array keys ("2021") to actual
integers, so array_keys() on a year-keyed map produces a mix of ints
and strings -- json_encode emits the int ones as bare JSON numbers in
a list (unlike object keys, which JSON always stringifies), which
broke the frontend's annees[i].slice(2) trend-card labels. Fixed with
an explicit array_map('strval', ...).

Verified: bar widths/colors match the underlying data exactly (e.g.
EXT.'s red bar is proportionally sized against Maud's green one per
their actual solde ratio), all 8 trend cards render correct year
labels, and both nav links correctly highlight on their own page.
This commit is contained in:
2026-09-04 23:30:40 +02:00
parent 2947a542da
commit 2f9ad7d52c
9 changed files with 659 additions and 139 deletions
@@ -13,6 +13,45 @@
margin-block-start: 0 !important;
}
/* Grand livre / Dashboard switcher, top-right of both pages. Only present
on those two custom routes, but attached here (already loaded on every
page for the phantom-top-bar fix above) rather than duplicated between
home.css and dashboard.css -- and defined with its own explicit colors
rather than relying on either page's #figli-*-app-scoped custom
properties, since this <nav> sits outside both of those elements. */
.figli-page-nav {
display: flex;
justify-content: flex-end;
gap: 0.4rem;
padding: 0.5rem 0.25rem 0;
}
.figli-page-nav a {
padding: 0.3rem 0.8rem;
border-radius: 6px;
font-size: 0.82rem;
font-weight: 600;
text-decoration: none;
color: #6b7280;
border: 1px solid transparent;
}
.figli-page-nav a:hover {
border-color: #dcdee2;
}
.figli-page-nav a.is-active {
background: #eef1f6;
color: #1a1a1a;
}
html.gin--dark-mode .figli-page-nav a {
color: #a1a5ab;
}
html.gin--dark-mode .figli-page-nav a:hover {
border-color: #3d3e42;
}
html.gin--dark-mode .figli-page-nav a.is-active {
background: #2c2d30;
color: #e8e9ea;
}
/* Drupal status messages: fixed top-right, out of document flow, so they
never shift the page layout the way the default in-flow placement does
-- and shrunk to a fraction of Gin's default size, which is sized for a
@@ -26,51 +26,18 @@ html.gin--dark-mode #figli-dashboard-app {
}
#figli-dashboard-app h2 {
font-size: 1.25rem;
font-size: 1.1rem;
font-weight: 600;
margin: 2rem 0 0.75rem;
margin: 0 0 0.25rem;
color: var(--figli-text);
}
#figli-dashboard-app .figli-note {
color: var(--figli-text-light);
font-size: 0.875rem;
font-size: 0.8rem;
margin-bottom: 1rem;
}
#figli-dashboard-app table {
width: 100%;
border-collapse: collapse;
background: var(--figli-bg);
color: var(--figli-text);
border: 1px solid var(--figli-border);
border-radius: 6px;
overflow: hidden;
}
#figli-dashboard-app th,
#figli-dashboard-app td {
text-align: left;
padding: 0.5rem 0.85rem;
border-bottom: 1px solid var(--figli-border);
color: var(--figli-text);
}
#figli-dashboard-app th {
background: var(--figli-bg-alt);
font-weight: 600;
font-size: 0.85rem;
}
#figli-dashboard-app td.amount {
text-align: right;
font-variant-numeric: tabular-nums;
}
#figli-dashboard-app tr.positive td.amount { color: var(--figli-positive); }
#figli-dashboard-app tr.negative td.amount { color: var(--figli-error); }
#figli-dashboard-app tr.total td { font-weight: 700; border-top: 2px solid var(--figli-border); }
#figli-dashboard-app .figli-error {
background: #fde8e8;
border: 1px solid #f4a3a3;
@@ -78,3 +45,204 @@ html.gin--dark-mode #figli-dashboard-app {
padding: 0.75rem 1rem;
border-radius: 6px;
}
/* --- Summary cards --- */
#figli-dashboard-app .figli-summary-row {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
margin-bottom: 2rem;
}
#figli-dashboard-app .figli-summary-card {
flex: 1 1 200px;
background: var(--figli-bg-alt);
border: 1px solid var(--figli-border);
border-radius: 8px;
padding: 0.85rem 1rem;
}
#figli-dashboard-app .figli-summary-label {
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.02em;
color: var(--figli-text-light);
margin-bottom: 0.3rem;
}
#figli-dashboard-app .figli-summary-value {
font-size: 1.4rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
#figli-dashboard-app .figli-summary-value.is-positive { color: var(--figli-positive); }
#figli-dashboard-app .figli-summary-value.is-negative { color: var(--figli-error); }
/* --- Chart sections --- */
#figli-dashboard-app .figli-chart-section {
background: var(--figli-bg);
border: 1px solid var(--figli-border);
border-radius: 8px;
padding: 1.25rem 1.5rem 1.5rem;
margin-bottom: 1.5rem;
}
/* --- Horizontal bar chart (solde par compte, par type, top clients) --- */
#figli-dashboard-app .figli-hbar-chart {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
#figli-dashboard-app .figli-hbar-row {
display: grid;
grid-template-columns: 11rem 1fr 7rem;
align-items: center;
gap: 0.75rem;
}
#figli-dashboard-app .figli-hbar-label {
font-size: 0.82rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#figli-dashboard-app .figli-hbar-track {
position: relative;
height: 0.9rem;
background: var(--figli-bg-alt);
border-radius: 4px;
overflow: hidden;
}
#figli-dashboard-app .figli-hbar-track.is-diverging {
overflow: visible;
}
#figli-dashboard-app .figli-hbar-zero {
position: absolute;
top: -2px;
bottom: -2px;
left: 50%;
width: 1px;
background: var(--figli-border);
}
#figli-dashboard-app .figli-hbar-fill {
position: absolute;
top: 0;
bottom: 0;
border-radius: 3px;
min-width: 2px;
}
@media (prefers-reduced-motion: no-preference) {
#figli-dashboard-app .figli-hbar-fill {
transition: width 0.3s ease;
}
}
#figli-dashboard-app .figli-hbar-value {
font-size: 0.8rem;
font-variant-numeric: tabular-nums;
text-align: right;
white-space: nowrap;
}
/* --- Vertical bar chart (CA par année) --- */
#figli-dashboard-app .figli-vbar-chart {
display: flex;
align-items: flex-end;
gap: 1rem;
height: 12rem;
padding-top: 1.5rem;
}
#figli-dashboard-app .figli-vbar-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
#figli-dashboard-app .figli-vbar-value {
font-size: 0.75rem;
font-weight: 600;
margin-bottom: 0.3rem;
white-space: nowrap;
}
#figli-dashboard-app .figli-vbar-track {
flex: 1;
width: 100%;
display: flex;
align-items: flex-end;
}
#figli-dashboard-app .figli-vbar-fill {
width: 100%;
background: var(--figli-positive);
border-radius: 4px 4px 0 0;
min-height: 2px;
}
@media (prefers-reduced-motion: no-preference) {
#figli-dashboard-app .figli-vbar-fill {
transition: height 0.3s ease;
}
}
#figli-dashboard-app .figli-vbar-label {
font-size: 0.78rem;
color: var(--figli-text-light);
margin-top: 0.4rem;
}
/* --- Trend grid (small multiples, one per compte) --- */
#figli-dashboard-app .figli-trend-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
gap: 1rem;
}
#figli-dashboard-app .figli-trend-card {
background: var(--figli-bg-alt);
border: 1px solid var(--figli-border);
border-radius: 6px;
padding: 0.75rem;
}
#figli-dashboard-app .figli-trend-title {
font-size: 0.85rem;
font-weight: 600;
margin-bottom: 0.5rem;
}
#figli-dashboard-app .figli-mini-trend {
display: flex;
align-items: stretch;
gap: 0.2rem;
height: 4.5rem;
}
#figli-dashboard-app .figli-mini-bar-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
#figli-dashboard-app .figli-mini-bar-track {
position: relative;
flex: 1;
width: 100%;
}
#figli-dashboard-app .figli-mini-bar-track::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 1px;
background: var(--figli-border);
}
#figli-dashboard-app .figli-mini-bar-fill {
position: absolute;
left: 1px;
right: 1px;
border-radius: 2px;
}
#figli-dashboard-app .figli-mini-bar-fill.is-positive {
bottom: 50%;
background: var(--figli-positive);
}
#figli-dashboard-app .figli-mini-bar-fill.is-negative {
top: 50%;
background: var(--figli-error);
}
#figli-dashboard-app .figli-mini-bar-label {
font-size: 0.65rem;
color: var(--figli-text-light);
margin-top: 0.25rem;
}