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
555 changes: 555 additions & 0 deletions cypress/e2e/swimlanesFeatures.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ Returns an array of board items
"lastModified": 1586269585,
"settings": {
"notify-due": "off",
"calendar": true
"calendar": true,
"swimlaneMode": "none",
"swimlaneLabelOrder": "[]",
"swimlaneUserOrder": "[]"
}
}
]
Expand Down Expand Up @@ -1174,6 +1177,9 @@ Deck stores user and app configuration values globally and per board. The GET en
| calendar | Boolean |
| cardDetailsInModal | Boolean |
| cardIdBadge | Boolean |
| swimlaneMode | `none`, `labels` or `assignees`. Shared by everyone with access to the board, needs edit permission |
| swimlaneLabelOrder | JSON string holding an array of label ids in lane order. Shared, needs edit permission. May contain `"__none__"` for the lane of cards without a label. At most 8192 bytes, 1000 entries, 255 bytes per id |
| swimlaneUserOrder | JSON string holding an array of participant uids (without type) in lane order. Shared, needs edit permission. May contain `"__none__"` for the lane of unassigned cards. At most 8192 bytes, 1000 entries, 255 bytes per id |

#### Example request

Expand Down
14 changes: 14 additions & 0 deletions docs/User_documentation_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,17 @@ Individual boards can be transferred by adding the id of the board to the comman
```bash
php occ deck:transfer-ownership previousOwner newOwner 123
```

### 12. Group cards into swimlanes
In the board view, open the board menu in the top bar and pick an entry under **Group by**:

- **No grouping** shows the usual columns.
- **Labels** adds one row per label. Cards without a label land in **No label**.
- **Assignees** adds one row per assigned user, group or circle. Cards without an assignee land in **Unassigned**.

Every row keeps all stacks as columns, so a card stays in its stack and only moves between rows.

