AP1.10c: Profil-Modal mit Archetyp, EFS und Owner.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m13s
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 18s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m13s
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 18s
Test Suite / playwright-smoke (push) Successful in 12s
InitiativeForm laedt Felder nach gewaehltem Archetyp; Plan-Profil zeigt Standardfelder und Zusatzfelder; actor_ref und Owner-Auswahl. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
43d30944aa
commit
dbe6f4f684
4 files changed
+207
-95
No files matched your search
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { RequireInitiativeScope } from '../../components/RequireInitiativeScope.jsx'
|
||||
import { ScopedInitiativeProvider } from '../../layout/ScopedInitiativeProvider.jsx'
|
||||
import { ArchetypeBadge } from '../../components/ArchetypeBadge.jsx'
|
||||
import { StatusBadge } from '../../components/StatusBadge.jsx'
|
||||
import { LoadingState } from '../../components/LoadingState.jsx'
|
||||
import { Modal } from '../../components/Modal.jsx'
|
||||
@@ -17,13 +18,15 @@ import {
|
||||
getInitiativeFields,
|
||||
} from '../../api/entityFields.js'
|
||||
|
||||
function DynamicFieldsDisplay({ initiativeId }) {
|
||||
function DynamicFieldsDisplay({ initiativeId, refreshKey = 0 }) {
|
||||
const [definitions, setDefinitions] = useState([])
|
||||
const [values, setValues] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
async function load() {
|
||||
setLoading(true)
|
||||
try {
|
||||
const [defs, fieldValues] = await Promise.all([
|
||||
getInitiativeFieldDefinitions(initiativeId),
|
||||
@@ -38,15 +41,21 @@ function DynamicFieldsDisplay({ initiativeId }) {
|
||||
setDefinitions([])
|
||||
setValues({})
|
||||
}
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false)
|
||||
}
|
||||
}
|
||||
load()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [initiativeId])
|
||||
}, [initiativeId, refreshKey])
|
||||
|
||||
if (!definitions.length || values === null) {
|
||||
if (loading || values === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!definitions.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -57,15 +66,25 @@ function DynamicFieldsDisplay({ initiativeId }) {
|
||||
})
|
||||
|
||||
if (!visible.length) {
|
||||
return null
|
||||
return (
|
||||
<div className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">Zusatzfelder (Archetyp)</h3>
|
||||
<p className="muted">Noch keine Werte für die Felder dieses Archetyps.</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
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>
|
||||
return (
|
||||
<div className="plan-profile__section">
|
||||
<h3 className="plan-profile__section-title">Zusatzfelder (Archetyp)</h3>
|
||||
{visible.map((def) => (
|
||||
<div key={def.field_key} className="plan-profile__field">
|
||||
<h4 className="plan-profile__label">{def.label}</h4>
|
||||
<p>{formatFieldValue(def, values[def.field_key])}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
function formatFieldValue(definition, value) {
|
||||
@@ -91,6 +110,7 @@ function PlanProfileInner() {
|
||||
projects,
|
||||
} = ops
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [fieldsRefreshKey, setFieldsRefreshKey] = useState(0)
|
||||
const canManage = capabilities.has('kairo.initiative.manage')
|
||||
|
||||
if (loading) {
|
||||
@@ -110,6 +130,7 @@ function PlanProfileInner() {
|
||||
const ok = await ops.handleUpdateInitiative(payload)
|
||||
if (ok) {
|
||||
refreshInitiativeMeta()
|
||||
setFieldsRefreshKey((key) => key + 1)
|
||||
setEditing(false)
|
||||
}
|
||||
}
|
||||
@@ -118,7 +139,13 @@ function PlanProfileInner() {
|
||||
<>
|
||||
<section className="card plan-profile">
|
||||
<header className="plan-profile__header">
|
||||
<h2 className="card-title">{initiative.title}</h2>
|
||||
<div>
|
||||
<h2 className="card-title">{initiative.title}</h2>
|
||||
<ArchetypeBadge
|
||||
archetypeKey={initiative.archetype_key}
|
||||
archetypes={initiativeArchetypes}
|
||||
/>
|
||||
</div>
|
||||
<div className="plan-profile__header-actions">
|
||||
<StatusBadge kind="initiative" status={initiative.status} />
|
||||
{canManage && (
|
||||
@@ -165,27 +192,29 @@ function PlanProfileInner() {
|
||||
<p>{initiative.goal}</p>
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted">Noch keine Kurzbeschreibung hinterlegt.</p>
|
||||
<p className="muted plan-profile__empty-hint">Noch keine Kurzbeschreibung hinterlegt.</p>
|
||||
)}
|
||||
{initiative.vision && (
|
||||
<div className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">Vision</h3>
|
||||
<p>{initiative.vision}</p>
|
||||
</div>
|
||||
)}
|
||||
{initiative.target_state_summary && (
|
||||
<div className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">Zielzustand</h3>
|
||||
<p>{initiative.target_state_summary}</p>
|
||||
</div>
|
||||
)}
|
||||
<DynamicFieldsDisplay initiativeId={initiative.id} key={editing ? 'closed' : 'open'} />
|
||||
<div className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">Vision</h3>
|
||||
<p>{initiative.vision?.trim() ? initiative.vision : '—'}</p>
|
||||
</div>
|
||||
<div className="plan-profile__field">
|
||||
<h3 className="plan-profile__label">Zielzustand (Kurzfassung)</h3>
|
||||
<p>
|
||||
{initiative.target_state_summary?.trim() ? initiative.target_state_summary : '—'}
|
||||
</p>
|
||||
</div>
|
||||
<DynamicFieldsDisplay
|
||||
initiativeId={initiative.id}
|
||||
refreshKey={fieldsRefreshKey}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<Modal open={editing} title="Vorhaben bearbeiten" onClose={() => setEditing(false)} size="lg">
|
||||
<InitiativeForm
|
||||
initiativeId={initiative.id}
|
||||
initial={initiative}
|
||||
actors={actors}
|
||||
onSubmit={handleSave}
|
||||
onCancel={() => setEditing(false)}
|
||||
busy={formBusy}
|
||||
|
||||
Reference in new issue
Block a user