Enhance Framework Programs Filtering and UI Components
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 38s
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 1m14s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 38s
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 1m14s
- Updated the FrameworkProgramsFilterBlock to include a search input and filter modal, improving user interaction and accessibility. - Refactored CSS styles for filter components to ensure consistent layout and spacing. - Removed deprecated panel open state management, streamlining the component logic. - Integrated new filtering capabilities in the TrainingPlanningFrameworkImportModal and TrainingModulesListPage, enhancing the overall filtering experience. - Improved the display of active filters and results count, providing clearer feedback to users.
This commit is contained in:
1 parent
2de4c0b7c9
commit
2d187447bb
10 files changed
+945
-385
No files matched your search
@@ -0,0 +1,137 @@
|
||||
import { formatDurationDisplay } from './trainingDurationUtils'
|
||||
import { EMPTY_FRAMEWORK_IMPORT_FILTERS } from './frameworkProgramListHelpers'
|
||||
import { EMPTY_TRAINING_MODULE_FILTERS } from './trainingModuleListHelpers'
|
||||
import { peerCorpusCountLabel } from './skillProfileListHelpers'
|
||||
|
||||
function nameById(list, id) {
|
||||
return list?.find((x) => String(x.id) === String(id))?.name || id
|
||||
}
|
||||
|
||||
function peerPercentLabel(artifactType) {
|
||||
const label = peerCorpusCountLabel(artifactType)
|
||||
return label === 'Rahmenprogramme' ? 'Rahmenprogramm-Maximum' : `${label}-Maximum`
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernbare Filter-Chips (UX wie Übungsliste).
|
||||
*/
|
||||
export function buildPlanningArtifactFilterChips({
|
||||
filters,
|
||||
setFilters,
|
||||
catalogs = {},
|
||||
artifactType = 'framework_program',
|
||||
emptyFilters = null,
|
||||
}) {
|
||||
const base =
|
||||
emptyFilters ||
|
||||
(artifactType === 'training_module' ? EMPTY_TRAINING_MODULE_FILTERS : EMPTY_FRAMEWORK_IMPORT_FILTERS)
|
||||
const f = { ...base, ...filters }
|
||||
const chips = []
|
||||
const peerMaxLabel = peerPercentLabel(artifactType)
|
||||
|
||||
const q = (f.query || '').trim()
|
||||
if (q) {
|
||||
chips.push({
|
||||
key: 'query',
|
||||
label: `Suche: „${q}"`,
|
||||
onRemove: () => setFilters((prev) => ({ ...prev, query: '' })),
|
||||
})
|
||||
}
|
||||
|
||||
;(f.skillIds || []).forEach((id) => {
|
||||
chips.push({
|
||||
key: `skill-${id}`,
|
||||
label: `Fähigkeit: ${nameById(catalogs.skills, id)}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
skillIds: (prev.skillIds || []).filter((x) => String(x) !== String(id)),
|
||||
})),
|
||||
})
|
||||
})
|
||||
|
||||
if (Number(f.skillMinClubPercent) > 0) {
|
||||
chips.push({
|
||||
key: 'skill-min-pct',
|
||||
label: `mind. ${f.skillMinClubPercent}% vom ${peerMaxLabel}`,
|
||||
onRemove: () => setFilters((prev) => ({ ...prev, skillMinClubPercent: 0 })),
|
||||
})
|
||||
}
|
||||
|
||||
if (f.skillSort === 'skill_strength' && (f.skillIds || []).length) {
|
||||
chips.push({
|
||||
key: 'skill-sort',
|
||||
label: 'Sortierung: Fähigkeiten-Stärke',
|
||||
onRemove: () => setFilters((prev) => ({ ...prev, skillSort: 'title' })),
|
||||
})
|
||||
}
|
||||
|
||||
;(f.focusAreaIds || []).forEach((id) => {
|
||||
chips.push({
|
||||
key: `focus-${id}`,
|
||||
label: `Fokus: ${nameById(catalogs.focusAreas, id)}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
focusAreaIds: (prev.focusAreaIds || []).filter((x) => String(x) !== String(id)),
|
||||
})),
|
||||
})
|
||||
})
|
||||
|
||||
;(f.trainingTypeIds || []).forEach((id) => {
|
||||
chips.push({
|
||||
key: `type-${id}`,
|
||||
label: `Trainingsart: ${nameById(catalogs.trainingTypes, id)}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
trainingTypeIds: (prev.trainingTypeIds || []).filter((x) => String(x) !== String(id)),
|
||||
})),
|
||||
})
|
||||
})
|
||||
|
||||
;(f.targetGroupIds || []).forEach((id) => {
|
||||
chips.push({
|
||||
key: `tg-${id}`,
|
||||
label: `Zielgruppe: ${nameById(catalogs.targetGroups, id)}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
targetGroupIds: (prev.targetGroupIds || []).filter((x) => String(x) !== String(id)),
|
||||
})),
|
||||
})
|
||||
})
|
||||
|
||||
if (f.durationMode === 'range') {
|
||||
const a = String(f.durationRangeFrom || '').trim()
|
||||
const b = String(f.durationRangeTo || '').trim()
|
||||
if (a || b) {
|
||||
const fromLbl = a ? formatDurationDisplay(Number(a), { empty: a }) : '—'
|
||||
const toLbl = b ? formatDurationDisplay(Number(b), { empty: b }) : '—'
|
||||
chips.push({
|
||||
key: 'duration-range',
|
||||
label: `Dauer: ${fromLbl} – ${toLbl}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
durationMode: 'any',
|
||||
durationRangeFrom: '',
|
||||
durationRangeTo: '',
|
||||
})),
|
||||
})
|
||||
}
|
||||
} else if (f.durationMode === 'preset' && f.durationPresetMin != null) {
|
||||
chips.push({
|
||||
key: 'duration-preset',
|
||||
label: `Dauer: ${formatDurationDisplay(f.durationPresetMin)}`,
|
||||
onRemove: () =>
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
durationMode: 'any',
|
||||
durationPresetMin: null,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
return chips
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
maxSelectedSkillClubPercent,
|
||||
moduleSkillSummaryKey,
|
||||
summaryHasSkill,
|
||||
} from './skillProfileListHelpers'
|
||||
|
||||
export const EMPTY_TRAINING_MODULE_FILTERS = {
|
||||
query: '',
|
||||
skillIds: [],
|
||||
skillSort: 'title',
|
||||
skillMinClubPercent: 0,
|
||||
skillDisplayLimit: 12,
|
||||
}
|
||||
|
||||
export function hasActiveTrainingModuleFilters(filters = {}) {
|
||||
const f = { ...EMPTY_TRAINING_MODULE_FILTERS, ...filters }
|
||||
if ((f.query || '').trim()) 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
|
||||
}
|
||||
|
||||
export function filterTrainingModules(rows, filters = {}, skillSummaries = null) {
|
||||
const f = { ...EMPTY_TRAINING_MODULE_FILTERS, ...filters }
|
||||
const q = (f.query || '').trim().toLowerCase()
|
||||
const skillIds = f.skillIds || []
|
||||
const minClubPct = Number(f.skillMinClubPercent) || 0
|
||||
|
||||
let list = (rows || []).filter((r) => {
|
||||
if (q) {
|
||||
const blob = [r.title, r.summary].filter(Boolean).join(' ').toLowerCase()
|
||||
if (!blob.includes(q)) return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
if (skillIds.length && skillSummaries) {
|
||||
list = list.filter((r) => {
|
||||
const summary = skillSummaries[moduleSkillSummaryKey(r.id)]
|
||||
if (!summary) return false
|
||||
return skillIds.some((sid) => summaryHasSkill(summary, sid, minClubPct))
|
||||
})
|
||||
}
|
||||
|
||||
if (f.skillSort === 'skill_strength' && skillIds.length && skillSummaries) {
|
||||
list = [...list].sort((a, b) => {
|
||||
const sa = skillSummaries[moduleSkillSummaryKey(a.id)]
|
||||
const sb = skillSummaries[moduleSkillSummaryKey(b.id)]
|
||||
const pa = maxSelectedSkillClubPercent(sa, skillIds) ?? -1
|
||||
const pb = maxSelectedSkillClubPercent(sb, skillIds) ?? -1
|
||||
return pb - pa
|
||||
})
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
Reference in new issue
Block a user