AP1.10b/10c: Entity Field System mit dynamischen Vorhaben-Zusatzfeldern.
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 15s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 15s
EFS-Tabellen, Registry-Sync und Fields-API ermöglichen archetyp-spezifische Felder; Frontend rendert sie im Profil-Modal per FieldRenderer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
408050bcb8
commit
a6fc86025c
23 files changed
+1107
-20
No files matched your search
@@ -6,6 +6,7 @@ import { getWidgetsForArea } from '../../registry/widgetRegistry.js'
|
||||
import { useSession } from '../../context/SessionContext.jsx'
|
||||
import { InitiativeForm } from '../../components/InitiativeForm.jsx'
|
||||
import { createInitiative } from '../../api/initiatives.js'
|
||||
import { saveInitiativeDynamicFields, splitInitiativeFormPayload } from '../../api/entityFields.js'
|
||||
import { ModeShell } from '../../components/ModeShell.jsx'
|
||||
import { initiativeCatalogPath } from '../../utils/routes.js'
|
||||
|
||||
@@ -21,11 +22,13 @@ export function CockpitPage() {
|
||||
async function handleCreateInitiative(payload) {
|
||||
setFormBusy(true)
|
||||
setFormError(null)
|
||||
const { core, dynamicFields } = splitInitiativeFormPayload(payload)
|
||||
try {
|
||||
await createInitiative({
|
||||
...payload,
|
||||
const created = await createInitiative({
|
||||
...core,
|
||||
owner_actor_id: context?.actor?.id,
|
||||
})
|
||||
await saveInitiativeDynamicFields(created.id, dynamicFields)
|
||||
setShowForm(false)
|
||||
navigate(initiativeCatalogPath())
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { RequireInitiativeScope } from '../../components/RequireInitiativeScope.jsx'
|
||||
import { ScopedInitiativeProvider } from '../../layout/ScopedInitiativeProvider.jsx'
|
||||
import { StatusBadge } from '../../components/StatusBadge.jsx'
|
||||
@@ -8,6 +8,68 @@ import { InitiativeForm } from '../../components/InitiativeForm.jsx'
|
||||
import { useInitiativeOperations } from '../../context/InitiativeOperationsContext.jsx'
|
||||
import { useProgramScope } from '../../context/ProgramScopeContext.jsx'
|
||||
import { initiativeArchetypeLabel } from '../../constants/initiativeArchetypes.js'
|
||||
import {
|
||||
getInitiativeFieldDefinitions,
|
||||
getInitiativeFields,
|
||||
} from '../../api/entityFields.js'
|
||||
|
||||
function DynamicFieldsDisplay({ initiativeId }) {
|
||||
const [definitions, setDefinitions] = useState([])
|
||||
const [values, setValues] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
async function load() {
|
||||
try {
|
||||
const [defs, fieldValues] = await Promise.all([
|
||||
getInitiativeFieldDefinitions(initiativeId),
|
||||
getInitiativeFields(initiativeId),
|
||||
])
|
||||
if (!cancelled) {
|
||||
setDefinitions(defs)
|
||||
setValues(fieldValues)
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) {
|
||||
setDefinitions([])
|
||||
setValues({})
|
||||
}
|
||||
}
|
||||
}
|
||||
load()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [initiativeId])
|
||||
|
||||
if (!definitions.length || values === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
const visible = definitions.filter((def) => {
|
||||
const val = values[def.field_key]
|
||||
if (def.field_type === 'boolean') return val === true
|
||||
return val != null && String(val).trim() !== ''
|
||||
})
|
||||
|
||||
if (!visible.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return visible.map((def) => (
|
||||
<div key={def.field_key} className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">{def.label}</h3>
|
||||
<p>{formatFieldValue(def, values[def.field_key])}</p>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
function formatFieldValue(definition, value) {
|
||||
if (definition.field_type === 'boolean') {
|
||||
return value ? 'Ja' : 'Nein'
|
||||
}
|
||||
return String(value ?? '')
|
||||
}
|
||||
|
||||
function PlanProfileInner() {
|
||||
const ops = useInitiativeOperations()
|
||||
@@ -77,13 +139,12 @@ function PlanProfileInner() {
|
||||
<p>{initiative.target_state_summary}</p>
|
||||
</div>
|
||||
)}
|
||||
<p className="muted plan-profile__note">
|
||||
Dynamische Zusatzfelder (EFS) folgen in AP1.10c.
|
||||
</p>
|
||||
<DynamicFieldsDisplay initiativeId={initiative.id} key={editing ? 'closed' : 'open'} />
|
||||
</section>
|
||||
|
||||
<Modal open={editing} title="Vorhaben bearbeiten" onClose={() => setEditing(false)} size="lg">
|
||||
<InitiativeForm
|
||||
initiativeId={initiative.id}
|
||||
initial={initiative}
|
||||
onSubmit={handleSave}
|
||||
onCancel={() => setEditing(false)}
|
||||
|
||||
Reference in new issue
Block a user