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
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
*
@@ -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,18 +146,21 @@ 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->STATUS = 'COMPLETED';
$event->COMPLETED = $this->getDone() ? $this->$this->getDone() : $this->getArchived();
} else {
$event->STATUS = 'NEEDS-ACTION';
}
// $event->add('PERCENT-COMPLETE', 100);
}
if (count($this->getLabels()) > 0) {
$event->CATEGORIES = array_map(function ($label) {
$labels = $this->getLabels() ?? [];
$event->CATEGORIES = array_map(function ($label): string {
return $label->getTitle();
}, $this->getLabels());
}
}, $labels);
$event->SUMMARY = $this->getTitle();
$event->DESCRIPTION = $this->getDescription();
@@ -179,7 +187,7 @@ class Card extends RelationalEntity {
return 'card';
}
public function getETag() {
public function getETag(): string {
return md5((string)$this->getLastModified());
}
}