Enhance Skills Catalog Admin with Unassigned Skill Handling and Improved Selection Logic
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Has been cancelled
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Has been cancelled
- Introduced utility functions to count skills without main categories and categories, enhancing data management in the Skills Catalog Admin. - Updated the SkillsCatalogAdmin component to handle unassigned main and category IDs, improving user experience when managing skills. - Refactored skill selection logic to utilize new utility functions, ensuring accurate filtering of skills based on selected categories and main categories. - Enhanced the UI to display unassigned skills clearly, improving overall usability and clarity in skill management.
This commit is contained in:
1 parent
9020e5eb16
commit
39b1fd04f0
3 files changed
+233
-28
No files matched your search
@@ -195,3 +195,51 @@ export function defaultExpandedKeysForSkillTree(tree) {
|
||||
walk(tree)
|
||||
return keys
|
||||
}
|
||||
|
||||
/** Sentinel für Katalog-Admin: keine Hauptgruppe gewählt. */
|
||||
export const SKILL_MAIN_UNASSIGNED_KEY = '__unassigned_main__'
|
||||
/** Sentinel für Katalog-Admin: keine Kategorie gewählt. */
|
||||
export const SKILL_CATEGORY_UNASSIGNED_KEY = '__unassigned_category__'
|
||||
export const SKILL_UNASSIGNED_MAIN_LABEL = 'Ohne Hauptgruppe'
|
||||
export const SKILL_UNASSIGNED_CATEGORY_LABEL = 'Ohne Kategorie'
|
||||
|
||||
/**
|
||||
* Fähigkeiten für die Admin-Katalog-Auswahl (Hauptgruppe + Kategorie-Slot).
|
||||
* @param {object[]} skills
|
||||
* @param {number|string|null} mainId
|
||||
* @param {number|string|null} categoryId
|
||||
*/
|
||||
export function catalogSkillsForSelection(skills, mainId, categoryId) {
|
||||
if (!Array.isArray(skills) || categoryId == null) return []
|
||||
if (categoryId === SKILL_CATEGORY_UNASSIGNED_KEY) {
|
||||
if (mainId === SKILL_MAIN_UNASSIGNED_KEY) {
|
||||
return skills.filter((s) => s.main_category_id == null && s.category_id == null)
|
||||
}
|
||||
if (typeof mainId === 'number') {
|
||||
return skills.filter((s) => s.main_category_id === mainId && s.category_id == null)
|
||||
}
|
||||
return []
|
||||
}
|
||||
if (typeof categoryId === 'number') {
|
||||
return skills.filter((s) => s.category_id === categoryId)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/** @param {object[]} skills */
|
||||
export function countCatalogSkillsWithoutMain(skills) {
|
||||
if (!Array.isArray(skills)) return 0
|
||||
return skills.filter((s) => s.main_category_id == null).length
|
||||
}
|
||||
|
||||
/** @param {object[]} skills @param {number|string|null} mainId */
|
||||
export function countCatalogSkillsWithoutCategory(skills, mainId) {
|
||||
if (!Array.isArray(skills)) return 0
|
||||
if (mainId === SKILL_MAIN_UNASSIGNED_KEY) {
|
||||
return skills.filter((s) => s.main_category_id == null && s.category_id == null).length
|
||||
}
|
||||
if (typeof mainId === 'number') {
|
||||
return skills.filter((s) => s.main_category_id === mainId && s.category_id == null).length
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
buildSkillCatalogTree,
|
||||
catalogSkillsForSelection,
|
||||
collectSkillLeavesFromTree,
|
||||
countCatalogSkillsWithoutCategory,
|
||||
countCatalogSkillsWithoutMain,
|
||||
defaultExpandedKeysForSkillTree,
|
||||
filterSkillTreeByQuery,
|
||||
SKILL_CATEGORY_UNASSIGNED_KEY,
|
||||
SKILL_MAIN_UNASSIGNED_KEY,
|
||||
skillCatalogPathLabel,
|
||||
} from './skillCatalogTree.js'
|
||||
|
||||
@@ -70,4 +75,22 @@ describe('skillCatalogTree', () => {
|
||||
const group = kihon?.children?.[0]
|
||||
expect(group?.children?.some((s) => s.skillId === 1)).toBe(true)
|
||||
})
|
||||
|
||||
it('catalogSkillsForSelection lists unassigned buckets', () => {
|
||||
const skills = [
|
||||
{ id: 1, main_category_id: null, category_id: null },
|
||||
{ id: 2, main_category_id: 10, category_id: null },
|
||||
{ id: 3, main_category_id: 10, category_id: 20 },
|
||||
]
|
||||
expect(
|
||||
catalogSkillsForSelection(skills, SKILL_MAIN_UNASSIGNED_KEY, SKILL_CATEGORY_UNASSIGNED_KEY).map(
|
||||
(s) => s.id
|
||||
)
|
||||
).toEqual([1])
|
||||
expect(catalogSkillsForSelection(skills, 10, SKILL_CATEGORY_UNASSIGNED_KEY).map((s) => s.id)).toEqual([
|
||||
2,
|
||||
])
|
||||
expect(countCatalogSkillsWithoutMain(skills)).toBe(1)
|
||||
expect(countCatalogSkillsWithoutCategory(skills, 10)).toBe(1)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user