From b9979056e0fb58f744f84e94e7d51cc9e13cd986 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 10 Nov 2026 11:44:32 +0100 Subject: [PATCH] fix(cards): keep card color on clone and use contrasting text color Pass the card color through when duplicating a card so the copy keeps it. On cards with a custom background color, pick black or white text based on the background's lightness, as is already done for tags, and apply it to muted text and badges on the card as well. Signed-off-by: Jonas Assisted-by: ClaudeCode:claude-opus-5-5 --- lib/Service/CardService.php | 2 +- src/components/cards/CardItem.vue | 15 ++++++++++++++- tests/unit/Service/CardServiceTest.php | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 3b12d2a891..5d2978f207 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -368,7 +368,7 @@ public function cloneCard(int $id, ?int $targetStackId = null):Card { $targetStackId = $originCard->getStackId(); } $this->permissionService->checkPermission($this->stackMapper, $targetStackId, Acl::PERMISSION_EDIT); - $newCard = $this->create($originCard->getTitle(), $targetStackId, $originCard->getType(), $originCard->getOrder(), $originCard->getOwner()); + $newCard = $this->create($originCard->getTitle(), $targetStackId, $originCard->getType(), $originCard->getOrder(), $originCard->getOwner(), color: $originCard->getColor()); $boardId = $this->stackMapper->findBoardId($targetStackId); foreach ($this->labelMapper->findAssignedLabelsForCard($id) as $label) { if ($boardId !== $this->stackMapper->findBoardId($originCard->getStackId())) { diff --git a/src/components/cards/CardItem.vue b/src/components/cards/CardItem.vue index 5132bd19df..9246a3ba3d 100644 --- a/src/components/cards/CardItem.vue +++ b/src/components/cards/CardItem.vue @@ -7,7 +7,7 @@
setOwner('admin'); $card->setStackId(12345); $card->setDescription('A test description'); + $card->setColor('FF0000'); $clonedCard = clone $card; $clonedCard->setId(2); $clonedCard->setStackId(1234); + $inserted = []; $this->cardMapper->expects($this->exactly(2)) ->method('insert') - ->willReturn($card, $clonedCard); + ->willReturnCallback(function (Card $entity) use (&$inserted, $card, $clonedCard) { + $inserted[] = $entity; + return count($inserted) === 1 ? $card : $clonedCard; + }); $this->cardMapper->expects($this->once()) ->method('update')->willReturn($clonedCard); @@ -331,6 +336,7 @@ public function testClone() { $this->assertNotEquals($b->getStackId(), $c->getStackId()); $this->assertEquals('A test description', $c->getDescription()); + $this->assertEquals('FF0000', $inserted[1]->getColor()); $this->assertCount(1, $c->getLabels()); $this->assertEquals($label->getId(), $c->getLabels()[0]->getId());