Enhance Skill Scoring and Profile Features
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
- Updated the skill scoring specification to include club-specific metrics and improved aggregation methods for skill profiles. - Introduced new API endpoints for batch skill profile summaries, allowing for efficient retrieval of compact skill data. - Enhanced frontend components to display skill profiles with club comparisons, improving user interaction and visibility of skill strengths. - Added filtering options for skills in the framework programs, enabling users to refine selections based on training weight relative to club maximums. - Improved CSS styles for skill profile displays, ensuring a cohesive and user-friendly interface across the application.
This commit is contained in:
1 parent
5200895a73
commit
78c6c51520
15 files changed
+1131
-141
No files matched your search
@@ -24,3 +24,17 @@ export async function getSkillDiscoverySuggestions(skillIds, opts = {}) {
|
||||
if (opts.limit != null) params.set('limit', String(opts.limit))
|
||||
return request(`/api/skill-discovery/suggestions?${params.toString()}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch-Summaries für Listen (ein Vereins-Corpus-Scan).
|
||||
* @param {{ frameworkProgramIds?: number[], trainingModuleIds?: number[] }} payload
|
||||
*/
|
||||
export async function batchSkillProfileSummaries(payload = {}) {
|
||||
return request('/api/skill-profiles/batch-summaries', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
framework_program_ids: payload.frameworkProgramIds || [],
|
||||
training_module_ids: payload.trainingModuleIds || [],
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -2690,6 +2690,107 @@ html.modal-scroll-locked .app-main {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.skill-profile-compact {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.skill-profile-compact__label {
|
||||
display: block;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--text3);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.skill-profile-compact__list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.skill-profile-compact__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 8px;
|
||||
background: var(--surface2);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.skill-profile-compact__name {
|
||||
font-weight: 600;
|
||||
font-size: 0.86rem;
|
||||
color: var(--text1);
|
||||
}
|
||||
.skill-profile-compact__metric {
|
||||
font-size: 0.78rem;
|
||||
font-weight: 700;
|
||||
color: var(--accent-dark);
|
||||
}
|
||||
.skill-profile-compact__best {
|
||||
margin: 0;
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.fw-prog-card__section-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.fw-prog-card__section--skills {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
.fw-import-skill-grid {
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.skill-profile-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1200;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding: 24px 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.skill-profile-modal__backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
border: none;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
cursor: pointer;
|
||||
}
|
||||
.skill-profile-modal__panel {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: min(42rem, 100%);
|
||||
max-height: calc(100vh - 48px);
|
||||
overflow-y: auto;
|
||||
padding: 1rem 1.1rem 1.25rem;
|
||||
margin-top: 2vh;
|
||||
}
|
||||
.skill-profile-modal__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
.skill-profile-modal__title {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
.skill-profile-modal__scale {
|
||||
margin: 0.5rem 0 0;
|
||||
}
|
||||
|
||||
.skill-discovery {
|
||||
padding: 1.15rem 1.25rem;
|
||||
max-width: 52rem;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import NavStateLink from '../NavStateLink'
|
||||
import SkillProfileCompact from '../skills/SkillProfileCompact'
|
||||
import {
|
||||
frameworkSessionDurationLabel,
|
||||
splitFrameworkCommaAgg,
|
||||
@@ -26,7 +27,16 @@ function CatalogGroup({ label, items, variant }) {
|
||||
/**
|
||||
* Einzelkarte für die Rahmenprogramm-Bibliothek.
|
||||
*/
|
||||
export default function FrameworkProgramListCard({ row, returnContext, onDelete }) {
|
||||
export default function FrameworkProgramListCard({
|
||||
row,
|
||||
returnContext,
|
||||
onDelete,
|
||||
skillSummary = null,
|
||||
skillSummaryLoading = false,
|
||||
skillFilterIds = [],
|
||||
skillDisplayLimit = 6,
|
||||
onShowSkillProfile,
|
||||
}) {
|
||||
const title = (row.title || '').trim() || `Rahmen #${row.id}`
|
||||
const description = (row.description || '').trim()
|
||||
const durationLabel = frameworkSessionDurationLabel(row)
|
||||
@@ -112,6 +122,27 @@ export default function FrameworkProgramListCard({ row, returnContext, onDelete
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
<section className="fw-prog-card__section fw-prog-card__section--skills">
|
||||
<div className="fw-prog-card__section-head">
|
||||
<h3 className="fw-prog-card__section-title">Fähigkeiten</h3>
|
||||
{onShowSkillProfile ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-small fw-prog-card__skills-btn"
|
||||
onClick={() => onShowSkillProfile(row)}
|
||||
>
|
||||
Vollständiges Profil
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<SkillProfileCompact
|
||||
summary={skillSummary}
|
||||
skillIds={skillFilterIds}
|
||||
loading={skillSummaryLoading}
|
||||
displayLimit={skillDisplayLimit}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<footer className="fw-prog-card__actions">
|
||||
<NavStateLink
|
||||
to={`/planning/framework-programs/${row.id}`}
|
||||
|
||||
@@ -20,6 +20,8 @@ export default function FrameworkProgramsFilterBlock({
|
||||
catalogFocusAreas = [],
|
||||
catalogTrainingTypes = [],
|
||||
catalogTargetGroups = [],
|
||||
catalogSkills = [],
|
||||
skillSummaries = null,
|
||||
disabled = false,
|
||||
durationRadioName = 'fw-duration-mode',
|
||||
showHint = true,
|
||||
@@ -31,8 +33,8 @@ export default function FrameworkProgramsFilterBlock({
|
||||
)
|
||||
|
||||
const matchCount = useMemo(
|
||||
() => filterFrameworkPrograms(programs, filters).length,
|
||||
[programs, filters]
|
||||
() => filterFrameworkPrograms(programs, filters, skillSummaries).length,
|
||||
[programs, filters, skillSummaries]
|
||||
)
|
||||
|
||||
const totalCount = (programs || []).length
|
||||
@@ -43,8 +45,9 @@ export default function FrameworkProgramsFilterBlock({
|
||||
focusAreas: catalogFocusAreas,
|
||||
trainingTypes: catalogTrainingTypes,
|
||||
targetGroups: catalogTargetGroups,
|
||||
skills: catalogSkills,
|
||||
}),
|
||||
[filters, catalogFocusAreas, catalogTrainingTypes, catalogTargetGroups]
|
||||
[filters, catalogFocusAreas, catalogTrainingTypes, catalogTargetGroups, catalogSkills]
|
||||
)
|
||||
|
||||
const updateFilter = (patch) => onFiltersChange((prev) => ({ ...prev, ...patch }))
|
||||
@@ -285,6 +288,61 @@ export default function FrameworkProgramsFilterBlock({
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{catalogSkills.length > 0 ? (
|
||||
<div className="fw-import-catalog-block fw-import-catalog-block--skills">
|
||||
<span className="form-label">Fähigkeiten (Vereinsvergleich)</span>
|
||||
<p className="form-sub" style={{ margin: '0 0 8px' }}>
|
||||
Filtert nach Trainingsgewicht relativ zum stärksten Vereins-Programm je Fähigkeit — ohne
|
||||
Punktewerte eingeben.
|
||||
</p>
|
||||
<div className="framework-catalog-checkgrid fw-import-skill-grid">
|
||||
{catalogSkills.map((sk) => (
|
||||
<label key={sk.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={(filters.skillIds || []).includes(String(sk.id))}
|
||||
onChange={() => toggleId('skillIds', sk.id)}
|
||||
disabled={disabled}
|
||||
/>
|
||||
<span>{sk.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{(filters.skillIds || []).length > 0 ? (
|
||||
<div className="fw-import-skill-options">
|
||||
<div className="form-row" style={{ marginBottom: 8 }}>
|
||||
<label className="form-label">Mindest-Anteil am Vereins-Maximum</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={String(filters.skillMinClubPercent ?? 0)}
|
||||
disabled={disabled}
|
||||
onChange={(e) =>
|
||||
updateFilter({ skillMinClubPercent: Number(e.target.value) || 0 })
|
||||
}
|
||||
>
|
||||
<option value="0">Kein Minimum (nur markieren)</option>
|
||||
<option value="25">mind. 25%</option>
|
||||
<option value="50">mind. 50%</option>
|
||||
<option value="75">mind. 75%</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="form-row" style={{ marginBottom: 0 }}>
|
||||
<label className="form-label">Sortierung</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={filters.skillSort || 'title'}
|
||||
disabled={disabled}
|
||||
onChange={(e) => updateFilter({ skillSort: e.target.value })}
|
||||
>
|
||||
<option value="title">Bibliotheks-Reihenfolge</option>
|
||||
<option value="skill_strength">Stärkste gewählte Fähigkeit zuerst</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{showHint ? (
|
||||
<p className="form-sub fw-import-filter-panel__hint">
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import React from 'react'
|
||||
import {
|
||||
artifactPath,
|
||||
artifactTypeLabel,
|
||||
compactSkillDisplayRows,
|
||||
formatClubPercent,
|
||||
} from '../../utils/skillProfileListHelpers'
|
||||
|
||||
function formatWeight(value) {
|
||||
const n = Number(value)
|
||||
if (!Number.isFinite(n)) return '0'
|
||||
return n % 1 === 0 ? String(n) : n.toFixed(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Kompakte Fähigkeiten-Zeile für Listen/Kacheln.
|
||||
*/
|
||||
export default function SkillProfileCompact({
|
||||
summary,
|
||||
skillIds = [],
|
||||
loading = false,
|
||||
emptyText = 'Noch keine Übungen mit Fähigkeiten',
|
||||
displayLimit = 6,
|
||||
showClubBest = true,
|
||||
}) {
|
||||
if (loading) {
|
||||
return <p className="skill-profile-compact skill-profile-compact--loading form-sub">Fähigkeiten werden berechnet…</p>
|
||||
}
|
||||
|
||||
const rows = compactSkillDisplayRows(summary, { skillIds, limit: displayLimit })
|
||||
|
||||
if (!rows.length) {
|
||||
return summary ? (
|
||||
<p className="skill-profile-compact skill-profile-compact--empty form-sub">{emptyText}</p>
|
||||
) : null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="skill-profile-compact">
|
||||
<span className="skill-profile-compact__label">Fähigkeiten</span>
|
||||
<ul className="skill-profile-compact__list">
|
||||
{rows.map((sk) => {
|
||||
const best = sk.club_best
|
||||
const path = showClubBest && best ? artifactPath(best) : null
|
||||
return (
|
||||
<li key={sk.skill_id} className="skill-profile-compact__item">
|
||||
<span className="skill-profile-compact__name" title={sk.skill_name}>
|
||||
{sk.skill_name}
|
||||
</span>
|
||||
<span className="skill-profile-compact__metric" title="Trainingsgewicht und Anteil am Vereins-Maximum">
|
||||
{formatWeight(sk.weight)} · {formatClubPercent(sk.universal_percent)} Verein
|
||||
</span>
|
||||
{showClubBest && best && path && sk.universal_percent != null && sk.universal_percent < 100 ? (
|
||||
<span className="skill-profile-compact__best form-sub">
|
||||
Vereins-Top: {artifactTypeLabel(best.artifact_type)} „{best.artifact_title || best.artifact_id}“ (
|
||||
{formatWeight(best.weight)})
|
||||
</span>
|
||||
) : sk.universal_percent >= 100 ? (
|
||||
<span className="skill-profile-compact__best form-sub">Stärkste Vereins-Nutzung dieser Fähigkeit</span>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import api from '../../utils/api'
|
||||
import SkillProfilePanel from './SkillProfilePanel'
|
||||
|
||||
/**
|
||||
* Vollständiges Fähigkeiten-Profil in einem Modal (Listen-Kontext).
|
||||
*/
|
||||
export default function SkillProfileFullModal({
|
||||
open,
|
||||
onClose,
|
||||
artifactType = 'framework_program',
|
||||
artifactId,
|
||||
title = 'Fähigkeiten-Profil',
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
const [data, setData] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !artifactId) return undefined
|
||||
let cancelled = false
|
||||
setLoading(true)
|
||||
setError('')
|
||||
setData(null)
|
||||
const load =
|
||||
artifactType === 'training_module'
|
||||
? api.getTrainingModuleSkillProfile(artifactId)
|
||||
: artifactType === 'progression_graph'
|
||||
? api.getProgressionGraphSkillProfile(artifactId)
|
||||
: api.getFrameworkProgramSkillProfile(artifactId)
|
||||
load
|
||||
.then((res) => {
|
||||
if (!cancelled) setData(res)
|
||||
})
|
||||
.catch((e) => {
|
||||
if (!cancelled) setError(e.message || 'Profil konnte nicht geladen werden')
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setLoading(false)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [open, artifactId, artifactType])
|
||||
|
||||
if (!open) return null
|
||||
|
||||
return (
|
||||
<div className="skill-profile-modal" role="dialog" aria-modal="true" aria-labelledby="skill-profile-modal-title">
|
||||
<button type="button" className="skill-profile-modal__backdrop" aria-label="Schließen" onClick={onClose} />
|
||||
<div className="skill-profile-modal__panel card">
|
||||
<header className="skill-profile-modal__head">
|
||||
<h2 id="skill-profile-modal-title" className="skill-profile-modal__title">
|
||||
{title}
|
||||
</h2>
|
||||
<button type="button" className="btn btn-secondary btn-small" onClick={onClose}>
|
||||
Schließen
|
||||
</button>
|
||||
</header>
|
||||
<SkillProfilePanel
|
||||
profile={data?.overall}
|
||||
slots={artifactType === 'framework_program' ? data?.slots : null}
|
||||
loading={loading}
|
||||
error={error}
|
||||
title="Vollständiges Profil"
|
||||
defaultExpanded
|
||||
/>
|
||||
{data?.reference_scale?.scope === 'club' && !loading ? (
|
||||
<p className="form-sub skill-profile-modal__scale">
|
||||
Vergleichsbasis: {data.reference_scale.artifacts_scanned ?? 0} Vereins-Artefakte (
|
||||
{data.reference_scale.skills_in_corpus ?? 0} Fähigkeiten mit Referenz).
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ function barFillPercent(skill, maxWeight, hasReferenceScale) {
|
||||
|
||||
function metricLabel(skill, hasReferenceScale) {
|
||||
if (hasReferenceScale && skill?.universal_percent != null) {
|
||||
return `${skill.universal_percent}% Bibliothek`
|
||||
return `${skill.universal_percent}% vom Vereins-Maximum`
|
||||
}
|
||||
return formatWeight(skillWeight(skill))
|
||||
}
|
||||
@@ -43,7 +43,14 @@ function CategoryTopSkill({ skill, maxWeight, hasReferenceScale }) {
|
||||
</div>
|
||||
{hasReferenceScale ? (
|
||||
<span className="skill-profile__meta-hint">
|
||||
Absolut: {formatWeight(skillWeight(skill))} · Skala über alle Programme
|
||||
Trainingsgewicht {formatWeight(skillWeight(skill))}
|
||||
{skill.club_best ? (
|
||||
<>
|
||||
{' '}
|
||||
· Vereins-Top: {skill.club_best.artifact_title || skill.club_best.artifact_id} (
|
||||
{formatWeight(skill.club_best.weight)})
|
||||
</>
|
||||
) : null}
|
||||
</span>
|
||||
) : null}
|
||||
</li>
|
||||
@@ -111,7 +118,7 @@ export default function SkillProfilePanel({
|
||||
loading = false,
|
||||
error = '',
|
||||
title = 'Fähigkeiten-Profil',
|
||||
hint = 'Aus verknüpften Übungen berechnet (Dauer, Vorkommen, Intensität, Stufen von/bis). Trainingsgewicht ist über Programme vergleichbar; die Balken zeigen die Stärke relativ zur Bibliothek.',
|
||||
hint = 'Trainingsgewicht aus Dauer, Häufigkeit, Intensität und Stufen-Spanne. Vergleich nur im aktiven Verein (visibility=club). Pro Kategorie die stärkste Fähigkeit; Balken = Anteil am Vereins-Maximum dieser Fähigkeit.',
|
||||
defaultExpanded = true,
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(defaultExpanded)
|
||||
|
||||
@@ -3,6 +3,7 @@ import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import FrameworkProgramsFilterBlock from '../components/planning/FrameworkProgramsFilterBlock'
|
||||
import FrameworkProgramListCard from '../components/planning/FrameworkProgramListCard'
|
||||
import SkillProfileFullModal from '../components/skills/SkillProfileFullModal'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildFrameworkProgramsListReturnContext } from '../utils/navReturnContext'
|
||||
@@ -22,12 +23,16 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
const [catalogFocusAreas, setCatalogFocusAreas] = useState([])
|
||||
const [catalogTrainingTypes, setCatalogTrainingTypes] = useState([])
|
||||
const [catalogTargetGroups, setCatalogTargetGroups] = useState([])
|
||||
const [catalogSkills, setCatalogSkills] = useState([])
|
||||
const [filters, setFilters] = useState(() => ({ ...EMPTY_FRAMEWORK_IMPORT_FILTERS }))
|
||||
const [filterPanelOpen, setFilterPanelOpen] = useState(true)
|
||||
const [skillSummaries, setSkillSummaries] = useState({})
|
||||
const [summariesLoading, setSummariesLoading] = useState(false)
|
||||
const [profileModal, setProfileModal] = useState(null)
|
||||
|
||||
const filteredRows = useMemo(
|
||||
() => filterFrameworkPrograms(rows, filters),
|
||||
[rows, filters]
|
||||
() => filterFrameworkPrograms(rows, filters, skillSummaries),
|
||||
[rows, filters, skillSummaries]
|
||||
)
|
||||
const filterActive = hasActiveFrameworkImportFilters(filters)
|
||||
|
||||
@@ -35,22 +40,25 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
setLoading(true)
|
||||
setError('')
|
||||
try {
|
||||
const [list, fa, tt, tg] = await Promise.all([
|
||||
const [list, fa, tt, tg, skills] = await Promise.all([
|
||||
api.listTrainingFrameworkPrograms(),
|
||||
api.listFocusAreas({ status: 'active' }),
|
||||
api.listTrainingTypes({ status: 'active' }),
|
||||
api.listTargetGroups({ status: 'active' }),
|
||||
api.listSkills({ status: 'active' }),
|
||||
])
|
||||
setRows(Array.isArray(list) ? list : [])
|
||||
setCatalogFocusAreas(Array.isArray(fa) ? fa : [])
|
||||
setCatalogTrainingTypes(Array.isArray(tt) ? tt : [])
|
||||
setCatalogTargetGroups(Array.isArray(tg) ? tg : [])
|
||||
setCatalogSkills(Array.isArray(skills) ? skills : [])
|
||||
} catch (e) {
|
||||
setError(e.message || 'Laden fehlgeschlagen')
|
||||
setRows([])
|
||||
setCatalogFocusAreas([])
|
||||
setCatalogTrainingTypes([])
|
||||
setCatalogTargetGroups([])
|
||||
setCatalogSkills([])
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -60,6 +68,29 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
load()
|
||||
}, [load, tenantClubDepKey])
|
||||
|
||||
useEffect(() => {
|
||||
if (!rows.length) {
|
||||
setSkillSummaries({})
|
||||
return undefined
|
||||
}
|
||||
let cancelled = false
|
||||
setSummariesLoading(true)
|
||||
api
|
||||
.batchSkillProfileSummaries({ frameworkProgramIds: rows.map((r) => r.id) })
|
||||
.then((data) => {
|
||||
if (!cancelled) setSkillSummaries(data?.summaries || {})
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setSkillSummaries({})
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setSummariesLoading(false)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [rows, tenantClubDepKey])
|
||||
|
||||
async function handleDelete(id, title) {
|
||||
if (!confirm(`Rahmenprogramm „${title || id}“ wirklich löschen?`)) return
|
||||
try {
|
||||
@@ -136,6 +167,8 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
catalogFocusAreas={catalogFocusAreas}
|
||||
catalogTrainingTypes={catalogTrainingTypes}
|
||||
catalogTargetGroups={catalogTargetGroups}
|
||||
catalogSkills={catalogSkills}
|
||||
skillSummaries={skillSummaries}
|
||||
durationRadioName="fw-list-duration-mode"
|
||||
className="fw-prog-filter-block--list"
|
||||
/>
|
||||
@@ -157,6 +190,17 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
row={r}
|
||||
returnContext={frameworkListReturn}
|
||||
onDelete={handleDelete}
|
||||
skillSummary={skillSummaries[`framework_program:${r.id}`]}
|
||||
skillSummaryLoading={summariesLoading}
|
||||
skillFilterIds={filters.skillIds || []}
|
||||
skillDisplayLimit={filters.skillDisplayLimit || 10}
|
||||
onShowSkillProfile={(row) =>
|
||||
setProfileModal({
|
||||
artifactType: 'framework_program',
|
||||
artifactId: row.id,
|
||||
title: (row.title || '').trim() || `Rahmen #${row.id}`,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
@@ -164,6 +208,14 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<SkillProfileFullModal
|
||||
open={Boolean(profileModal)}
|
||||
onClose={() => setProfileModal(null)}
|
||||
artifactType={profileModal?.artifactType}
|
||||
artifactId={profileModal?.artifactId}
|
||||
title={profileModal?.title}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import SkillProfileCompact from '../components/skills/SkillProfileCompact'
|
||||
import SkillProfileFullModal from '../components/skills/SkillProfileFullModal'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildTrainingModulesListReturnContext } from '../utils/navReturnContext'
|
||||
@@ -12,6 +14,9 @@ export default function TrainingModulesListPage() {
|
||||
const [rows, setRows] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [skillSummaries, setSkillSummaries] = useState({})
|
||||
const [summariesLoading, setSummariesLoading] = useState(false)
|
||||
const [profileModal, setProfileModal] = useState(null)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
@@ -31,6 +36,29 @@ export default function TrainingModulesListPage() {
|
||||
load()
|
||||
}, [load, tenantClubDepKey])
|
||||
|
||||
useEffect(() => {
|
||||
if (!rows.length) {
|
||||
setSkillSummaries({})
|
||||
return undefined
|
||||
}
|
||||
let cancelled = false
|
||||
setSummariesLoading(true)
|
||||
api
|
||||
.batchSkillProfileSummaries({ trainingModuleIds: rows.map((r) => r.id) })
|
||||
.then((data) => {
|
||||
if (!cancelled) setSkillSummaries(data?.summaries || {})
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setSkillSummaries({})
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setSummariesLoading(false)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [rows, tenantClubDepKey])
|
||||
|
||||
async function handleDelete(id, title) {
|
||||
if (!confirm(`Trainingsmodul „${title || id}“ wirklich löschen?`)) return
|
||||
try {
|
||||
@@ -58,8 +86,7 @@ export default function TrainingModulesListPage() {
|
||||
Trainingsmodule
|
||||
</h1>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.95rem', maxWidth: '38rem', margin: 0 }}>
|
||||
Wiederverwendbare Übungsfolgen für die Trainingsplanung. Übernahme in eine Einheit erfolgt dort als
|
||||
lokale Kopie (mit Herkunftsmarkierung).
|
||||
Wiederverwendbare Übungsfolgen für die Trainingsplanung. Fähigkeiten werden im Vereinskontext verglichen.
|
||||
</p>
|
||||
</div>
|
||||
<NavStateLink
|
||||
@@ -114,11 +141,28 @@ export default function TrainingModulesListPage() {
|
||||
({Number(r.items_count) || 0} Position{r.items_count === 1 ? '' : 'en'})
|
||||
</span>
|
||||
</p>
|
||||
<p style={{ margin: '0.35rem 0 0', fontSize: '0.8rem', color: 'var(--text3)' }}>
|
||||
Sichtbarkeit: <strong>{r.visibility || '—'}</strong>
|
||||
</p>
|
||||
<div style={{ marginTop: '0.65rem' }}>
|
||||
<SkillProfileCompact
|
||||
summary={skillSummaries[`training_module:${r.id}`]}
|
||||
loading={summariesLoading}
|
||||
displayLimit={4}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-small"
|
||||
onClick={() =>
|
||||
setProfileModal({
|
||||
artifactType: 'training_module',
|
||||
artifactId: r.id,
|
||||
title: (r.title || '').trim() || `Modul #${r.id}`,
|
||||
})
|
||||
}
|
||||
>
|
||||
Fähigkeiten-Profil
|
||||
</button>
|
||||
<NavStateLink
|
||||
to={`/planning/training-modules/${r.id}`}
|
||||
returnContext={modulesListReturn}
|
||||
@@ -136,6 +180,14 @@ export default function TrainingModulesListPage() {
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<SkillProfileFullModal
|
||||
open={Boolean(profileModal)}
|
||||
onClose={() => setProfileModal(null)}
|
||||
artifactType={profileModal?.artifactType}
|
||||
artifactId={profileModal?.artifactId}
|
||||
title={profileModal?.title}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
import { formatDurationDisplay, formatSessionDurationRange } from './trainingDurationUtils'
|
||||
import {
|
||||
frameworkSkillSummaryKey,
|
||||
maxSelectedSkillClubPercent,
|
||||
skillEntryFromSummary,
|
||||
} from './skillProfileListHelpers'
|
||||
|
||||
export function frameworkSessionDurationLabel(row) {
|
||||
return formatSessionDurationRange(row?.session_duration_min, row?.session_duration_max, {
|
||||
@@ -109,6 +114,10 @@ export const EMPTY_FRAMEWORK_IMPORT_FILTERS = {
|
||||
durationRangeFrom: '',
|
||||
durationRangeTo: '',
|
||||
durationPresetMin: null,
|
||||
skillIds: [],
|
||||
skillSort: 'title',
|
||||
skillMinClubPercent: 0,
|
||||
skillDisplayLimit: 10,
|
||||
}
|
||||
|
||||
export function hasActiveFrameworkImportFilters(filters = {}) {
|
||||
@@ -122,6 +131,9 @@ export function hasActiveFrameworkImportFilters(filters = {}) {
|
||||
if (String(f.durationRangeTo || '').trim() !== '') return true
|
||||
}
|
||||
if (f.durationMode === 'preset' && f.durationPresetMin != null) return true
|
||||
if ((f.skillIds || []).length) return true
|
||||
if (Number(f.skillMinClubPercent) > 0) return true
|
||||
if (f.skillSort === 'skill_strength' && (f.skillIds || []).length) return true
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -136,6 +148,17 @@ export function summarizeFrameworkImportFilters(filters = {}, catalogs = {}) {
|
||||
|
||||
const nameById = (list, id) => list?.find((x) => String(x.id) === String(id))?.name || id
|
||||
|
||||
if ((f.skillIds || []).length) {
|
||||
const names = f.skillIds.map((id) => nameById(catalogs.skills, id))
|
||||
parts.push(`Fähigkeiten: ${names.join(', ')}`)
|
||||
}
|
||||
if (Number(f.skillMinClubPercent) > 0) {
|
||||
parts.push(`mind. ${f.skillMinClubPercent}% vom Vereins-Maximum`)
|
||||
}
|
||||
if (f.skillSort === 'skill_strength' && (f.skillIds || []).length) {
|
||||
parts.push('Sortierung: Fähigkeiten-Stärke')
|
||||
}
|
||||
|
||||
if ((f.focusAreaIds || []).length) {
|
||||
const names = f.focusAreaIds.map((id) => nameById(catalogs.focusAreas, id))
|
||||
parts.push(`Fokus: ${names.join(', ')}`)
|
||||
@@ -167,14 +190,16 @@ export function summarizeFrameworkImportFilters(filters = {}, catalogs = {}) {
|
||||
/**
|
||||
* Client-Filter für Rahmenprogramm-Auswahl (Liste / Import-Dialog).
|
||||
*/
|
||||
export function filterFrameworkPrograms(rows, filters = {}) {
|
||||
export function filterFrameworkPrograms(rows, filters = {}, skillSummaries = null) {
|
||||
const f = { ...EMPTY_FRAMEWORK_IMPORT_FILTERS, ...filters }
|
||||
const q = (f.query || '').trim().toLowerCase()
|
||||
const focusIds = new Set((f.focusAreaIds || []).map(String))
|
||||
const typeIds = new Set((f.trainingTypeIds || []).map(String))
|
||||
const tgIds = new Set((f.targetGroupIds || []).map(String))
|
||||
const skillIds = f.skillIds || []
|
||||
const minClubPct = Number(f.skillMinClubPercent) || 0
|
||||
|
||||
return (rows || []).filter((r) => {
|
||||
let list = (rows || []).filter((r) => {
|
||||
if (q) {
|
||||
const blob = [
|
||||
r.title,
|
||||
@@ -212,6 +237,32 @@ export function filterFrameworkPrograms(rows, filters = {}) {
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
if (skillIds.length && skillSummaries) {
|
||||
list = list.filter((r) => {
|
||||
const summary = skillSummaries[frameworkSkillSummaryKey(r.id)]
|
||||
if (!summary) return minClubPct === 0
|
||||
return skillIds.some((sid) => {
|
||||
const sk = skillEntryFromSummary(summary, sid)
|
||||
if (!sk) return false
|
||||
const pct = sk.universal_percent
|
||||
if (pct == null) return minClubPct === 0
|
||||
return pct >= minClubPct
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (f.skillSort === 'skill_strength' && skillIds.length && skillSummaries) {
|
||||
list = [...list].sort((a, b) => {
|
||||
const sa = skillSummaries[frameworkSkillSummaryKey(a.id)]
|
||||
const sb = skillSummaries[frameworkSkillSummaryKey(b.id)]
|
||||
const pa = maxSelectedSkillClubPercent(sa, skillIds) ?? -1
|
||||
const pb = maxSelectedSkillClubPercent(sb, skillIds) ?? -1
|
||||
return pb - pa
|
||||
})
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
export function frameworkProgramOptionLabel(row) {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
export function frameworkSkillSummaryKey(id) {
|
||||
return `framework_program:${id}`
|
||||
}
|
||||
|
||||
export function moduleSkillSummaryKey(id) {
|
||||
return `training_module:${id}`
|
||||
}
|
||||
|
||||
export function skillEntryFromSummary(summary, skillId) {
|
||||
if (!summary?.skills) return null
|
||||
return summary.skills.find((s) => String(s.skill_id) === String(skillId)) || null
|
||||
}
|
||||
|
||||
export function maxSelectedSkillClubPercent(summary, skillIds = []) {
|
||||
if (!summary || !skillIds.length) return null
|
||||
let max = null
|
||||
for (const id of skillIds) {
|
||||
const sk = skillEntryFromSummary(summary, id)
|
||||
if (!sk) continue
|
||||
const pct = sk.universal_percent
|
||||
if (pct == null) continue
|
||||
if (max == null || pct > max) max = pct
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
export function formatClubPercent(value) {
|
||||
if (value == null || !Number.isFinite(Number(value))) return '—'
|
||||
const n = Number(value)
|
||||
return n % 1 === 0 ? `${n}%` : `${n.toFixed(1)}%`
|
||||
}
|
||||
|
||||
export function artifactTypeLabel(type) {
|
||||
if (type === 'framework_program') return 'Rahmenprogramm'
|
||||
if (type === 'training_module') return 'Modul'
|
||||
if (type === 'progression_graph') return 'Regressionspfad'
|
||||
return type || 'Artefakt'
|
||||
}
|
||||
|
||||
export function artifactPath(ref) {
|
||||
if (!ref) return null
|
||||
if (ref.artifact_type === 'framework_program') {
|
||||
return `/planning/framework-programs/${ref.artifact_id}`
|
||||
}
|
||||
if (ref.artifact_type === 'training_module') {
|
||||
return `/planning/training-modules/${ref.artifact_id}`
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** Zeilen für Kompakt-Anzeige: gewählte Fähigkeiten oder Top je Kategorie. */
|
||||
export function compactSkillDisplayRows(summary, { skillIds = [], limit = 6 } = {}) {
|
||||
if (!summary) return []
|
||||
if (skillIds.length) {
|
||||
return skillIds
|
||||
.map((id) => skillEntryFromSummary(summary, id))
|
||||
.filter(Boolean)
|
||||
.sort((a, b) => (b.universal_percent ?? 0) - (a.universal_percent ?? 0))
|
||||
.slice(0, limit)
|
||||
}
|
||||
return (summary.top_by_category || []).slice(0, limit)
|
||||
}
|
||||
Reference in new issue
Block a user