fix: Expose done done state through CalDAV

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-11-08 08:34:01 +01:00
parent c2fd5163b0
commit c405a5729a

View File

@@ -1,4 +1,7 @@
<?php <?php
declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> * @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
* *
@@ -37,6 +40,8 @@ use Sabre\VObject\Component\VCalendar;
* @method int getCreatedAt() * @method int getCreatedAt()
* @method bool getArchived() * @method bool getArchived()
* @method bool getNotified() * @method bool getNotified()
* @method ?DateTime getDone()
* @method void setDone(?DateTime $done)
* *
* @method void setLabels(Label[] $labels) * @method void setLabels(Label[] $labels)
* @method null|Label[] getLabels() * @method null|Label[] getLabels()
@@ -141,18 +146,21 @@ class Card extends RelationalEntity {
$event->add('RELATED-TO', 'deck-stack-' . $this->getStackId()); $event->add('RELATED-TO', 'deck-stack-' . $this->getStackId());
// FIXME: For write support: CANCELLED / IN-PROCESS handling // FIXME: For write support: CANCELLED / IN-PROCESS handling
$event->STATUS = $this->getArchived() ? "COMPLETED" : "NEEDS-ACTION"; if ($this->getDone() || $this->getArchived()) {
if ($this->getArchived()) {
$date = new DateTime(); $date = new DateTime();
$date->setTimestamp($this->getLastModified()); $date->setTimestamp($this->getLastModified());
$event->COMPLETED = $date; $event->STATUS = 'COMPLETED';
//$event->add('PERCENT-COMPLETE', 100); $event->COMPLETED = $this->getDone() ? $this->$this->getDone() : $this->getArchived();
} else {
$event->STATUS = 'NEEDS-ACTION';
} }
if (count($this->getLabels()) > 0) {
$event->CATEGORIES = array_map(function ($label) { // $event->add('PERCENT-COMPLETE', 100);
$labels = $this->getLabels() ?? [];
$event->CATEGORIES = array_map(function ($label): string {
return $label->getTitle(); return $label->getTitle();
}, $this->getLabels()); }, $labels);
}
$event->SUMMARY = $this->getTitle(); $event->SUMMARY = $this->getTitle();
$event->DESCRIPTION = $this->getDescription(); $event->DESCRIPTION = $this->getDescription();
@@ -179,7 +187,7 @@ class Card extends RelationalEntity {
return 'card'; return 'card';
} }
public function getETag() { public function getETag(): string {
return md5((string)$this->getLastModified()); return md5((string)$this->getLastModified());
} }
} }