mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Smooth over a few more transaction compatibility/structure issues with Calendar events
Summary: Ref T9275. This gets things roughly into shape for a cutover to EditEngine, mostly by fixing some problems with "recurrence end date" not being nullable while editing events. Test Plan: Edited events with EditPro controller, nothing was obviously broken. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9275 Differential Revision: https://secure.phabricator.com/D16282
This commit is contained in:
parent
bac6acb3d1
commit
a46a4362db
7 changed files with 49 additions and 18 deletions
|
@ -6633,7 +6633,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditProController' => 'ManiphestController',
|
||||
'PhabricatorCalendarEventEditProController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand',
|
||||
'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||
|
|
|
@ -3,13 +3,30 @@
|
|||
final class AphrontEpochHTTPParameterType
|
||||
extends AphrontHTTPParameterType {
|
||||
|
||||
private $allowNull;
|
||||
|
||||
public function setAllowNull($allow_null) {
|
||||
$this->allowNull = $allow_null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllowNull() {
|
||||
return $this->allowNull;
|
||||
}
|
||||
|
||||
protected function getParameterExists(AphrontRequest $request, $key) {
|
||||
return $request->getExists($key) ||
|
||||
$request->getExists($key.'_d');
|
||||
}
|
||||
|
||||
protected function getParameterValue(AphrontRequest $request, $key) {
|
||||
return AphrontFormDateControlValue::newFromRequest($request, $key);
|
||||
$value = AphrontFormDateControlValue::newFromRequest($request, $key);
|
||||
|
||||
if ($this->getAllowNull()) {
|
||||
$value->setOptional(true);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function getParameterTypeName() {
|
||||
|
|
|
@ -185,7 +185,7 @@ final class PhabricatorCalendarEventEditController
|
|||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE)
|
||||
->setNewValue($recurrence_end_date_value->getEpoch());
|
||||
->setNewValue($recurrence_end_date_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,12 +203,12 @@ final class PhabricatorCalendarEventEditController
|
|||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarEventTransaction::TYPE_START_DATE)
|
||||
->setNewValue($start_value->getEpoch());
|
||||
->setNewValue($start_value);
|
||||
|
||||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarEventTransaction::TYPE_END_DATE)
|
||||
->setNewValue($end_value->getEpoch());
|
||||
->setNewValue($end_value);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCalendarEventEditProController
|
||||
extends ManiphestController {
|
||||
extends PhabricatorCalendarController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
return id(new PhabricatorCalendarEditEngine())
|
||||
|
|
|
@ -85,9 +85,9 @@ final class PhabricatorCalendarEventEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
|
||||
return $object->getIsRecurring();
|
||||
return (int)$object->getIsRecurring();
|
||||
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
|
||||
return $object->getRecurrenceFrequency();
|
||||
return $object->getFrequencyUnit();
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE:
|
||||
return $object->getRecurrenceEndDate();
|
||||
case PhabricatorCalendarEventTransaction::TYPE_NAME:
|
||||
|
@ -120,7 +120,6 @@ final class PhabricatorCalendarEventEditor
|
|||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_NAME:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
|
||||
|
@ -132,11 +131,12 @@ final class PhabricatorCalendarEventEditor
|
|||
case PhabricatorCalendarEventTransaction::TYPE_DECLINE:
|
||||
return PhabricatorCalendarEventInvitee::STATUS_DECLINED;
|
||||
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
|
||||
return (int)$xaction->getNewValue();
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_START_DATE:
|
||||
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
|
||||
return $xaction->getNewValue();
|
||||
return $xaction->getNewValue()->getEpoch();
|
||||
case PhabricatorCalendarEventTransaction::TYPE_INVITE:
|
||||
$status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
|
||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
|
||||
|
@ -187,9 +187,12 @@ final class PhabricatorCalendarEventEditor
|
|||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
|
||||
return $object->setIsRecurring($xaction->getNewValue());
|
||||
return $object->setIsRecurring((int)$xaction->getNewValue());
|
||||
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
|
||||
return $object->setRecurrenceFrequency($xaction->getNewValue());
|
||||
return $object->setRecurrenceFrequency(
|
||||
array(
|
||||
'rule' => $xaction->getNewValue(),
|
||||
));
|
||||
case PhabricatorCalendarEventTransaction::TYPE_NAME:
|
||||
$object->setName($xaction->getNewValue());
|
||||
return;
|
||||
|
@ -370,11 +373,11 @@ final class PhabricatorCalendarEventEditor
|
|||
|
||||
foreach ($xactions as $xaction) {
|
||||
if ($xaction->getTransactionType() == $start_date_xaction) {
|
||||
$start_date = $xaction->getNewValue();
|
||||
$start_date = $xaction->getNewValue()->getEpoch();
|
||||
} else if ($xaction->getTransactionType() == $end_date_xaction) {
|
||||
$end_date = $xaction->getNewValue();
|
||||
$end_date = $xaction->getNewValue()->getEpoch();
|
||||
} else if ($xaction->getTransactionType() == $recurrence_end_xaction) {
|
||||
$recurrence_end = $xaction->getNewValue();
|
||||
$recurrence_end = $xaction->getNewValue()->getEpoch();
|
||||
} else if ($xaction->getTransactionType() == $is_recurrence_xaction) {
|
||||
$is_recurring = $xaction->getNewValue();
|
||||
}
|
||||
|
|
|
@ -265,8 +265,13 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($author_phid));
|
||||
return $text;
|
||||
case self::TYPE_FREQUENCY:
|
||||
$rule = $new;
|
||||
if (is_array($rule)) {
|
||||
$rule = idx($rule, 'rule');
|
||||
}
|
||||
|
||||
$text = '';
|
||||
switch ($new['rule']) {
|
||||
switch ($rule) {
|
||||
case PhabricatorCalendarEvent::FREQUENCY_DAILY:
|
||||
$text = pht('%s set this event to repeat daily.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
|
@ -487,8 +492,13 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($object_phid));
|
||||
return $text;
|
||||
case self::TYPE_FREQUENCY:
|
||||
$rule = $new;
|
||||
if (is_array($rule)) {
|
||||
$rule = idx($rule, 'rule');
|
||||
}
|
||||
|
||||
$text = '';
|
||||
switch ($new['rule']) {
|
||||
switch ($rule) {
|
||||
case PhabricatorCalendarEvent::FREQUENCY_DAILY:
|
||||
$text = pht('%s set %s to repeat daily.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
|
|
|
@ -21,7 +21,8 @@ final class PhabricatorEpochEditField
|
|||
}
|
||||
|
||||
protected function newHTTPParameterType() {
|
||||
return new AphrontEpochHTTPParameterType();
|
||||
return id(new AphrontEpochHTTPParameterType())
|
||||
->setAllowNull($this->getAllowNull());
|
||||
}
|
||||
|
||||
protected function newConduitParameterType() {
|
||||
|
|
Loading…
Reference in a new issue