fix: Expose done done state through CalDAV
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -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,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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user