Add per-project card statuses and a kanban board
Statuses
- Migration 006: card_statuses table (project-scoped) and cards.status_id, a
nullable FK with ON DELETE SET NULL. Every new project is seeded with
"To do" / "Doing" / "Done"; GET /api/projects/{id}/statuses lists them.
- New cards have no status -- they sit in an "inbox" until moved.
Project view
- Full-width and tabbed: "All tasks" (a flat list, sorted by name
case-insensitively) and "Kanban" (Inbox plus one column per status).
- Drag a card within or between columns to reorder / restatus; the Inbox
column has its own name + Add form.
Ordering
- Migration 007: `position` is now a dense 0..n-1 rank within a
(project_id, status_id) column, not a project-wide order. New composite
index idx_cards_project_status_position; existing rows re-ranked.
- PUT /api/projects/{id}/cards/order takes { status_id, card_ids } and sets one
column's contents and order, re-parenting moved-in cards and re-packing their
source column in a single transaction. PATCH status_id appends the card to the
end of the destination column.
58 phpunit tests pass; the frontend type-checks and builds.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+11
-6
@@ -3,10 +3,11 @@ import { ref } from 'vue'
|
||||
import { apiRequest } from '../lib/api'
|
||||
import type { Card } from '../types'
|
||||
|
||||
type CardPatch = Partial<Pick<Card, 'text' | 'complete' | 'position'>>
|
||||
type CardPatch = Partial<Pick<Card, 'text' | 'complete'>>
|
||||
|
||||
export const useCardsStore = defineStore('cards', () => {
|
||||
// Held in project order (by position); mutated in place by drag-and-drop.
|
||||
// Every card in the project, grouped by column (inbox first) then position.
|
||||
// Views re-sort as needed (the "all tasks" list is alphabetical).
|
||||
const cards = ref<Card[]>([])
|
||||
const projectId = ref<number | null>(null)
|
||||
const loading = ref(false)
|
||||
@@ -56,11 +57,15 @@ export const useCardsStore = defineStore('cards', () => {
|
||||
cards.value = cards.value.filter((c) => c.id !== card.id)
|
||||
}
|
||||
|
||||
/** Persist the current array order (call after a drag ends). */
|
||||
async function persistOrder(): Promise<void> {
|
||||
/**
|
||||
* Set the contents and order of one status column (`null` = inbox). Cards
|
||||
* dragged in from another column are re-parented server-side; the response is
|
||||
* the whole project's cards, which replaces local state.
|
||||
*/
|
||||
async function reorderColumn(statusId: number | null, cardIds: number[]): Promise<void> {
|
||||
const { cards: fresh } = await apiRequest<{ cards: Card[] }>(
|
||||
`/projects/${projectId.value}/cards/order`,
|
||||
{ method: 'PUT', auth: true, body: { card_ids: cards.value.map((c) => c.id) } },
|
||||
{ method: 'PUT', auth: true, body: { status_id: statusId, card_ids: cardIds } },
|
||||
)
|
||||
cards.value = fresh
|
||||
}
|
||||
@@ -82,7 +87,7 @@ export const useCardsStore = defineStore('cards', () => {
|
||||
setComplete,
|
||||
setText,
|
||||
remove,
|
||||
persistOrder,
|
||||
reorderColumn,
|
||||
reset,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user