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
49 changes: 31 additions & 18 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,32 @@ Returns an array of board items
"color": "31CC7C",
"boardId": 10,
"cardId": null,
"id": 37
"id": 37,
"customSettings": {}
},
{
"title": "To review",
"color": "317CCC",
"boardId": 10,
"cardId": null,
"id": 38
"id": 38,
"customSettings": {}
},
{
"title": "Action needed",
"color": "FF7A66",
"boardId": 10,
"cardId": null,
"id": 39
"id": 39,
"customSettings": { "isImportant": true }
},
{
"title": "Later",
"color": "F1DB50",
"boardId": 10,
"cardId": null,
"id": 40
"id": 40,
"customSettings": {}
}
],
"acl": [],
Expand Down Expand Up @@ -282,28 +286,32 @@ A 403 response might be returned if the users ability to create new boards has b
"color": "31CC7C",
"boardId": "10",
"cardId": null,
"id": 37
"id": 37,
"customSettings": {}
},
{
"title": "To review",
"color": "317CCC",
"boardId": "10",
"cardId": null,
"id": 38
"id": 38,
"customSettings": {}
},
{
"title": "Action needed",
"color": "FF7A66",
"boardId": "10",
"cardId": null,
"id": 39
"id": 39,
"customSettings": {}
},
{
"title": "Later",
"color": "F1DB50",
"boardId": "10",
"cardId": null,
"id": 40
"id": 40,
"customSettings": {}
}
],
"acl": [],
Expand Down Expand Up @@ -867,24 +875,27 @@ The request can fail with a bad request response for the following reasons:
"color": "31CC7C",
"boardId": "2",
"cardId": null,
"id": 5
"id": 5,
"customSettings": { "isImportant": false }
}
```

### POST /boards/{boardId}/labels - Create a new label

#### Request parameters

| Parameter | Type | Description |
| --------- | ------- | ---------------------------------------- |
| boardId | Integer | The id of the board the label belongs to |
| Parameter | Type | Description |
|----------------|---------|------------------------------------------------------------------------------|
| boardId | Integer | The id of the board the label belongs to |
| customSettings | Object | An key-value structure, currently supported only bool property `isImportant` |

#### Request data

```json
{
"title": "Finished",
"color": "31CC7C"
"color": "31CC7C",
"customSettings": { "isImportant": false }
}
```

Expand All @@ -896,18 +907,20 @@ The request can fail with a bad request response for the following reasons:

#### Request parameters

| Parameter | Type | Description |
| --------- | ------- | ---------------------------------------- |
| boardId | Integer | The id of the board the label belongs to |
| labelId | Integer | The id of the label |
| Parameter | Type | Description |
| --------- | ------- |-----------------------------------------------------------------------------------|
| boardId | Integer | The id of the board the label belongs to |
| labelId | Integer | The id of the label |
| customSettings | Object | An key-value structure, currently supported only bool property `isImportant` |


#### Request data

```json
{
"title": "Finished",
"color": "31CC7C"
"color": "31CC7C",
"customSettings": { }
}
```

Expand Down
12 changes: 8 additions & 4 deletions lib/Controller/LabelApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public function get() {
*
* @params $title
* @params $color
* @param array<string, scalar> $customSettings
*
* Create a new label
*/
public function create($title, $color) {
$label = $this->labelService->create($title, $color, $this->request->getParam('boardId'));
public function create($title, $color, array $customSettings = []) {
$label = $this->labelService->create($title, $color, $this->request->getParam('boardId'), $customSettings);
return new DataResponse($label, HTTP::STATUS_OK);
}

Expand All @@ -64,10 +66,12 @@ public function create($title, $color) {
*
* @params $title
* @params $color
* @param array<string, scalar> $customSettings
*
* Update a specific label
*/
public function update($title, $color) {
$label = $this->labelService->update($this->request->getParam('labelId'), $title, $color);
public function update($title, $color, array $customSettings = []) {
$label = $this->labelService->update($this->request->getParam('labelId'), $title, $color, $customSettings);
return new DataResponse($label, HTTP::STATUS_OK);
}

Expand Down
10 changes: 6 additions & 4 deletions lib/Controller/LabelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ public function __construct(
* @param $title
* @param $color
* @param $boardId
* @param array<string, scalar> $customSettings
* @return \OCP\AppFramework\Db\Entity
*/
public function create($title, $color, $boardId) {
return $this->labelService->create($title, $color, $boardId);
public function create($title, $color, $boardId, array $customSettings = []) {
return $this->labelService->create($title, $color, $boardId, $customSettings);
}

/**
* @NoAdminRequired
* @param $id
* @param $title
* @param $color
* @param array<string, scalar> $customSettings
* @return \OCP\AppFramework\Db\Entity
*/
public function update($id, $title, $color) {
return $this->labelService->update($id, $title, $color);
public function update($id, $title, $color, array $customSettings = []) {
return $this->labelService->update($id, $title, $color, $customSettings);
}

/**
Expand Down
19 changes: 19 additions & 0 deletions lib/Db/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,41 @@

/**
* @method getTitle(): string
* @method getCustomSettings(): string
* @method setCustomSettings(string $customSettings)
*/
class Label extends RelationalEntity {
protected $title;
protected $color;
protected $boardId;
protected $cardId;
protected $lastModified;
protected $customSettings;

public function __construct() {
$this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('cardId', 'integer');
$this->addType('lastModified', 'integer');
$this->addType('customSettings', 'string');
}

public function getETag() {
return md5((string)$this->getLastModified());
}

public function getCustomSettingsArray(): array {
return $this->customSettings ? json_decode($this->customSettings, true) : [];
}

public function setCustomSettingsArray(array $customSettings): void {
$this->setCustomSettings(json_encode($customSettings ?: new \stdClass()));
}

public function jsonSerialize(): array {
$data = parent::jsonSerialize();
$data['customSettings'] = $this->getCustomSettingsArray() ?: new \stdClass();

return $data;
}
}
32 changes: 32 additions & 0 deletions lib/Migration/Version20000Date20250907000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* SPDX-FileCopyrightText: 2022 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\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version20000Date20250907000000 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$table = $schema->getTable('deck_labels');
if (!$table->hasColumn('custom_settings')) {
$table->addColumn('custom_settings', Types::JSON, [
'notnull' => false,
]);
}

return $schema;
}
}
2 changes: 1 addition & 1 deletion lib/Service/CardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function update($id, $title, $stackId, $type, $owner, $description = '',
// clone labels that are assigned to card but don't exist in new board
if (empty($filteredLabels)) {
if ($this->permissionService->getPermissions($boardId)[Acl::PERMISSION_MANAGE] === true) {
$newLabel = $this->labelService->create($label->getTitle(), $label->getColor(), $board->getId());
$newLabel = $this->labelService->create($label->getTitle(), $label->getColor(), $board->getId(), $label->getCustomSettingsArray());
$boardLabels[] = $label;
$this->assignLabel($card->getId(), $newLabel->getId());
}
Expand Down
10 changes: 7 additions & 3 deletions lib/Service/LabelService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ public function find($labelId) {
* @param $title
* @param $color
* @param $boardId
* @param array<string, scalar> $customSettings
* @return \OCP\AppFramework\Db\Entity
* @throws StatusException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function create($title, $color, $boardId) {
public function create($title, $color, $boardId, array $customSettings = []) {
$this->labelServiceValidator->check(compact('title', 'color', 'boardId'));

$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
Expand All @@ -89,6 +90,7 @@ public function create($title, $color, $boardId) {
$label->setTitle($title);
$label->setColor($color);
$label->setBoardId($boardId);
$label->setCustomSettingsArray($customSettings);
$this->changeHelper->boardChanged($boardId);
return $this->labelMapper->insert($label);
}
Expand All @@ -99,7 +101,7 @@ public function cloneLabelIfNotExists(int $labelId, int $targetBoardId): Label {
$originLabel = $this->find($labelId);
$filteredValues = array_values(array_filter($boardLabels, fn ($item) => $item->getTitle() === $originLabel->getTitle()));
if (empty($filteredValues)) {
$label = $this->create($originLabel->getTitle(), $originLabel->getColor(), $targetBoardId);
$label = $this->create($originLabel->getTitle(), $originLabel->getColor(), $targetBoardId, $originLabel->getCustomSettingsArray());
return $label;
}
return $originLabel;
Expand Down Expand Up @@ -130,14 +132,15 @@ public function delete($id) {
* @param $id
* @param $title
* @param $color
* @param array<string, scalar> $customSettings
* @return \OCP\AppFramework\Db\Entity
* @throws StatusException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function update($id, $title, $color) {
public function update($id, $title, $color, array $customSettings = []) {
$this->labelServiceValidator->check(compact('title', 'color', 'id'));

$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
Expand All @@ -161,6 +164,7 @@ public function update($id, $title, $color) {

$label->setTitle($title);
$label->setColor($color);
$label->setCustomSettingsArray($customSettings);
$this->changeHelper->boardChanged($label->getBoardId());
return $this->labelMapper->update($label);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/board/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export default {
}

.board {
padding-left: $board-gap;
position: relative;
overflow-x: auto;
flex-grow: 1;
Expand Down
1 change: 1 addition & 0 deletions src/components/board/BoardSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<NcAppSidebar v-if="board != null"
:actions="[]"
:name="board.title"
style="width: 400px"
@close="closeSidebar">
<NcAppSidebarTab id="sharing"
:order="0"
Expand Down
Loading
Loading