- A card with several labels or assignees appears in each matching row. A small badge on the card shows how many rows it appears in. It is still one card, so editing it changes every copy.
- A card can only be dragged inside its own row, between stacks or within a stack. To move it to another row, change its labels or assignees.
- Drag a row header to reorder the rows. Use the arrow on the header to collapse or expand a row.
- The grouping and the row order belong to the board. Everyone with access sees the same layout, and only users who can edit the board can change it.
13 changes: 12 additions & 1 deletion lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OCA\Deck\Db\Acl;
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\ConfigService;
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
Expand All @@ -25,6 +26,7 @@ public function __construct(
private ConfigService $configService,
private PermissionService $permissionService,
private BoardMapper $boardMapper,
private BoardService $boardService,
) {
parent::__construct($AppName, $request);
}
Expand All @@ -38,14 +40,23 @@ public function get(): DataResponse {
#[NoAdminRequired]
#[NoCSRFRequired]
public function setValue(string $key, mixed $value): DataResponse|NotFoundResponse {
$boardId = null;
if (preg_match('/^board:(\d+):/', $key, $matches) === 1) {
$boardId = (int)$matches[1];
$this->permissionService->checkPermission(
$this->boardMapper,
(int)$matches[1],
$boardId,
Acl::PERMISSION_EDIT,
);
}

// Swimlane settings are board columns. Only a key that passed the
// numeric EDIT check above may reach BoardService.
$setting = $boardId === null ? null : substr($key, strlen($matches[0]));
if ($setting !== null && in_array($setting, BoardService::SWIMLANE_SETTINGS, true)) {
return new DataResponse($this->boardService->setSwimlaneSetting($boardId, $setting, $value));
}

$result = $this->configService->set($key, $value);
if ($result === null) {
return new NotFoundResponse();
Expand Down
14 changes: 14 additions & 0 deletions lib/Db/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
* @method string getShareToken()
* @method void setExternalId(int $externalId)
* @method int | null getExternalId()
* @method string|null getSwimlaneMode()
* @method void setSwimlaneMode(?string $swimlaneMode)
* @method string|null getSwimlaneLabelOrder()
* @method void setSwimlaneLabelOrder(?string $swimlaneLabelOrder)
* @method string|null getSwimlaneUserOrder()
* @method void setSwimlaneUserOrder(?string $swimlaneUserOrder)
*/
class Board extends RelationalEntity {
protected $title;
Expand All @@ -50,6 +56,9 @@ class Board extends RelationalEntity {
protected $lastModified = 0;
protected $shareToken = null;
protected $externalId = null;
protected $swimlaneMode = null;
protected $swimlaneLabelOrder = null;
protected $swimlaneUserOrder = null;

protected $settings = [];

Expand All @@ -62,6 +71,9 @@ public function __construct() {
$this->addType('shareToken', 'string');
$this->addType('externalId', 'integer');
$this->addType('teamId', 'string');
$this->addType('swimlaneMode', 'string');
$this->addType('swimlaneLabelOrder', 'string');
$this->addType('swimlaneUserOrder', 'string');
$this->addRelation('labels');
$this->addRelation('acl');
$this->addRelation('shared');
Expand All @@ -84,6 +96,8 @@ public function jsonSerialize(): array {
// however this would be a breaking change for consumers of the API
$json['acl'] = $this->acl ?? [];
$json['labels'] = $this->labels ?? [];
// Served under 'settings' by BoardService::enrichWithBoardSettings, not top level.
unset($json['swimlaneMode'], $json['swimlaneLabelOrder'], $json['swimlaneUserOrder']);
return $json;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Db/BoardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function findAllByUser(string $userId, ?int $limit = null, ?int $offset =
// FIXME this used to be a UNION to get boards owned by $userId and the user shares in one single query
// Is it possible with the query builder?
$qb = $this->db->getQueryBuilder();
$qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token', 'swimlane_mode', 'swimlane_label_order', 'swimlane_user_order')
// this does not work in MySQL/PostgreSQL
//->selectAlias('0', 'shared')
->from('deck_boards', 'b')
Expand Down Expand Up @@ -270,7 +270,7 @@ public function findAllByUser(string $userId, ?int $limit = null, ?int $offset =

// shared with user
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token', 'swimlane_mode', 'swimlane_label_order', 'swimlane_user_order')
//->selectAlias('1', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down Expand Up @@ -352,7 +352,7 @@ public function findAllByGroups(string $userId, array $groups, ?int $limit = nul
return [];
}
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token', 'swimlane_mode', 'swimlane_label_order', 'swimlane_user_order')
//->selectAlias('2', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down Expand Up @@ -408,7 +408,7 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse
}

$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token', 'swimlane_mode', 'swimlane_label_order', 'swimlane_user_order')
//->selectAlias('2', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down
52 changes: 52 additions & 0 deletions lib/Migration/Version11002Date20261004120000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

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

namespace OCA\Deck\Migration;

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

/**
* Swimlane settings as columns on deck_boards, so they go with the board.
*/
class Version11002Date20261004120000 extends SimpleMigrationStep {
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable('deck_boards')) {
return null;
}

$table = $schema->getTable('deck_boards');

if (!$table->hasColumn('swimlane_mode')) {
$table->addColumn('swimlane_mode', 'string', [
'notnull' => false,
'length' => 16,
'default' => null,
]);
}

// text, an order may hold 8192 bytes and Oracle caps varchar at 4000.
// No default, MySQL rejects one on TEXT. Null is read as '[]'.
foreach (['swimlane_label_order', 'swimlane_user_order'] as $column) {
if (!$table->hasColumn($column)) {
$table->addColumn($column, 'text', [
'notnull' => false,
]);
}
}

return $schema;
}
}
74 changes: 72 additions & 2 deletions lib/Service/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@
use Psr\Container\NotFoundExceptionInterface;

class BoardService {
/** Settings stored as columns on the board, shared by every member. */
public const SWIMLANE_SETTINGS = ['swimlaneMode', 'swimlaneLabelOrder', 'swimlaneUserOrder'];

// Every member is served the stored order, so cap it.
private const MAX_SWIMLANE_ORDER_BYTES = 8192;
private const MAX_SWIMLANE_ORDER_ENTRIES = 1000;
// Federated user ids are full cloud ids (user@host), so allow 255.
private const MAX_SWIMLANE_LANE_ID_LENGTH = 255;

private ?array $boardsCacheFull = null;
private ?array $boardsCachePartial = null;

Expand Down Expand Up @@ -426,11 +435,72 @@ private function applyPermissions(int $boardId, bool $edit, bool $share, bool $m
return [$edit, $share, $manage];
}

/**
* Write one of the three swimlane settings onto the board.
*
* boardMapper->update writes only this field and fires no board events.
* boardChanged still moves the ETag.
*
* @throws BadRequestException if the key is not a swimlane setting or the value is malformed
* @throws DoesNotExistException if the board is gone
*/
public function setSwimlaneSetting(int $boardId, string $key, mixed $value): mixed {
if (!in_array($key, self::SWIMLANE_SETTINGS, true)) {
throw new BadRequestException('Not a swimlane setting: ' . $key);
}
$this->validateSwimlaneValue($key, $value);

$board = $this->boardMapper->find($boardId);
match ($key) {
'swimlaneMode' => $board->setSwimlaneMode((string)$value),
'swimlaneLabelOrder' => $board->setSwimlaneLabelOrder((string)$value),
'swimlaneUserOrder' => $board->setSwimlaneUserOrder((string)$value),
};
$this->boardMapper->update($board);
$this->changeHelper->boardChanged($boardId);

return $value;
}

/**
* Every member is served these values, so reject malformed ones.
*/
private function validateSwimlaneValue(string $key, mixed $value): void {
if ($key === 'swimlaneMode') {
if (!in_array($value, ['none', 'labels', 'assignees'], true)) {
throw new BadRequestException('Swimlane mode must be one of: none, labels, assignees');
}
return;
}

// swimlaneLabelOrder / swimlaneUserOrder: JSON array of lane ids
// (label ids, user ids or the '__none__' catch-all lane).
if (!is_string($value) || strlen($value) > self::MAX_SWIMLANE_ORDER_BYTES) {
throw new BadRequestException('Swimlane order must be a JSON array of lane ids');
}
$order = json_decode($value, true);
if (!is_array($order) || !array_is_list($order) || count($order) > self::MAX_SWIMLANE_ORDER_ENTRIES) {
throw new BadRequestException('Swimlane order must be a JSON array of lane ids');
}
foreach ($order as $laneId) {
$isIntId = is_int($laneId);
$isStringId = is_string($laneId) && $laneId !== '' && strlen($laneId) <= self::MAX_SWIMLANE_LANE_ID_LENGTH;
if (!$isIntId && !$isStringId) {
throw new BadRequestException('Swimlane order entries must be label ids, user ids or "__none__"');
}
}
}

public function enrichWithBoardSettings(Board $board): void {
$globalCalendarConfig = (bool)$this->config->getUserValue($this->userId, Application::APP_ID, 'calendar', true);
$boardId = $board->getId();
$settings = [
'notify-due' => $this->config->getUserValue($this->userId, Application::APP_ID, 'board:' . $board->getId() . ':notify-due', ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED),
'calendar' => $this->config->getUserValue($this->userId, Application::APP_ID, 'board:' . $board->getId() . ':calendar', $globalCalendarConfig),
'notify-due' => $this->config->getUserValue($this->userId, Application::APP_ID, 'board:' . $boardId . ':notify-due', ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED),
'calendar' => $this->config->getUserValue($this->userId, Application::APP_ID, 'board:' . $boardId . ':calendar', $globalCalendarConfig),
// Shared by every member. Null until someone changes them.
'swimlaneMode' => $board->getSwimlaneMode() ?? 'none',
'swimlaneLabelOrder' => $board->getSwimlaneLabelOrder() ?? '[]',
'swimlaneUserOrder' => $board->getSwimlaneUserOrder() ?? '[]',
];
$board->setSettings($settings);
}
Expand Down
40 changes: 39 additions & 1 deletion src/components/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,34 @@
</template>
{{ showCardCover ? t('deck', 'Hide card cover images') : t('deck', 'Show card cover images') }}
</NcActionButton>
<template v-if="viewMode === 'kanban'">
<NcActionSeparator />
<NcActionCaption :name="t('deck', 'Group by')" />
<NcActionRadio
name="swimlaneMode"
value="none"
:modelValue="swimlaneMode"
:disabled="!canEdit"
@update:modelValue="setSwimlaneMode">
{{ t('deck', 'No grouping') }}
</NcActionRadio>
<NcActionRadio
name="swimlaneMode"
value="labels"
:modelValue="swimlaneMode"
:disabled="!canEdit"
@update:modelValue="setSwimlaneMode">
{{ t('deck', 'Labels') }}
</NcActionRadio>
<NcActionRadio
name="swimlaneMode"
value="assignees"
:modelValue="swimlaneMode"
:disabled="!canEdit"
@update:modelValue="setSwimlaneMode">
{{ t('deck', 'Assignees') }}
</NcActionRadio>
</template>
</NcActions>
<!-- FIXME: NcActionRouter currently doesn't work as an inline action -->
<NcActions v-if="isFullApp">
Expand All @@ -316,7 +344,7 @@
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { NcActionButton, NcActions, NcActionSeparator, NcAvatar, NcButton, NcModal, NcPopover, NcTextField } from '@nextcloud/vue'
import { NcActionButton, NcActionCaption, NcActionRadio, NcActions, NcActionSeparator, NcAvatar, NcButton, NcModal, NcPopover, NcTextField } from '@nextcloud/vue'
import { vOnClickOutside } from '@vueuse/components'
import { mapActions, mapState, mapWritableState } from 'pinia'
import ArchiveIcon from 'vue-material-design-icons/ArchiveOutline.vue'
Expand Down Expand Up @@ -344,6 +372,8 @@ export default {
NcModal,
NcActions,
NcActionButton,
NcActionCaption,
NcActionRadio,
NcButton,
NcPopover,
NcTextField,
Expand Down Expand Up @@ -414,6 +444,7 @@ export default {
'canManage',
'viewMode',
'showArchived',
'swimlaneMode',
]),

...mapState(useSettingsStore, {
Expand Down Expand Up @@ -500,6 +531,13 @@ export default {
toggleCardCover: 'toggleShowCardCover',
}),

setSwimlaneMode(mode) {
if (this.board?.id && this.canEdit) {
// Returned so a failed write reaches the global error handler.
return useBoardStore(this.$pinia).setSwimlaneMode({ boardId: this.board.id, mode })
}
},

beforeSetFilter(e) {
if (this.filter.due === e.target.value) {
this.filter.due = ''
Expand Down
Loading