cover images

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2021-03-05 14:47:43 +01:00
parent a857c63b35
commit d4898552ad
7 changed files with 65 additions and 5 deletions

View File

@@ -73,10 +73,11 @@ class BoardController extends ApiController {
* @param $title
* @param $color
* @param $archived
* @param $coverImages
* @return \OCP\AppFramework\Db\Entity
*/
public function update($id, $title, $color, $archived) {
return $this->boardService->update($id, $title, $color, $archived);
public function update($id, $title, $color, $archived, $coverImages) {
return $this->boardService->update($id, $title, $color, $archived, $coverImages);
}
/**

View File

@@ -38,6 +38,7 @@ class Board extends RelationalEntity {
protected $stacks = [];
protected $deletedAt = 0;
protected $lastModified = 0;
protected $coverImages = true;
protected $settings = [];
@@ -47,6 +48,7 @@ class Board extends RelationalEntity {
$this->addType('archived', 'boolean');
$this->addType('deletedAt', 'integer');
$this->addType('lastModified', 'integer');
$this->addType('coverImages', 'boolean');
$this->addRelation('labels');
$this->addRelation('acl');
$this->addRelation('shared');

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace OCA\Deck\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version10400Date20210305 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
// Add cover image database field
$table = $schema->getTable('deck_boards');
if (!$table->hasColumn('coverImages')) {
$table->addColumn('coverImages', 'boolean', [
'notnull' => false,
'default' => true,
]);
}
return $schema;
}
}

View File

@@ -408,13 +408,14 @@ class BoardService {
* @param $title
* @param $color
* @param $archived
* @param $coverImages
* @return \OCP\AppFramework\Db\Entity
* @throws DoesNotExistException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function update($id, $title, $color, $archived) {
public function update($id, $title, $color, $archived, $coverImages) {
if (is_numeric($id) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -431,12 +432,17 @@ class BoardService {
throw new BadRequestException('archived must be a boolean');
}
if (is_bool($coverImages) === false) {
throw new BadRequestException('coverImages must be a boolean');
}
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
$board = $this->find($id);
$changes = new ChangeSet($board);
$board->setTitle($title);
$board->setColor($color);
$board->setArchived($archived);
$board->setCoverImages($coverImages);
$changes->setAfter($board);
$this->boardMapper->update($board); // operate on clone so we can check for updated fields
$this->boardMapper->mapOwner($board);