Project configuration view: manage a project's statuses
New /projects/:id/configure view, linked from a new 'Configure' item on
the project view's Manage menu.
Backend:
- CardStatusRepository/CardStatusController gain full CRUD: create
(appended at the end), reorder (dense positions, like card
ordering), and delete.
- Deleting a status with cards attached is rejected with 409 and
error.details.card_count, rather than hitting the existing FK
RESTRICT constraint -- retrying with { reassign_to: <status id> }
moves those cards to that status first (CardRepository::
reassignStatus, appended after the destination's existing cards)
and deletes in one transaction (CardStatusRepository::transaction,
shared PDO connection across repositories).
- The last status in a project can't be deleted, since a project card
is required to have one.
- Routes: POST/DELETE .../statuses(/:id), PUT .../statuses/order.
- 14 new CardStatusTest cases covering all of the above.
Frontend:
- ProjectConfigureView.vue: header (title, back-to-project link, the
shared Manage menu) + a vuedraggable status list (reorder persists
the whole new order) with a delete button per row and an add-status
form. A row's plain delete either succeeds immediately or, on 409,
opens a modal to choose a different status before retrying the
delete with reassign_to.
- Extracted ProjectManageMenu.vue (the Manage dropdown + delete-project
modal) out of ProjectView so both views share it; it now also has a
Configure link (hidden on the configure page itself).
- ApiError gains a cardCount getter (details.card_count), mirroring
the existing retryAfter getter.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -214,6 +214,29 @@ final class CardRepository
|
||||
return $this->columnCards($ownerId, $projectId, $statusId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move every card in one project status to another status in the same
|
||||
* project -- used when a status is deleted out from under them. Appended
|
||||
* after the destination's existing cards, so both columns stay a dense
|
||||
* 0..n-1 with no repack needed.
|
||||
*/
|
||||
public function reassignStatus(int $ownerId, int $projectId, int $fromStatusId, int $toStatusId): void
|
||||
{
|
||||
$ids = $this->idsInColumn($ownerId, $projectId, $fromStatusId);
|
||||
if ($ids === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$next = $this->nextPositionInColumn($ownerId, $projectId, $toStatusId);
|
||||
$stmt = $this->pdo->prepare(
|
||||
'UPDATE cards SET status_id = :status, position = :position, updated_at = ' . $this->nowExpr() . '
|
||||
WHERE id = :id AND owner_id = :owner'
|
||||
);
|
||||
foreach ($ids as $i => $id) {
|
||||
$stmt->execute(['status' => $toStatusId, 'position' => $next + $i, 'id' => $id, 'owner' => $ownerId]);
|
||||
}
|
||||
}
|
||||
|
||||
private function insert(
|
||||
int $ownerId,
|
||||
?int $projectId,
|
||||
|
||||
Reference in New Issue
Block a user