diff --git a/lib/Db/Card.php b/lib/Db/Card.php index 52aa5be91..746ea465c 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -1,4 +1,7 @@ * @@ -37,6 +40,8 @@ use Sabre\VObject\Component\VCalendar; * @method int getCreatedAt() * @method bool getArchived() * @method bool getNotified() + * @method ?DateTime getDone() + * @method void setDone(?DateTime $done) * * @method void setLabels(Label[] $labels) * @method null|Label[] getLabels() @@ -141,19 +146,22 @@ class Card extends RelationalEntity { $event->add('RELATED-TO', 'deck-stack-' . $this->getStackId()); // FIXME: For write support: CANCELLED / IN-PROCESS handling - $event->STATUS = $this->getArchived() ? "COMPLETED" : "NEEDS-ACTION"; - if ($this->getArchived()) { + if ($this->getDone() || $this->getArchived()) { $date = new DateTime(); $date->setTimestamp($this->getLastModified()); - $event->COMPLETED = $date; - //$event->add('PERCENT-COMPLETE', 100); - } - if (count($this->getLabels()) > 0) { - $event->CATEGORIES = array_map(function ($label) { - return $label->getTitle(); - }, $this->getLabels()); + $event->STATUS = 'COMPLETED'; + $event->COMPLETED = $this->getDone() ? $this->$this->getDone() : $this->getArchived(); + } else { + $event->STATUS = 'NEEDS-ACTION'; } + // $event->add('PERCENT-COMPLETE', 100); + + $labels = $this->getLabels() ?? []; + $event->CATEGORIES = array_map(function ($label): string { + return $label->getTitle(); + }, $labels); + $event->SUMMARY = $this->getTitle(); $event->DESCRIPTION = $this->getDescription(); $calendar->add($event); @@ -179,7 +187,7 @@ class Card extends RelationalEntity { return 'card'; } - public function getETag() { + public function getETag(): string { return md5((string)$this->getLastModified()); } }