Let each workflow watch the due date or the start date
Build package / php-lint (8.4) (push) Successful in 39s
Build package / php-lint (8.5) (push) Successful in 43s
Build package / xml-lint (push) Successful in 13s
Build package / unit-tests (push) Failing after 39s
Build package / package (push) Skipped

Deck 1.18 added a start date to cards (Card::$startdate), so a workflow
no longer has to mean "overdue". Each rule now carries a date_field
('due' | 'start'), chosen in the settings form next to board and stacks.

Existing rules keep the due date: the new column's default supplies it
for every stored row, so there is no backfill step, and
Workflow::getDateFieldOrDue() covers entities that were never near the
database as well as hand-edited values. The controller is the one place
that rejects an unknown value instead of normalising it - a client
asking for a rule it would not get should hear about it.

The probe for the field is property_exists(), not method_exists():
Deck's entities declare no getter as real code - getStartdate(),
getDuedate(), even getId() all go through Entity::__call(), which
method_exists() ignores by definition. A method_exists() guard would
have been false on every Deck version and would have turned every
start-date rule into a silent no-op.

assertDeckAvailable() now also refuses Deck older than 1.18.0. That
floor cannot live in appinfo/info.xml - neither the server's nor the app
store's schema has an app-to-app dependency element - but
<nextcloud min-version="34"> already implies it, since 1.18.x is the
only Deck release line published for Nextcloud 34.

isOverdue() becomes hasPassed(): one function for both dates, since the
comparison and the argument against Deck's day-truncating
getDaysUntilDue() are identical for either.

Also carries a pending NcSelect icon-alignment fix that was already in
the working tree.

Bump to 34.1.0.
This commit is contained in:
Patrick Niebeling
2026-08-25 15:28:30 +02:00
parent 43648f3728
commit 0e66319a06
13 changed files with 390 additions and 41 deletions
+30
View File
@@ -22,6 +22,8 @@ use OCP\DB\Types;
* @method void setFilterUserIds(?string $filterUserIds)
* @method string|null getFilterLabelIds()
* @method void setFilterLabelIds(?string $filterLabelIds)
* @method string|null getDateField()
* @method void setDateField(string $dateField)
* @method bool getNotifyEmail()
* @method void setNotifyEmail(bool $notifyEmail)
* @method bool getEnabled()
@@ -30,6 +32,14 @@ use OCP\DB\Types;
* @method void setLastRun(?\DateTime $lastRun)
*/
class Workflow extends Entity implements \JsonSerializable {
/** Deck's `Card::$duedate` — the card is picked up once it is overdue. */
public const DATE_FIELD_DUE = 'due';
/** Deck's `Card::$startdate` — the card is picked up once its start date has been reached. */
public const DATE_FIELD_START = 'start';
public const DATE_FIELDS = [self::DATE_FIELD_DUE, self::DATE_FIELD_START];
protected $userId;
protected $title;
protected $boardId;
@@ -37,6 +47,7 @@ class Workflow extends Entity implements \JsonSerializable {
protected $targetStackId;
protected $filterUserIds;
protected $filterLabelIds;
protected $dateField;
protected $notifyEmail;
protected $enabled;
protected $lastRun;
@@ -50,11 +61,29 @@ class Workflow extends Entity implements \JsonSerializable {
$this->addType('targetStackId', Types::INTEGER);
$this->addType('filterUserIds', Types::STRING);
$this->addType('filterLabelIds', Types::STRING);
$this->addType('dateField', Types::STRING);
$this->addType('notifyEmail', Types::BOOLEAN);
$this->addType('enabled', Types::BOOLEAN);
$this->addType('lastRun', Types::DATETIME);
}
/**
* The date field to evaluate, never anything else.
*
* Rows written before the column existed carry 'due' from the schema
* default, but a freshly constructed entity holds `null` and a hand-edited
* row could hold anything. Falling back to the due date keeps the old
* behaviour for every value that is not explicitly the start date — the
* safe direction, since 'due' is what every workflow meant before this
* choice existed.
*
* @return self::DATE_FIELD_*
*/
public function getDateFieldOrDue(): string {
$field = $this->getDateField();
return in_array($field, self::DATE_FIELDS, true) ? $field : self::DATE_FIELD_DUE;
}
/**
* @return string[]
*/
@@ -90,6 +119,7 @@ class Workflow extends Entity implements \JsonSerializable {
'targetStackId' => $this->getTargetStackId(),
'filterUserIds' => $this->getFilterUserIdsArray(),
'filterLabelIds' => $this->getFilterLabelIdsArray(),
'dateField' => $this->getDateFieldOrDue(),
'notifyEmail' => (bool)$this->getNotifyEmail(),
'enabled' => (bool)$this->getEnabled(),
'lastRun' => $this->getLastRun()?->format(\DateTimeInterface::ATOM),