Sprint: Stories en taken krijgen één voorspelbare volgorde gekoppeld aan hun code; drag-and-drop herordening voor stories/taken verdwijnt, priority wordt puur label. (#201)
* feat(code): add parseCodeNumber helper to lib/code.ts
Pure helper that extracts the trailing numeric sequence from a code string
(ST-007 → 7, T-42 → 42). Non-conforming codes fall back to Number.MAX_SAFE_INTEGER
so they sort to the end. Includes 5 unit tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(tasks): add code field to BacklogTask type and all task selects
Adds `code: string | null` to BacklogTask interface and includes it in
all Prisma task.findMany selects (backlog API, stories tasks API, page
hydration routes). Updates coerceTaskPayload and test fixtures to match.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sort-order): derive story/task sort_order from parseCodeNumber(code)
All create paths (createStoryAction, saveTask, createTaskAction,
materializeIdeaPlanAction) and code-edit paths (updateStoryAction, saveTask
update) now set sort_order = parseCodeNumber(code) instead of last+1.
Removes stale last-record queries from create paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sort-order): decouple sprint membership actions from sort_order
createSprintAction and addStoryToSprintAction no longer write sort_order
when adding stories to a sprint. sort_order is derived from code via
parseCodeNumber, so membership should only set sprint_id + status.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(ordering): remove priority from all story/task orderBy
Story- en taak-ordering is nu puur sort_order asc (created_at als
tiebreaker). PBI-ordering (priority + sort_order) blijft ongewijzigd.
Gewijzigd: backlog/route, pbis/stories/route, claude-context/route,
next-story/route, workspace/route, tasks/route, sprint-runs (query +
in-memory sort), solo-workspace-server, page.tsx (app + mobile + sprint),
store compareStory, actions/sprints story-query, next-story test.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(dnd): remove drag-and-drop reorder for stories and tasks
- Remove reorderStoriesAction, reorderTasksAction, reorderSprintStoriesAction
- Delete REST route app/api/stories/[id]/tasks/reorder/route.ts
- Remove DnD from backlog story-panel and task-panel (flat list)
- Remove reorder-within-sprint branch from sprint-board-client handleDragEnd
- Switch SortableSprintRow to plain SprintRow using useDraggable (membership drag kept)
- Remove all DnD from task-list (status toggle + edit kept)
- Remove story-order/task-order/sprint-story-order/sprint-task-order mutation types and store handlers
- Remove related tests for deleted reorder route; fix sprint store tests
* feat(backlog): toon code-badge op backlog-taakkaarten
Geeft code={task.code} door aan <BacklogCard> in TaskCard (task-panel.tsx).
BacklogCard rendert de CodeBadge al conditionally — alleen de prop ontbrak.
* feat(migration): backfill story/task sort_order from code numeric suffix
One-time Prisma migration that sets sort_order = trailing numeric part
of code for all existing stories and tasks, consistent with
parseCodeNumber (fallback = Number.MAX_SAFE_INTEGER for non-conforming
codes). PBIs are intentionally excluded.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs+tests(sort-order): update for code-binding order on stories/tasks
- Rewrite docs/patterns/sort-order.md: float-insertion PBI only; story/task
sort_order = parseCodeNumber(code), never drag/membership mutated
- Update plan-to-pbi-flow.md: sort_order auto, sprint_id param, priority=label
- Update make-plan.md: priority=label, array order = execution order
- Update rest-contract.md: fix sprint-tasks ordering, remove reorder endpoint
- Add ADR-0011: code is bindende volgordesleutel voor stories/taken
- Regenerate docs/INDEX.md via npm run docs
- Remove reorderStoriesAction/reorderTasksAction mocks from backlog tests
- Remove dnd-kit mocks from task-panel test (panel no longer uses dnd)
- Extend materializeIdeaPlanAction test: assert sort_order=parseCodeNumber(code)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b6249a41c0
commit
ff22196714
43 changed files with 296 additions and 951 deletions
|
|
@ -56,7 +56,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props
|
|||
const [stories, tasks] = await Promise.all([
|
||||
prisma.story.findMany({
|
||||
where: { product_id: id },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
|
|
@ -75,6 +75,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props
|
|||
where: { story: { pbi: { product_id: id } } },
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
title: true,
|
||||
description: true,
|
||||
priority: true,
|
||||
|
|
@ -83,7 +84,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props
|
|||
story_id: true,
|
||||
created_at: true,
|
||||
},
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
}),
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export default async function SprintBoardPage({ params, searchParams }: Props) {
|
|||
where: { sprint_id: sprint.id },
|
||||
orderBy: { sort_order: 'asc' },
|
||||
include: {
|
||||
tasks: { orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }] },
|
||||
tasks: { orderBy: [{ sort_order: 'asc' }] },
|
||||
assignee: { select: { id: true, username: true } },
|
||||
},
|
||||
}),
|
||||
|
|
@ -128,7 +128,7 @@ export default async function SprintBoardPage({ params, searchParams }: Props) {
|
|||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
include: {
|
||||
stories: {
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export default async function MobileProductBacklogPage({ params, searchParams }:
|
|||
const [stories, tasks] = await Promise.all([
|
||||
prisma.story.findMany({
|
||||
where: { product_id: id },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
|
|
@ -61,6 +61,7 @@ export default async function MobileProductBacklogPage({ params, searchParams }:
|
|||
where: { story: { pbi: { product_id: id } } },
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
title: true,
|
||||
description: true,
|
||||
priority: true,
|
||||
|
|
@ -69,7 +70,7 @@ export default async function MobileProductBacklogPage({ params, searchParams }:
|
|||
story_id: true,
|
||||
created_at: true,
|
||||
},
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
}),
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export async function GET(
|
|||
|
||||
const stories = await prisma.story.findMany({
|
||||
where: { pbi_id: id },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export async function GET(
|
|||
}),
|
||||
prisma.story.findMany({
|
||||
where: { product_id: id },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
|
|
@ -66,6 +66,7 @@ export async function GET(
|
|||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
title: true,
|
||||
description: true,
|
||||
priority: true,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export async function GET(
|
|||
if (activeSprint) {
|
||||
const story = await prisma.story.findFirst({
|
||||
where: { sprint_id: activeSprint.id, status: 'IN_SPRINT' },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }],
|
||||
include: {
|
||||
tasks: {
|
||||
orderBy: { sort_order: 'asc' },
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export async function GET(
|
|||
|
||||
const story = await prisma.story.findFirst({
|
||||
where: { sprint_id: sprint.id, status: 'IN_SPRINT' },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }],
|
||||
include: {
|
||||
tasks: {
|
||||
orderBy: { sort_order: 'asc' },
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export async function GET(
|
|||
where: { sprint_id: id },
|
||||
orderBy: [
|
||||
{ story: { sort_order: 'asc' } },
|
||||
{ priority: 'asc' },
|
||||
{ sort_order: 'asc' },
|
||||
],
|
||||
take: limit,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export async function GET(
|
|||
const [stories, tasks] = await Promise.all([
|
||||
prisma.story.findMany({
|
||||
where: { sprint_id: id },
|
||||
orderBy: [{ priority: 'asc' }, { sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
include: {
|
||||
tasks: { select: { id: true, status: true } },
|
||||
assignee: { select: { id: true, username: true } },
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
import { authenticateApiRequest } from '@/lib/api-auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { productAccessFilter } from '@/lib/product-access'
|
||||
import { z } from 'zod'
|
||||
|
||||
const bodySchema = z.object({
|
||||
task_ids: z.array(z.string()).min(1),
|
||||
})
|
||||
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const auth = await authenticateApiRequest(request)
|
||||
if ('error' in auth) {
|
||||
return Response.json({ error: auth.error }, { status: auth.status })
|
||||
}
|
||||
if (auth.isDemo) {
|
||||
return Response.json({ error: 'Niet beschikbaar in demo-modus' }, { status: 403 })
|
||||
}
|
||||
|
||||
const { id: storyId } = await params
|
||||
|
||||
let body: unknown
|
||||
try {
|
||||
body = await request.json()
|
||||
} catch {
|
||||
return Response.json({ error: 'Malformed JSON' }, { status: 400 })
|
||||
}
|
||||
const parsed = bodySchema.safeParse(body)
|
||||
if (!parsed.success) {
|
||||
return Response.json({ error: parsed.error.flatten() }, { status: 422 })
|
||||
}
|
||||
|
||||
const story = await prisma.story.findFirst({
|
||||
where: { id: storyId, product: productAccessFilter(auth.userId) },
|
||||
include: { tasks: { select: { id: true } } },
|
||||
})
|
||||
if (!story) {
|
||||
return Response.json({ error: 'Story niet gevonden' }, { status: 404 })
|
||||
}
|
||||
|
||||
const storyTaskIds = new Set(story.tasks.map(t => t.id))
|
||||
const invalidId = parsed.data.task_ids.find(id => !storyTaskIds.has(id))
|
||||
if (invalidId) {
|
||||
return Response.json({ error: `Ongeldig task_id: ${invalidId}` }, { status: 422 })
|
||||
}
|
||||
|
||||
await prisma.$transaction(
|
||||
parsed.data.task_ids.map((id, i) =>
|
||||
prisma.task.update({ where: { id }, data: { sort_order: i + 1.0 } })
|
||||
)
|
||||
)
|
||||
|
||||
return Response.json({ success: true })
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ export async function GET(
|
|||
orderBy: [{ sort_order: 'asc' }, { created_at: 'asc' }],
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
title: true,
|
||||
description: true,
|
||||
priority: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue