mitai-jinkendo/frontend/src/widgetSystem/QuickCaptureConfigEditor.jsx
Lars 7f833b2cb1
All checks were successful
Deploy Development / deploy (push) Successful in 55s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s
feat: Introduce quick capture widget configuration and validation
- Added support for the "quick_capture" widget, allowing users to configure visibility for weight and baseline vitals (resting HR, HRV, VO₂max).
- Implemented validation logic to ensure correct configuration input and prevent errors.
- Updated the widget catalog and dashboard layout to reflect the new quick capture features.
- Removed the "training_type_distribution" widget from the catalog as part of the refactor.
- Bumped app_dashboard version to 1.6.2 to incorporate these enhancements.
2026-04-07 18:02:18 +02:00

68 lines
2.1 KiB
JavaScript

/**
* Sichtbarkeit der Teile im Schnelleingabe-Widget (Dashboard-Lab).
* Default: alle sichtbar (leeres config).
*/
const KEYS = [
{ key: 'show_weight', label: 'Gewicht' },
{ key: 'show_resting_hr', label: 'Ruhepuls' },
{ key: 'show_hrv', label: 'HRV' },
{ key: 'show_vo2_max', label: 'VO₂max' },
]
function mergeFromConfig(config) {
const c = config || {}
return {
show_weight: c.show_weight !== false,
show_resting_hr: c.show_resting_hr !== false,
show_hrv: c.show_hrv !== false,
show_vo2_max: c.show_vo2_max !== false,
}
}
/** @param {{ config: Record<string, unknown>, onChange: (next: Record<string, boolean>) => void }} props */
export default function QuickCaptureConfigEditor({ config, onChange }) {
const vis = mergeFromConfig(config)
const setKey = (k, checked) => {
const next = { ...vis, [k]: checked }
if (!next.show_weight && !next.show_resting_hr && !next.show_hrv && !next.show_vo2_max) {
return
}
const stored = {}
for (const { key } of KEYS) {
if (!next[key]) stored[key] = false
}
onChange(stored)
}
const resetAllVisible = () => onChange({})
return (
<div style={{ marginTop: 10, marginLeft: 28 }}>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 8, lineHeight: 1.5 }}>
<strong>Schnelleingabe:</strong> welche Bereiche angezeigt werden. Ohne Eintrag = alles sichtbar.
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{KEYS.map(({ key, label }) => (
<label key={key} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' }}>
<input
type="checkbox"
checked={vis[key]}
onChange={(e) => setKey(key, e.target.checked)}
/>
<span>{label}</span>
</label>
))}
</div>
<button
type="button"
className="btn btn-secondary"
style={{ marginTop: 10, fontSize: 12, padding: '6px 12px' }}
onClick={resetAllVisible}
>
Alle einblenden (Standard)
</button>
</div>
)
}