feat(categories): assign categories to entries & motifs + display (#6, slice 2) #51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/v6.2-categories-assign"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Slice 2 of the categories feature (#6). Builds on slice 1's data model + CRUD API (#50).
Done when: you can assign categories to entries and motifs from their forms, and see them as colored badges across the app.
API
lib/categoryAssign.ts:applyCategories(target, userId, ownerId, categoryIds)— project-contained replace-set intoentry_categories/motif_categories. Only category ids belonging to the owner's own project are applied (prevents cross-project assignment / IDOR); unknown and malformed ids are silently dropped rather than failing the write. Diffs are written to the audit log by category name. No-ops whencategory_idsis absent (so an omitted field leaves assignments untouched).fetchCategoriesForfor accurate write responses, andcategoriesJsonSqlfor embedding categories in read payloads.category_ids: string[].categories(id/name/color): entry list + detail, motif list + detail, and entries-within-a-motif. Embedded via a correlated subquery, not a JOIN, so it never cartesian-multiplies the existing tag aggregation.UI
CategoryBadge— colored chip with automatic text-contrast; neutral fallback when a category has no color.CategorySelect— multi-select that picks existing categories or creates one on the fly (POST /api/categories), mirroring the tag input. Selection is by id; the component owns the id→name/color lookup.EntryFormand the motif edit form; badges shown onEntryCard,EntryDetailPage,MotifListPage,MotifDetailPage(including entries-within).categoriesadded to theEntry/MotifSummary/MotifEntrytypes; test fixtures and the public-project graph adapter updated to match.Tests
11 new integration tests in
categoryAssign.test.ts: assignment on create/update, replace-set semantics, empty-array clear, omitted-field no-op, list/detail read payloads, usage counts, project containment, and malformed-id tolerance.Not in this slice
Filtering lists by category and the Settings management UI land in slice 3. CHANGELOG entry is deferred to the end of slice 3, rolling into the v6.2.0 release notes (per the #6 plan).
🤖 Generated with Claude Code