2016-07-13 00:44:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorCalendarEventDateTransaction
|
|
|
|
extends PhabricatorCalendarEventTransactionType {
|
|
|
|
|
|
|
|
abstract protected function getInvalidDateMessage();
|
|
|
|
|
Smooth out various transaction/editing behaviors for Calendar
Summary:
Ref T11809.
- Allow users to remove the "Until" date from recurring events.
- When removing "Until", show a sensible string ("...set this event to repeat forever.")
- When users go through the "Make Recurring" workflow, don't require them to explicitly select "Recurring: Recurring" from the dropdown. This intent is clear from clicking "Make Recurring".
- When editing "All Future Events", don't literally apply date changes to them, since that doesn't make sense. We update the template, then reschedule any events which haven't been edited already. I think this is what users probably mean if they make this edit.
- When creating an event with a non-default icon, don't show "alice changed the icon from Default to Party.".
- Hide the "recurring mode" transaction, which had no string ("alice edited this Event.") and was redundant anyway.
- Also, add a little piece of developer text to make hunting these things down easier.
Test Plan: Edited various events, parents, children, made events recur, set until, unset until, viewed transactions, rescheduled parents, rescheduled children.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11809
Differential Revision: https://secure.phabricator.com/D16796
2016-11-02 23:15:09 +01:00
|
|
|
public function isInheritedEdit() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-13 00:44:11 +02:00
|
|
|
public function generateNewValue($object, $value) {
|
2016-11-01 20:55:27 +01:00
|
|
|
$editor = $this->getEditor();
|
Smooth out various transaction/editing behaviors for Calendar
Summary:
Ref T11809.
- Allow users to remove the "Until" date from recurring events.
- When removing "Until", show a sensible string ("...set this event to repeat forever.")
- When users go through the "Make Recurring" workflow, don't require them to explicitly select "Recurring: Recurring" from the dropdown. This intent is clear from clicking "Make Recurring".
- When editing "All Future Events", don't literally apply date changes to them, since that doesn't make sense. We update the template, then reschedule any events which haven't been edited already. I think this is what users probably mean if they make this edit.
- When creating an event with a non-default icon, don't show "alice changed the icon from Default to Party.".
- Hide the "recurring mode" transaction, which had no string ("alice edited this Event.") and was redundant anyway.
- Also, add a little piece of developer text to make hunting these things down easier.
Test Plan: Edited various events, parents, children, made events recur, set until, unset until, viewed transactions, rescheduled parents, rescheduled children.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11809
Differential Revision: https://secure.phabricator.com/D16796
2016-11-02 23:15:09 +01:00
|
|
|
|
|
|
|
if ($value->isDisabled()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-11-01 20:55:27 +01:00
|
|
|
return $value->newPhutilDateTime()
|
|
|
|
->setIsAllDay($editor->getNewIsAllDay())
|
|
|
|
->newAbsoluteDateTime()
|
|
|
|
->toDictionary();
|
2016-07-13 00:44:11 +02:00
|
|
|
}
|
|
|
|
|
2016-11-28 18:17:26 +01:00
|
|
|
public function getTransactionHasEffect($object, $old, $new) {
|
|
|
|
$editor = $this->getEditor();
|
|
|
|
|
|
|
|
$actor = $this->getActor();
|
|
|
|
$actor_timezone = $actor->getTimezoneIdentifier();
|
|
|
|
|
|
|
|
// When an edit only changes the timezone of an event without materially
|
|
|
|
// changing the absolute time, discard it. This can happen if two users in
|
|
|
|
// different timezones edit an event without rescheduling it.
|
|
|
|
|
|
|
|
// Eventually, after T11073, there may be a UI control to adjust timezones.
|
|
|
|
// If a user explicitly changed the timezone, we should respect that.
|
|
|
|
// However, there is no way for users to intentionally apply this kind of
|
|
|
|
// edit today.
|
|
|
|
|
|
|
|
$old_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($old)
|
|
|
|
->setIsAllDay($editor->getNewIsAllDay())
|
|
|
|
->setViewerTimezone($actor_timezone);
|
|
|
|
|
|
|
|
$new_datetime = PhutilCalendarAbsoluteDateTime::newFromDictionary($new)
|
|
|
|
->setIsAllDay($editor->getNewIsAllDay())
|
|
|
|
->setViewerTimezone($actor_timezone);
|
|
|
|
|
|
|
|
$old_epoch = $old_datetime->getEpoch();
|
|
|
|
$new_epoch = $new_datetime->getEpoch();
|
|
|
|
|
|
|
|
return ($old_epoch !== $new_epoch);
|
|
|
|
}
|
|
|
|
|
2016-07-13 00:44:11 +02:00
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
|
|
$errors = array();
|
|
|
|
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
if ($xaction->getNewValue()->isValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = $this->getInvalidDateMessage();
|
|
|
|
$errors[] = $this->newInvalidError($message, $xaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|