Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
['name' => 'card#removeLabel', 'url' => '/cards/{cardId}/label/{labelId}', 'verb' => 'DELETE'],
['name' => 'card#assignUser', 'url' => '/cards/{cardId}/assign', 'verb' => 'POST'],
['name' => 'card#unassignUser', 'url' => '/cards/{cardId}/unassign', 'verb' => 'PUT'],
['name' => 'card#assignDependentCard', 'url' => '/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'POST'],
['name' => 'card#removeDependentCard', 'url' => '/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'DELETE'],

// attachments
['name' => 'attachment#getAll', 'url' => '/cards/{cardId}/attachments', 'verb' => 'GET'],
Expand Down Expand Up @@ -105,6 +107,8 @@
['name' => 'card_api#assignUser', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/assignUser', 'verb' => 'PUT'],
['name' => 'card_api#unassignUser', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/unassignUser', 'verb' => 'PUT'],
['name' => 'card_api#reorder', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/reorder', 'verb' => 'PUT'],
['name' => 'card_api#assignDependentCard', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'POST'],
['name' => 'card_api#removeDependentCard', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'DELETE'],
['name' => 'card_api#archive', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/archive', 'verb' => 'PUT'],
['name' => 'card_api#unarchive', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/unarchive', 'verb' => 'PUT'],
['name' => 'card_api#delete', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}', 'verb' => 'DELETE'],
Expand Down Expand Up @@ -146,6 +150,8 @@
['name' => 'card_ocs#unAssignUser', 'url' => '/api/v{apiVersion}/cards/{cardId}/unassign', 'verb' => 'PUT'],
['name' => 'card_ocs#removeLabel', 'url' => '/api/v{apiVersion}/cards/{cardId}/label/{labelId}', 'verb' => 'DELETE'],
['name' => 'card_ocs#reorder', 'url' => '/api/v{apiVersion}/cards/{cardId}/reorder', 'verb' => 'PUT'],
['name' => 'card_ocs#assignDependentCard', 'url' => '/api/v{apiVersion}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'POST'],
['name' => 'card_ocs#removeDependentCard', 'url' => '/api/v{apiVersion}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'DELETE'],

['name' => 'stack_ocs#create', 'url' => '/api/v{apiVersion}/stacks', 'verb' => 'POST'],
['name' => 'stack_ocs#setDoneStack', 'url' => '/api/v{apiVersion}/stacks/{stackId}/done', 'verb' => 'PUT'],
Expand Down
6 changes: 5 additions & 1 deletion cypress/e2e/cardFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,14 @@ describe('Card', function () {

cy.reload()
cy.get('.modal__card').should('be.visible')

// Scroll to the bottom to ensure all content is loaded and visible
cy.get('.modal__card .app-sidebar-tabs, .modal__card .app-sidebar__tab--active').first().scrollTo('bottom', { ensureScrollable: false })
cy.contains('.modal__card .ProseMirror p', 'Paragraph').scrollIntoView().should('be.visible')

cy.get('.modal__card .ProseMirror h1').contains('Hello world writing more text').should('be.visible')
cy.get('.modal__card .ProseMirror li').eq(0).contains('List item').should('be.visible')
cy.get('.modal__card .ProseMirror li').eq(1).contains('with entries').should('be.visible')
cy.get('.modal__card .ProseMirror p').contains('Paragraph').should('be.visible')
})

it('Smart picker', () => {
Expand Down
22 changes: 22 additions & 0 deletions lib/Controller/CardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ public function unassignUser(int $cardId, string $userId, int $type = 0): DataRe
return new DataResponse($card, HTTP::STATUS_OK);
}

/**
* Assign a dependent card
*/
#[NoAdminRequired]
#[CORS]
#[NoCSRFRequired]
public function assignDependentCard(int $cardId, int $dependentCardId): DataResponse {
$card = $this->cardService->assignDependentCard($cardId, $dependentCardId);
return new DataResponse($card, HTTP::STATUS_OK);
}

/**
* Remove a dependent card
*/
#[NoAdminRequired]
#[CORS]
#[NoCSRFRequired]
public function removeDependentCard(int $cardId, int $dependentCardId): DataResponse {
$card = $this->cardService->removeDependentCard($cardId, $dependentCardId);
return new DataResponse($card, HTTP::STATUS_OK);
}

/**
* Archive card
*/
Expand Down
10 changes: 10 additions & 0 deletions lib/Controller/CardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ public function assignUser(int $cardId, string $userId, int $type = 0): Assignme
public function unassignUser(int $cardId, string $userId, int $type = 0): Assignment {
return $this->assignmentService->unassignUser($cardId, $userId, $type);
}

#[NoAdminRequired]
public function assignDependentCard(int $cardId, int $dependentCardId): Card {
return $this->cardService->assignDependentCard($cardId, $dependentCardId);
}

#[NoAdminRequired]
public function removeDependentCard(int $cardId, int $dependentCardId): Card {
return $this->cardService->removeDependentCard($cardId, $dependentCardId);
}
}
24 changes: 24 additions & 0 deletions lib/Controller/CardOcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,28 @@ public function reorder(int $cardId, int $stackId, int $order, ?int $boardId): D
}
return new DataResponse($this->cardService->reorder($cardId, $stackId, $order));
}

#[NoAdminRequired]
#[PublicPage]
public function assignDependentCard(int $cardId, int $dependentCardId, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
// External board support can be added later if needed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't implement it yet we should throw a not implement exception here

}
}
return new DataResponse($this->cardService->assignDependentCard($cardId, $dependentCardId));
}

#[NoAdminRequired]
#[PublicPage]
public function removeDependentCard(int $cardId, int $dependentCardId, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
// External board support can be added later if needed
}
}
return new DataResponse($this->cardService->removeDependentCard($cardId, $dependentCardId));
}
}
5 changes: 5 additions & 0 deletions lib/Db/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
* @method ?DateTime getStartdate()
* @method void setStartdate(?DateTime $startdate)
*
* @method void setDependentCards(array $cardIds)
* @method null|array getDependentCards()
*
* @method void setLabels(Label[] $labels)
* @method null|Label[] getLabels()
*
Expand Down Expand Up @@ -90,6 +93,7 @@ class Card extends RelationalEntity {
protected $deletedAt = 0;
protected $commentsUnread = 0;
protected $commentsCount = 0;
protected ?array $dependentCards = null;

protected $relatedStack = null;
protected $relatedBoard = null;
Expand All @@ -113,6 +117,7 @@ public function __construct() {
$this->addType('deletedAt', 'integer');
$this->addType('duedate', 'datetime');
$this->addType('startdate', 'datetime');
$this->addType('dependentCards', 'json');
$this->addRelation('labels');
$this->addRelation('assignedUsers');
$this->addRelation('attachments');
Expand Down
29 changes: 29 additions & 0 deletions lib/Migration/Version11002Date20260410000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);
namespace OCA\Deck\Migration;

use Closure;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version11002Date20260410000000 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
$schema = $schemaClosure();

if ($schema->hasTable('deck_cards')) {
$table = $schema->getTable('deck_cards');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curios about the thought process of storing related cards as json field. Why not have it as an actual db relation so we can have both depends on and required by displayed.
Storing it this way also removes the ability to auto-delete relations, right now if a card is deleted the depending json will never be changed and the frontend will keep trying to retrieve that card, while the json only keeps growing.

if (!$table->hasColumn('dependent_cards')) {
$table->addColumn('dependent_cards', 'text', [
'notnull' => false,
]);
}
}
return $schema;
}
}
67 changes: 67 additions & 0 deletions lib/Service/CardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,71 @@ public function getCardUrl(int $cardId): string {
public function getRedirectUrlForCard(int $cardId): string {
return $this->urlGenerator->linkToRouteAbsolute('deck.page.redirectToCard', ['cardId' => $cardId]);
}

/**
* @throws StatusException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function assignDependentCard(int $cardId, int $dependentCardId): Card {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
$this->permissionService->checkPermission($this->cardMapper, $dependentCardId, Acl::PERMISSION_READ);

if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
throw new StatusException('Operation not allowed. This board is archived.');
}

$card = $this->cardMapper->find($cardId);
if ($card->getArchived()) {
throw new StatusException('Operation not allowed. This card is archived.');
}

$dependentCards = $card->getDependentCards() ?? [];
if (!in_array($dependentCardId, $dependentCards, true)) {
$dependentCards[] = $dependentCardId;
$card->setDependentCards($dependentCards);
$card = $this->cardMapper->update($card);
$this->changeHelper->cardChanged($cardId);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_UPDATE);
}

[$card] = $this->enrichCards([$card]);
return $card;
}

/**
* @throws StatusException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function removeDependentCard(int $cardId, int $dependentCardId): Card {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
$this->permissionService->checkPermission($this->cardMapper, $dependentCardId, Acl::PERMISSION_READ);

if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
throw new StatusException('Operation not allowed. This board is archived.');
}

$card = $this->cardMapper->find($cardId);
if ($card->getArchived()) {
throw new StatusException('Operation not allowed. This card is archived.');
}

$dependentCards = $card->getDependentCards() ?? [];
$key = array_search($dependentCardId, $dependentCards, true);
if ($key !== false) {
unset($dependentCards[$key]);
$card->setDependentCards(array_values($dependentCards));
$card = $this->cardMapper->update($card);
$this->changeHelper->cardChanged($cardId);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_UPDATE);
}

[$card] = $this->enrichCards([$card]);
return $card;
}
}
40 changes: 40 additions & 0 deletions src/components/card/CardSidebarTabDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
@change="updateCardDue"
@input="debouncedUpdateCardDue" />

<DependentCardsSelector :card="card"
:can-edit="canEdit"
@select="assignDependentCard"
@remove="removeDependentCard" />

<div v-if="projectsEnabled" class="section-wrapper">
<NcCollectionList v-if="card.id"
:id="`${card.id}`"
Expand Down Expand Up @@ -59,10 +64,12 @@ import AssignmentSelector from './AssignmentSelector.vue'
import DueDateSelector from './DueDateSelector.vue'
import StartDateSelector from './StartDateSelector.vue'
import { debounce } from 'lodash'
import DependentCardsSelector from './DependentCardsSelector.vue'

export default {
name: 'CardSidebarTabDetails',
components: {
DependentCardsSelector,
DueDateSelector,
StartDateSelector,
AssignmentSelector,
Expand Down Expand Up @@ -203,6 +210,39 @@ export default {
}
this.$store.dispatch('removeLabel', data)
},
assignDependentCard(dependentCard) {
if (!dependentCard?.id) {
return
}

if (!Array.isArray(this.copiedCard.dependentCards)) {
this.copiedCard.dependentCards = []
}

if (!this.copiedCard.dependentCards.includes(dependentCard.id)) {
this.copiedCard.dependentCards.push(dependentCard.id)
}

this.$store.dispatch('assignDependentCard', {
card: this.copiedCard,
dependentCard,
})
},
removeDependentCard(dependentCard) {
const dependentCardId = dependentCard?.id
if (!dependentCardId) {
return
}

if (Array.isArray(this.copiedCard.dependentCards)) {
this.copiedCard.dependentCards = this.copiedCard.dependentCards.filter((id) => id !== dependentCardId)
}

this.$store.dispatch('removeDependentCard', {
card: this.copiedCard,
dependentCardId,
})
},
stringify(date) {
return moment(date).locale(this.locale).format('LLL')
},
Expand Down
Loading
Loading