Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Move to storing the date instead of boolean for done state
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 8, 2023
commit c2fd5163b02425b9665d4e211681a4db9cf0f880
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -107,7 +107,7 @@ public function __construct() {
$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');
Expand Down
6 changes: 3 additions & 3 deletions lib/Db/CardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function findAllWithDue(array $boardIds) {
->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)))
Expand All @@ -285,7 +285,7 @@ public function findToMeOrNotAssignedCards(array $boardIds, string $username) {
)
// 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)))
Expand All @@ -300,7 +300,7 @@ public function findOverdue() {
->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);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Migration/Version1011Date20230901010840.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

Expand All @@ -47,9 +48,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

$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;
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/CardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function delete($id) {
* @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);
Expand Down Expand Up @@ -532,7 +532,7 @@ public function done(int $id): Card {
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);
Expand All @@ -558,7 +558,7 @@ public function undone(int $id): Card {
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);
Expand Down
36 changes: 5 additions & 31 deletions src/components/card/CardSidebarTabDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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 {
Expand Down