shared board option show_only_assigned_cards or all due dates
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
@@ -73,10 +73,11 @@ class BoardController extends ApiController {
|
||||
* @param $title
|
||||
* @param $color
|
||||
* @param $archived
|
||||
* @param $upcoming_show_only_assigned_cards
|
||||
* @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, $upcoming_show_only_assigned_cards) {
|
||||
return $this->boardService->update($id, $title, $color, $archived, $upcoming_show_only_assigned_cards);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ class Board extends RelationalEntity {
|
||||
protected $stacks = [];
|
||||
protected $deletedAt = 0;
|
||||
protected $lastModified = 0;
|
||||
protected $upcoming_show_only_assigned_cards = true;
|
||||
|
||||
protected $settings = [];
|
||||
|
||||
@@ -45,6 +46,7 @@ class Board extends RelationalEntity {
|
||||
$this->addType('archived', 'boolean');
|
||||
$this->addType('deletedAt', 'integer');
|
||||
$this->addType('lastModified', 'integer');
|
||||
$this->addType('upcoming_show_only_assigned_cards', 'boolean');
|
||||
$this->addRelation('labels');
|
||||
$this->addRelation('acl');
|
||||
$this->addRelation('shared');
|
||||
|
||||
@@ -66,7 +66,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function find($id, $withLabels = false, $withAcl = false) {
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at, last_modified FROM `*PREFIX*deck_boards` ' .
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at, last_modified, upcoming_show_only_assigned_cards FROM `*PREFIX*deck_boards` ' .
|
||||
'WHERE `id` = ?';
|
||||
$board = $this->findEntity($sql, [$id]);
|
||||
|
||||
@@ -105,12 +105,12 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
*/
|
||||
public function findAllByUser($userId, $limit = null, $offset = null, $since = -1, $includeArchived = true) {
|
||||
// FIXME: One moving to QBMapper we should allow filtering the boards probably by method chaining for additional where clauses
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at, 0 as shared, last_modified FROM `*PREFIX*deck_boards` WHERE owner = ? AND last_modified > ?';
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at, 0 as shared, last_modified, upcoming_show_only_assigned_cards FROM `*PREFIX*deck_boards` WHERE owner = ? AND last_modified > ?';
|
||||
if (!$includeArchived) {
|
||||
$sql .= ' AND NOT archived AND deleted_at = 0';
|
||||
}
|
||||
$sql .= ' UNION ' .
|
||||
'SELECT boards.id, title, owner, color, archived, deleted_at, 1 as shared, last_modified FROM `*PREFIX*deck_boards` as boards ' .
|
||||
'SELECT boards.id, title, owner, color, archived, deleted_at, 1 as shared, last_modified, upcoming_show_only_assigned_cards FROM `*PREFIX*deck_boards` as boards ' .
|
||||
'JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE acl.participant=? AND acl.type=? AND boards.owner != ? AND last_modified > ?';
|
||||
if (!$includeArchived) {
|
||||
$sql .= ' AND NOT archived AND deleted_at = 0';
|
||||
@@ -142,7 +142,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
if (count($groups) <= 0) {
|
||||
return [];
|
||||
}
|
||||
$sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified FROM `*PREFIX*deck_boards` as boards ' .
|
||||
$sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified, upcoming_show_only_assigned_cards FROM `*PREFIX*deck_boards` as boards ' .
|
||||
'INNER JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE owner != ? AND type=? AND (';
|
||||
for ($i = 0, $iMax = count($groups); $i < $iMax; $i++) {
|
||||
$sql .= 'acl.participant = ? ';
|
||||
@@ -174,7 +174,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified FROM `*PREFIX*deck_boards` as boards ' .
|
||||
$sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified, upcoming_show_only_assigned_cards FROM `*PREFIX*deck_boards` as boards ' .
|
||||
'INNER JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE owner != ? AND type=? AND (';
|
||||
for ($i = 0, $iMax = count($circles); $i < $iMax; $i++) {
|
||||
$sql .= 'acl.participant = ? ';
|
||||
|
||||
26
lib/Migration/Version010404Date20210305.php
Normal file
26
lib/Migration/Version010404Date20210305.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version010404Date20210305 extends SimpleMigrationStep {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
$table = $schema->getTable('deck_boards');
|
||||
if (!$table->hasColumn('upcoming_show_only_assigned_cards')) {
|
||||
$table->addColumn('upcoming_show_only_assigned_cards', 'boolean', [
|
||||
'notnull' => false,
|
||||
'default' => true
|
||||
]);
|
||||
}
|
||||
return $schema;
|
||||
}
|
||||
}
|
||||
@@ -422,13 +422,14 @@ class BoardService {
|
||||
* @param $title
|
||||
* @param $color
|
||||
* @param $archived
|
||||
* @param $upcoming_show_only_assigned_cards
|
||||
* @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, $upcoming_show_only_assigned_cards) {
|
||||
if (is_numeric($id) === false) {
|
||||
throw new BadRequestException('board id must be a number');
|
||||
}
|
||||
@@ -445,12 +446,17 @@ class BoardService {
|
||||
throw new BadRequestException('archived must be a boolean');
|
||||
}
|
||||
|
||||
if (is_bool($upcoming_show_only_assigned_cards) === false) {
|
||||
throw new BadRequestException('upcoming_show_only_assigned_cards 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->setUpcoming_show_only_assigned_cards($upcoming_show_only_assigned_cards);
|
||||
$changes->setAfter($board);
|
||||
$this->boardMapper->update($board); // operate on clone so we can check for updated fields
|
||||
$this->boardMapper->mapOwner($board);
|
||||
|
||||
Reference in New Issue
Block a user