fix: Move to storing the date instead of boolean for done state

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-11-07 21:35:33 +01:00
parent c3b4ed6e1f
commit c2fd5163b0
6 changed files with 18 additions and 43 deletions

View File

@@ -16,7 +16,7 @@
- 🚀 Get your project organized
</description>
<version>1.11.0-dev.1</version>
<version>1.11.0-dev.2</version>
<licence>agpl</licence>
<author>Julius Härtl</author>
<documentation>

View File

@@ -83,7 +83,7 @@ class Card extends RelationalEntity {
protected $owner;
protected $order;
protected $archived = false;
protected $done = false;
protected $done = null;
protected $duedate;
protected $notified = false;
protected $deletedAt = 0;
@@ -107,7 +107,7 @@ class Card extends RelationalEntity {
$this->addType('lastModified', 'integer');
$this->addType('createdAt', 'integer');
$this->addType('archived', 'boolean');
$this->addType('done', 'boolean');
$this->addType('done', 'datetime');
$this->addType('notified', 'boolean');
$this->addType('deletedAt', 'integer');
$this->addType('duedate', 'datetime');

View File

@@ -263,7 +263,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
->where($qb->expr()->in('s.board_id', $qb->createNamedParameter($boardIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($qb->expr()->isNotNull('c.duedate'))
->andWhere($qb->expr()->eq('c.archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('c.done', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->isNull('done'))
->andWhere($qb->expr()->eq('c.deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('s.deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('b.archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
@@ -285,7 +285,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
)
// Filter out archived/deleted cards and board
->andWhere($qb->expr()->eq('c.archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('c.done', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->isNull('done'))
->andWhere($qb->expr()->eq('c.deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('s.deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('b.archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
@@ -300,7 +300,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
->where($qb->expr()->lt('duedate', $qb->createFunction('NOW()')))
->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('done', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->isNull('done'))
->andWhere($qb->expr()->eq('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
return $this->findEntities($qb);
}

View File

@@ -28,6 +28,7 @@ namespace OCA\Deck\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -47,9 +48,9 @@ class Version1011Date20230901010840 extends SimpleMigrationStep {
$table = $schema->getTable('deck_cards');
if (!$table->hasColumn('done')) {
$table->addColumn('done', 'boolean', [
'default' => false,
'notnull' => true,
$table->addColumn('done', Types::DATETIME, [
'default' => null,
'notnull' => false,
]);
return $schema;

View File

@@ -294,7 +294,7 @@ class CardService {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/
public function update($id, $title, $stackId, $type, $owner, $description = '', $order = 0, $duedate = null, $deletedAt = null, $archived = null, ?bool $done = null) {
public function update($id, $title, $stackId, $type, $owner, $description = '', $order = 0, $duedate = null, $deletedAt = null, $archived = null, $done = null) {
$this->cardServiceValidator->check(compact('id', 'title', 'stackId', 'type', 'owner', 'order'));
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
@@ -532,7 +532,7 @@ class CardService {
throw new StatusException('Operation not allowed. This board is archived.');
}
$card = $this->cardMapper->find($id);
$card->setDone(true);
$card->setDone(new \DateTime());
$newCard = $this->cardMapper->update($card);
$this->notificationHelper->markDuedateAsRead($card);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_DONE);
@@ -558,7 +558,7 @@ class CardService {
throw new StatusException('Operation not allowed. This board is archived.');
}
$card = $this->cardMapper->find($id);
$card->setDone(false);
$card->setDone(null);
$newCard = $this->cardMapper->update($card);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_UNDONE);
$this->changeHelper->cardChanged($id, false);

View File

@@ -29,13 +29,13 @@
<template #icon>
<CheckIcon :size="20" />
</template>
{{ t('deck', 'Mark as Done') }}
{{ t('deck', 'Mark as done') }}
</NcButton>
<NcButton v-if="card.done" type="tertiary" @click="changeCardDoneStatus()">
<template #icon>
<ClearIcon :size="20" />
</template>
{{ t('deck', 'Mark as not Done') }}
{{ t('deck', 'Mark as not done') }}
</NcButton>
<NcButton type="tertiary" @click="archiveUnarchiveCard()">
<template #icon>
@@ -62,11 +62,9 @@
<div v-if="card.done">
<div class="done">
<div v-if="!card.duedate && card.done" class="no-due">
{{ t('deck', 'No due date') }}
</div>
<CheckIcon :size="20" /> {{ t('deck', 'Done') }}
<div v-if="card.done" class="done-label">
{{ t('deck', 'Done') }}
{{ stringify(card.done) }}
</div>
</div>
</div>
@@ -287,32 +285,8 @@ export default {
}
}
.done{
.done {
display: flex;
margin-left: 40px;
.no-due, .done-label{
line-height: 30px;
align-items: baseline;
flex-shrink: 1;
z-index: 2;
margin: 13px 5px 5px;
font-size: 100%;
}
.no-due{
padding: 3px;
color: var(--color-main-text);
}
.done-label {
font-size: 90%;
padding: 3px 20px;
color: var(--color-primary-text);
background-color: var(--color-success);
border-radius: 15px;
}
}
.tag {