Refactor charts: dedicated nav tab, JSON data transport, tests

Replace the toggle-view approach and hidden DOM data carrier with a
proper dedicated Charts page:

- Move Charts out of Measurements view toggles into its own nav tab
  and route (GET /charts)
- ChartsController serializes readout data as JSON (ordered by
  taken_at); the view embeds it in a <script type="application/json">
  element instead of rendering a hidden copy of the measurements
  partial just to ferry data attributes to JS
- buildCharts() reads from the JSON element directly — no DOM parsing,
  no sorting in JS (server already orders the data)
- Turbo load handler detects the charts page via #charts-data presence
- Add controller tests (authentication, data shape, ordering,
  data isolation between users) and system tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 09:55:31 +00:00
parent 71c22f2280
commit 5051122bcd
10 changed files with 151 additions and 61 deletions

View File

@@ -661,29 +661,18 @@ li::marker {
overflow-x: auto;
}
body[data-measurements-view=wide] .measurements-compact,
body[data-measurements-view=wide] .measurements-charts,
body[data-measurements-view=compact] .measurements-wide,
body[data-measurements-view=compact] .measurements-charts,
body[data-measurements-view=charts] .measurements-compact,
body[data-measurements-view=charts] .measurements-wide {
body[data-measurements-view=compact] .measurements-wide {
display: none;
}
body[data-measurements-view=compact] .view-toggle[data-view=compact],
body[data-measurements-view=wide] .view-toggle[data-view=wide],
body[data-measurements-view=charts] .view-toggle[data-view=charts] {
body[data-measurements-view=wide] .view-toggle[data-view=wide] {
background-color: var(--color-blue);
border-color: var(--color-blue);
color: white;
fill: white;
}
.measurements-charts {
display: flex;
flex-wrap: wrap;
gap: 1em;
}
.chart-panel {
flex: 1 1 400px;
min-width: 300px;
width: 100%;
}
#measurements tr.grouped td {
border-top: none;