Implement done state for due dates

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-11-05 16:24:02 +01:00
parent a777169487
commit d7b64ea17d
7 changed files with 114 additions and 21 deletions

View File

@@ -94,8 +94,8 @@ class CardController extends Controller {
* @param $deletedAt
* @return \OCP\AppFramework\Db\Entity
*/
public function update($id, $title, $stackId, $type, $order, $description, $duedate, $deletedAt) {
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId, $duedate, $deletedAt);
public function update($id, $title, $stackId, $type, $order, $description, $duedate, $deletedAt, $dueDone) {
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId, $duedate, $deletedAt, null, $dueDone);
}
/**

View File

@@ -36,17 +36,19 @@ class Card extends RelationalEntity {
protected $lastModified;
protected $lastEditor;
protected $createdAt;
protected $labels;
protected $assignedUsers;
protected $attachments;
protected $attachmentCount;
protected $owner;
protected $order;
protected $archived = false;
protected $duedate;
protected $notified = false;
protected $deletedAt = 0;
protected $dueDone = false;
protected $labels;
protected $assignedUsers;
protected $commentsUnread = 0;
protected $attachments;
protected $attachmentCount = 0;
private $databaseType = 'sqlite';
@@ -64,6 +66,8 @@ class Card extends RelationalEntity {
$this->addType('archived', 'boolean');
$this->addType('notified', 'boolean');
$this->addType('deletedAt', 'integer');
$this->addType('dueDone', 'boolean');
$this->addRelation('labels');
$this->addRelation('assignedUsers');
$this->addRelation('attachments');

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace OCA\Deck\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version10200Date20201104190344 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('deck_cards');
if (!$table->hasColumn('due_done')) {
$table->addColumn('due_done', 'boolean', [
'notnull' => false,
'default' => false
]);
}
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
}

View File

@@ -261,7 +261,7 @@ class CardService {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function update($id, $title, $stackId, $type, $order = 0, $description = '', $owner, $duedate = null, $deletedAt = null, $archived = null) {
public function update($id, $title, $stackId, $type, $order = 0, $description = '', $owner, $duedate = null, ?int $deletedAt = null, ?bool $archived = null, ?bool $dueDone = null) {
if (is_numeric($id) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -320,6 +320,9 @@ class CardService {
if ($archived !== null) {
$card->setArchived($archived);
}
if ($dueDone !== null) {
$card->setDueDone($dueDone);
}
// Trigger update events before setting description as it is handled separately
@@ -590,7 +593,7 @@ class CardService {
*/
public function findAllWithDue($userId) {
$cards = $this->cardMapper->findAllWithDue($userId);
return $cards;
}
@@ -602,7 +605,7 @@ class CardService {
*/
public function findAssignedCards($userId) {
$cards = $this->cardMapper->findAssignedCards($userId);
return $cards;
}
}