revert: Wiederherstellung Codezustand von ca8cee9 (ohne Branch-Historie zu überschreiben)
Reverts cd29c7d..026c51b per git revert. Alle zwischenliegenden Commits bleiben in Gitea sichtbar; der Arbeitsbaum entspricht wieder dem Stand von ca8cee9.
Made-with: Cursor
This commit is contained in:
1 parent
026c51b6b5
commit
06f83e2ffc
10 files changed
+117
-503
No files matched your search
@@ -96,16 +96,6 @@ const ACTIVITY_LOG_PAYLOAD_KEYS = new Set([
|
||||
'training_subcategory',
|
||||
])
|
||||
|
||||
/** activity_log-Spalten, die im EntryForm editiert werden (Kurzform). */
|
||||
const ACTIVITY_ENTRY_FORM_COLUMNS = new Set([
|
||||
'duration_min',
|
||||
'kcal_active',
|
||||
'hr_avg',
|
||||
'hr_max',
|
||||
'rpe',
|
||||
'notes',
|
||||
])
|
||||
|
||||
function empty() {
|
||||
return {
|
||||
date: dayjs().format('YYYY-MM-DD'),
|
||||
@@ -123,9 +113,6 @@ function empty() {
|
||||
function buildMetricsPayload(schema, draft) {
|
||||
const out = []
|
||||
for (const s of schema) {
|
||||
if (s.source_field && ACTIVITY_LOG_PAYLOAD_KEYS.has(String(s.source_field))) {
|
||||
continue
|
||||
}
|
||||
const raw = draft[s.key]
|
||||
if (s.data_type === 'boolean') {
|
||||
if (raw === '' || raw === null || raw === undefined) {
|
||||
@@ -161,23 +148,14 @@ function SessionMetricsFields({ schema, values, setValues, metrics }) {
|
||||
const schemaList = Array.isArray(schema) ? schema : []
|
||||
const metricRows = Array.isArray(metrics) ? metrics : []
|
||||
const schemaKeys = new Set(schemaList.map((s) => s.key))
|
||||
const isHeadColumnMetric = (s) =>
|
||||
s && s.source_field && ACTIVITY_LOG_PAYLOAD_KEYS.has(String(s.source_field))
|
||||
const schemaForProfileOnly = schemaList.filter((s) => !isHeadColumnMetric(s))
|
||||
const orphanMetrics = metricRows.filter(
|
||||
(row) =>
|
||||
row &&
|
||||
row.key &&
|
||||
!schemaKeys.has(row.key) &&
|
||||
!ACTIVITY_LOG_PAYLOAD_KEYS.has(row.key)
|
||||
)
|
||||
const orphanMetrics = metricRows.filter((row) => row && row.key && !schemaKeys.has(row.key))
|
||||
|
||||
if (schemaForProfileOnly.length === 0 && orphanMetrics.length === 0) return null
|
||||
if (schemaList.length === 0 && orphanMetrics.length === 0) return null
|
||||
const set = (k, v) => setValues((prev) => ({ ...prev, [k]: v }))
|
||||
return (
|
||||
<div style={{ marginTop: 12, paddingTop: 12, borderTop: '1px solid var(--border)' }}>
|
||||
<div style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>Weitere Kennwerte (Profil)</div>
|
||||
{schemaForProfileOnly.map((s) => (
|
||||
{schemaList.map((s) => (
|
||||
<div key={s.key} className="form-row">
|
||||
<label className="form-label">
|
||||
{s.name_de}
|
||||
@@ -568,27 +546,6 @@ export default function ActivityPage() {
|
||||
setMetricDraft(m)
|
||||
}, [sessionDetail])
|
||||
|
||||
/** Nach GET /activity/:id: Kopf-Spalten ins EntryForm, wenn die Listenzeile leer war (Parameter-Keys vs. Spalten). */
|
||||
useEffect(() => {
|
||||
const h = sessionDetail?.header
|
||||
if (!h?.id || !editing?.id) return
|
||||
if (String(h.id) !== String(editing.id)) return
|
||||
setEditing((prev) => {
|
||||
if (String(h.id) !== String(prev.id)) return prev
|
||||
let changed = false
|
||||
const next = { ...prev }
|
||||
for (const col of ACTIVITY_ENTRY_FORM_COLUMNS) {
|
||||
const cur = next[col]
|
||||
const empty = cur === null || cur === undefined || cur === ''
|
||||
if (empty && h[col] != null && h[col] !== '') {
|
||||
next[col] = h[col]
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
return changed ? next : prev
|
||||
})
|
||||
}, [sessionDetail, editing?.id])
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true)
|
||||
setError(null)
|
||||
@@ -631,18 +588,8 @@ export default function ActivityPage() {
|
||||
for (const s of sessionDetail?.schema || []) {
|
||||
const col = s.source_field
|
||||
if (!col || !ACTIVITY_LOG_PAYLOAD_KEYS.has(col)) continue
|
||||
const useFormColumn = ACTIVITY_ENTRY_FORM_COLUMNS.has(col)
|
||||
if (!useFormColumn && !(s.key in metricDraft)) continue
|
||||
let raw
|
||||
if (useFormColumn) {
|
||||
const fromForm = editing[col]
|
||||
const fromDraft = metricDraft[s.key]
|
||||
const formEmpty = fromForm === null || fromForm === undefined || fromForm === ''
|
||||
const draftEmpty = fromDraft === null || fromDraft === undefined || fromDraft === ''
|
||||
raw = !formEmpty ? fromForm : !draftEmpty ? fromDraft : fromForm
|
||||
} else {
|
||||
raw = metricDraft[s.key]
|
||||
}
|
||||
if (!(s.key in metricDraft)) continue
|
||||
const raw = metricDraft[s.key]
|
||||
const rawStr = raw === null || raw === undefined ? '' : String(raw).trim()
|
||||
if (rawStr === '') {
|
||||
payload[col] = null
|
||||
|
||||
Reference in new issue
Block a user