Fähigkeitauswahl verbessert #41
|
|
@ -78,7 +78,7 @@ function SkillTreeNodes({ nodes, depth, expanded, exclude, onToggle, onPickSkill
|
|||
}
|
||||
|
||||
/**
|
||||
* Ausklappbare Baumliste: Hauptgruppe → Kategorie → Fähigkeit (Hauptgruppe und Kategorie standard offen).
|
||||
* Ausklappbare Baumliste: Hauptgruppe → Kategorie → Fähigkeit (nur Hauptgruppe standard offen).
|
||||
*/
|
||||
export default function SkillTreePickerPanel({
|
||||
skills = [],
|
||||
|
|
|
|||
|
|
@ -162,19 +162,10 @@ export function allExpandableKeys(tree) {
|
|||
return keys
|
||||
}
|
||||
|
||||
/** Standard: Hauptgruppe und Kategorie aufgeklappt (Fähigkeiten direkt darunter sichtbar). */
|
||||
/** Standard: nur Hauptgruppe aufgeklappt; Kategorien und Fähigkeiten zugeklappt. */
|
||||
export function defaultExpandedKeysForSkillTree(tree) {
|
||||
const keys = []
|
||||
const walk = (nodes) => {
|
||||
for (const n of nodes) {
|
||||
if (n.type === 'main' || n.type === 'category') {
|
||||
keys.push(n.key)
|
||||
walk(n.children || [])
|
||||
}
|
||||
}
|
||||
}
|
||||
walk(tree)
|
||||
return keys
|
||||
if (!Array.isArray(tree)) return []
|
||||
return tree.filter((n) => n.type === 'main').map((n) => n.key)
|
||||
}
|
||||
|
||||
/** Sentinel für Katalog-Admin: keine Hauptgruppe gewählt. */
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ describe('skillCatalogTree', () => {
|
|||
expect(kataSkill.skillId).toBe(2)
|
||||
})
|
||||
|
||||
it('defaultExpandedKeysForSkillTree opens main and category only', () => {
|
||||
it('defaultExpandedKeysForSkillTree opens main groups only', () => {
|
||||
const tree = buildSkillCatalogTree(sample)
|
||||
const keys = defaultExpandedKeysForSkillTree(tree)
|
||||
expect(keys).toContain('m-10')
|
||||
expect(keys.some((k) => k.includes('c-21'))).toBe(true)
|
||||
expect(keys).toEqual(['m-10'])
|
||||
expect(keys.some((k) => k.includes('c-'))).toBe(false)
|
||||
expect(keys.some((k) => k.startsWith('s-'))).toBe(false)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user