* docs(dialog-pattern): add generic entity-dialog spec Introduceert docs/patterns/dialog.md als bron-of-truth voor elke create/edit/detail-dialog in Scrum4Me, ongeacht het achterliggende dataobject. Bevat 14 secties: uitgangspunten, stack, component- architectuur, layout, validatie, drielaagse demo-policy, submission, dialog-gedrag, theming, footer, triggers/URL-state, per-entiteit profile-template, out-of-scope, en een verificatie-checklist. Registreert het patroon in CLAUDE.md "Implementatiepatronen"-tabel zodat Claude (en mensen) de spec verplicht raadplegen voor elke nieuwe dialog. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(dialog-pattern): convert task spec + add pbi/story entity-profiles Reduceert docs/scrum4me-task-dialog.md van 507 naar ~140 regels: alle gedeelde regels verhuisd naar docs/patterns/dialog.md, dit document bevat nu alleen Task-specifieke velden, URL-pattern, status-veld, server actions, triggers en bewuste out-of-scope-keuzes. Voegt twee nieuwe entity-profielen toe voor bestaande dialogen: - docs/scrum4me-pbi-dialog.md (PbiDialog: state-based, code+title-rij, PbiStatusSelect, geen delete in v1) - docs/scrum4me-story-dialog.md (StoryDialog: state-based, header met status/priority badges, inline activity-log, demo-readonly-fallback, inline-delete-confirm i.p.v. AlertDialog) Beide profielen documenteren expliciet de "Bekende gaps t.o.v. generieke spec" zodat opvolgende PR's de afwijkingen kunnen rechtzetten of bewust kunnen accorderen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Added pdevelopment docs * docs(plans): add docs-restructure plan for AI-optimized lookup Audit of existing 39 doc files (~10.700 lines) and a phased restructure proposal aimed at minimising the tokens an AI agent has to read to find the right reference. Captures resolved decisions on language (English), ADR template (Nygard default with MADR escape-hatch), index generator (node script), and folder taxonomy. Proposal status — fase 1 to follow. * docs(adr): add ADR scaffolding (templates, README, meta-ADR) Set up docs/adr/ as the canonical home for architecture decisions: - templates/nygard.md — default four-section format (Status, Context, Decision, Consequences) for one-way-door decisions. - templates/madr.md — MADR v4 with YAML front-matter and explicit Considered Options for decisions where rejected alternatives matter. - README.md — naming convention (NNNN-kebab-case), template-selection guidance (Nygard default; MADR for auth, queue mechanics, agent integration), status lifecycle, and ADR roster. - 0000-record-architecture-decisions.md — meta-ADR establishing the practice itself, in Nygard format. Backfilling existing implicit decisions (base-ui-over-radix, float sort_order, demo-user three-layer policy, etc.) is fase 6 of the docs-restructure plan. * feat(docs): add docs index generator + initial INDEX.md scripts/generate-docs-index.mjs walks docs/**/*.md, parses YAML front-matter (or first H1 fallback) and a Nygard-style ## Status section, then writes docs/INDEX.md with grouped tables for ADRs, Specs, Plans (with archive subsection), Patterns, and Other. Pure Node 20 (no external deps); idempotent — running it twice produces byte-identical output. Excludes adr/templates/, the ADR README, INDEX.md itself, and any *_*.md sidecar file. Wire-up: - package.json: docs:index → node scripts/generate-docs-index.mjs Initial run indexed 35 docs across the existing structure; the generated INDEX.md is committed so the table is reviewable in the PR before hooking generation into a pre-commit step. * chore: ignore Obsidian vault and personal sidecar files Add .obsidian/ (Obsidian vault config) and _*.md (personal sidecar notes) to .gitignore so the docs/ tree can serve as canonical source of truth while still being usable as an Obsidian vault for personal authoring. The docs index generator already excludes the same _*.md pattern from INDEX.md. * docs(plans): add PBI bulk-create spec for docs-restructure Machine-parseable spec for an executor that calls the scrum4me MCP (create_pbi → create_story → create_task) to seed the docs-restructure work into the DB. - Section 1 (Context) is the PBI description; serves as task-context via mcp__scrum4me__get_claude_context. - Section 2 lists the 6 resolved decisions (English, MD3+styling merged, solo-paneel merged, .Plans archived, Nygard ADR default, node index script). - Section 3 records what already shipped on this branch so the executor doesn't duplicate the ADR scaffolding or index generator. - Section 4 carries the structured YAML graph: 1 PBI, 8 stories (one per phase), 39 tasks. product_id is REPLACE_ME — fill before running. - YAML validated with PyYAML; field schema sanity-checked. * docs(junk-cleanup): remove stub patterns/test.md * docs(junk-cleanup): archive .Plans/ to docs/plans/archive/ * docs(front-matter): add YAML front-matter to docs/ root * docs(front-matter): add YAML front-matter to patterns/ * docs(front-matter): add YAML front-matter to plans + agent files * docs(index): regenerate INDEX.md after front-matter pass * docs(naming): drop scrum4me- prefix from doc filenames * docs(naming): lowercase API.md and MD3 filenames * docs(naming): rename plan file to kebab-case ASCII * docs(naming): rename middleware.md to proxy.md (next 16) * docs(naming): polish CLAUDE.md doc-index after renames * docs(taxonomy): scaffold topical folders under docs/ * docs(taxonomy): move spec files into docs/specs/ * docs(taxonomy): move design/api/qa/backlog/assets into folders * docs(taxonomy): move agent-instruction-audit into decisions/ * docs(split): break architecture.md into 6 topical files * docs(split): merge solo-paneel-spec into specs/functional.md * docs(split): merge md3-color-scheme into design/styling * docs(trim): extract branch/commit rules into runbook * docs(trim): extract MCP integration into runbook * docs(adr): add 0001-base-ui-over-radix * docs(adr): add 0002-float-sort-order * docs(adr): add 0003-one-branch-per-milestone * docs(adr): add 0004-status-enum-mapping * docs(adr): add 0005-iron-session-over-nextauth * docs(adr): add 0006-demo-user-three-layer-policy * docs(adr): add 0007-claude-question-channel-design * docs(adr): add 0008-agent-instructions-in-claude-md + update README index * docs(index): regenerate after ADR 0001-0008 * docs(glossary): add docs/glossary.md * chore(docs): regenerate INDEX.md in pre-commit hook * docs(readme): link INDEX + glossary + agent instructions * feat(docs): add doc-link checker script * chore(docs): wire docs:check-links and docs npm scripts * ci(docs): block merge on broken doc links * docs(links): fix broken cross-references after restructure --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
170 lines
8 KiB
Markdown
170 lines
8 KiB
Markdown
---
|
|
title: "M9 — Actief Product Backlog"
|
|
status: active
|
|
audience: [maintainer, contributor]
|
|
language: nl
|
|
last_updated: 2026-05-03
|
|
applies_to: [M9]
|
|
---
|
|
|
|
# M9 — Actief Product Backlog
|
|
|
|
Eén "actief Product Backlog" per gebruiker, persistent op `User.active_product_id`. NavBar wordt: Producten | Product Backlog | Sprint | Solo | Todo's. Zonder actief PB zijn Backlog/Sprint/Solo disabled. Sprint is alleen klikbaar als er een sprint met status `ACTIVE` bestaat. Vervangt de bestaande `last_product`-cookieflow.
|
|
|
|
Backlog-entries: zie [backlog.md § M9](../backlog/index.md#m9-actief-product-backlog).
|
|
|
|
---
|
|
|
|
## ST-901 — Database `user.active_product_id`
|
|
|
|
> Status: voltooid in commit `dad9a80`.
|
|
|
|
**Bestanden**
|
|
- `prisma/schema.prisma` — model `User` uitgebreid + named relation
|
|
- `prisma/migrations/20260427165329_add_user_active_product_id/migration.sql` — migratie
|
|
|
|
**Stappen**
|
|
1. Op `User`: `active_product_id String? @db.Uuid` + relatie `active_product Product? @relation("UserActiveProduct", fields: [active_product_id], references: [id], onDelete: SetNull)` + `@@index([active_product_id])`.
|
|
2. Op `Product`: tegenrelatie `active_for_users User[] @relation("UserActiveProduct")` (anders conflicteert het met de bestaande `Product.user_id`-relatie).
|
|
3. `npx prisma migrate dev --name add_user_active_product_id`.
|
|
|
|
**Aandachtspunten**
|
|
- `vendor/scrum4me`-submodule in repo `mcp` heeft hetzelfde schema. Na merge moet daar `prisma generate && tsc --noEmit` slagen, anders breekt de wekelijkse drift-check (`trig_015FFUnxjz9WMuhhWNGBQKFD`).
|
|
- Geen seed-wijziging nodig — `null` is correcte initiële staat.
|
|
|
|
**Verificatie**
|
|
- `npx prisma migrate dev` slaagt
|
|
- `npx prisma validate` zonder fouten
|
|
- `prisma studio` toont kolom
|
|
|
|
---
|
|
|
|
## ST-902 — Server Actions: actief product zetten/wissen + auto-clear
|
|
|
|
**Bestanden**
|
|
- `actions/active-product.ts` — nieuw, twee Server Actions
|
|
- `actions/products.ts` — uitbreiden bij `archiveProductAction`
|
|
- `actions/product-members.ts` — uitbreiden bij `leaveProductAction` en `removeMemberAction` (locatie verifiëren met grep)
|
|
- `__tests__/actions/active-product.test.ts` — nieuw
|
|
|
|
**Stappen**
|
|
|
|
1. **`setActiveProductAction({ productId })`** in `actions/active-product.ts`:
|
|
- Volg `docs/patterns/server-action.md`
|
|
- Zod: `z.object({ productId: z.string().uuid() })`
|
|
- `getSession()` → 401 bij geen sessie
|
|
- **Demo-guard**: `if (session.isDemo) return { ok: false, error: 'Niet beschikbaar in demo-modus.' }`
|
|
- Toegangscheck: `prisma.product.findFirst({ where: { id: productId, archived: false, ...productAccessFilter(userId) } })` → `null` levert `{ ok: false, error: 'Product niet gevonden of geen toegang.' }`
|
|
- `prisma.user.update({ where: { id: userId }, data: { active_product_id: productId } })`
|
|
- `revalidatePath('/', 'layout')` — laat NavBar in alle routes opnieuw renderen
|
|
- Return `{ ok: true }`
|
|
|
|
2. **`clearActiveProductAction()`** in hetzelfde bestand:
|
|
- Geen input
|
|
- `getSession()` + demo-guard
|
|
- `prisma.user.update({ where: { id: userId }, data: { active_product_id: null } })`
|
|
- `revalidatePath('/', 'layout')`
|
|
|
|
3. **Auto-clear bij toegangsverlies** — drie call-sites uitbreiden ná de hoofdmutatie:
|
|
- `archiveProductAction(productId)`: `prisma.user.updateMany({ where: { active_product_id: productId }, data: { active_product_id: null } })`
|
|
- `leaveProductAction(productId)`: `prisma.user.updateMany({ where: { id: userId, active_product_id: productId }, data: { active_product_id: null } })`
|
|
- `removeMemberAction(productId, removedUserId)`: `prisma.user.updateMany({ where: { id: removedUserId, active_product_id: productId }, data: { active_product_id: null } })`
|
|
- Eigenaarsverwijdering van een product wordt door FK `onDelete: SetNull` automatisch geregeld — geen extra code
|
|
|
|
4. **Tests** — `__tests__/actions/active-product.test.ts`:
|
|
- setActive met onbekend product → `{ ok: false }`
|
|
- setActive met archived product → `{ ok: false }`
|
|
- setActive met product zonder access → `{ ok: false }`
|
|
- setActive happy path → `users.active_product_id` gezet
|
|
- Demo-user setActive → error + geen DB-mutatie
|
|
- archiveProductAction op actief product → `active_product_id` gecleared voor alle eigenaren/leden
|
|
|
|
**Aandachtspunten**
|
|
- Race-condition: setActive winnen ná auto-clear kan voorkomen. Layout-guard in ST-903 vangt dit op bij volgende request.
|
|
- `revalidatePath('/', 'layout')` is correct — niet `revalidatePath('/dashboard')` (NavBar zit in root layout van `(app)`).
|
|
- Geen `productAccessFilter` op `clearActiveProductAction` — eigen keuze wissen mag altijd.
|
|
|
|
**Verificatie**
|
|
- `npm run lint && npx tsc --noEmit && npm test && npm run build` groen
|
|
- Handmatig: 2 users — A archiveert product, `users.active_product_id` van B wordt `null` in DB
|
|
|
|
---
|
|
|
|
## ST-903 — App-layout actief product + redirects
|
|
|
|
**Bestanden**
|
|
- `app/(app)/layout.tsx` — uitbreiden met activeProduct-fetch + guard
|
|
- `app/(app)/solo/page.tsx` — cookie-flow vervangen
|
|
- `lib/cookies.ts` — `getLastProductCookie` / `setLastProductCookie` verwijderen
|
|
- `components/shared/nav-bar.tsx` — nieuwe prop `activeProduct` accepteren (verdere UI-uitwerking in ST-904)
|
|
- `components/solo/product-picker.tsx` — checken of nog gebruikt; anders weg
|
|
|
|
**Stappen**
|
|
|
|
1. **`app/(app)/layout.tsx`**:
|
|
- User-query uitbreiden:
|
|
```ts
|
|
prisma.user.findUnique({
|
|
where: { id: session.userId },
|
|
select: {
|
|
username: true,
|
|
email: true,
|
|
active_product_id: true,
|
|
active_product: { select: { id: true, name: true, archived: true } },
|
|
},
|
|
})
|
|
```
|
|
- **Guard**: als `user.active_product_id` is gezet maar (`active_product === null` of `active_product.archived === true` of geen toegang via `productAccessFilter`):
|
|
- `prisma.user.update(... active_product_id: null)` server-side
|
|
- `redirect('/dashboard?notice=active-cleared')`
|
|
- `<NavBar activeProduct={user.active_product ?? null} ... />` als nieuwe prop
|
|
|
|
2. **`app/(app)/solo/page.tsx`** — vervang volledig:
|
|
```ts
|
|
const session = await getSession()
|
|
if (!session.userId) redirect('/login')
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: session.userId },
|
|
select: { active_product_id: true },
|
|
})
|
|
if (!user?.active_product_id) redirect('/dashboard?notice=no-active')
|
|
redirect(`/products/${user.active_product_id}/solo`)
|
|
```
|
|
|
|
3. **`lib/cookies.ts`**: verwijder `getLastProductCookie` en `setLastProductCookie`. Grep alle call-sites en pas aan/verwijder.
|
|
|
|
4. **Toast-handling** (server-redirect → client toast):
|
|
- Klein client-component `<NoticeToast />` dat `useSearchParams` leest, `toast()` aanroept, querystring strippt via `router.replace(pathname)`
|
|
- Plaats in `app/(app)/dashboard/page.tsx` (of layout) — alleen geactiveerde notices afhandelen
|
|
- Twee waarden: `active-cleared` → "Je actieve product is niet meer beschikbaar."; `no-active` → "Selecteer eerst een actief product."
|
|
|
|
**Aandachtspunten**
|
|
- Layout-guard draait per request (extra DB-query). Houd 'm in dezelfde Promise.all met de bestaande user/userRoles-fetch.
|
|
- ProductPicker-fallback verdwijnt — switcher gebeurt in ST-904 via NavBar-dropdown.
|
|
- `app/(app)/solo/page.tsx` blijft Server Component — alleen `redirect()` van `next/navigation`.
|
|
- Een vorm van de cookie-helper kan ook door andere code gebruikt worden — verifieer de grep zorgvuldig vóór je verwijdert.
|
|
|
|
**Verificatie**
|
|
- `npm run lint && npx tsc --noEmit && npm test && npm run build` groen
|
|
- Login zonder active → NavBar krijgt `activeProduct={null}`
|
|
- Login met active → NavBar krijgt object met id/name
|
|
- Bezoek `/solo` met active → redirect naar `/products/[id]/solo` zonder cookie
|
|
- Archiveer actief product (script of via andere user) → bij volgende request layout cleart, toast op `/dashboard`
|
|
|
|
---
|
|
|
|
## ST-904 — NavBar splits + disabled-states + switcher
|
|
|
|
> Plan nog te schrijven.
|
|
|
|
## ST-905 — Producten-scherm Activeer-knop
|
|
|
|
> Plan nog te schrijven.
|
|
|
|
## ST-906 — Edge cases — toegangsverlies en archivering
|
|
|
|
> Plan nog te schrijven.
|
|
|
|
## ST-907 — Documentatie en tests
|
|
|
|
> Plan nog te schrijven.
|