1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Move event recurrence controls to a separate page on the workflow

Summary:
Ref T11326. Currently, the "Create Event" form is pretty wordy. One particular culprit is the "recurring" controls, which are (presumably) rarely used and visually complex.

  - Reflow the default form to hopefully feel a little better.
  - Move recurrence stuff to a separate workflow.

Test Plan:
{F1891355}

{F1891356}

{F1891357}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11326

Differential Revision: https://secure.phabricator.com/D16774
This commit is contained in:
epriestley 2016-10-31 09:08:01 -07:00
parent ee834c5958
commit 850fcf0207
4 changed files with 133 additions and 88 deletions

View file

@ -146,6 +146,8 @@ final class PhabricatorCalendarEventViewController
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = "event/edit/{$id}/"; $edit_uri = "event/edit/{$id}/";
$edit_uri = $this->getApplicationURI($edit_uri);
if ($event->isChildEvent()) { if ($event->isChildEvent()) {
$edit_label = pht('Edit This Instance'); $edit_label = pht('Edit This Instance');
} else { } else {
@ -159,11 +161,28 @@ final class PhabricatorCalendarEventViewController
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setName($edit_label) ->setName($edit_label)
->setIcon('fa-pencil') ->setIcon('fa-pencil')
->setHref($this->getApplicationURI($edit_uri)) ->setHref($edit_uri)
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)); ->setWorkflow(!$can_edit));
} }
$recurring_uri = "{$edit_uri}page/recurring/";
$can_recurring = $can_edit && !$event->isChildEvent();
if ($event->getIsRecurring()) {
$recurring_label = pht('Edit Recurrence');
} else {
$recurring_label = pht('Make Recurring');
}
$curtain->addAction(
id(new PhabricatorActionView())
->setName($recurring_label)
->setIcon('fa-repeat')
->setHref($recurring_uri)
->setDisabled(!$can_recurring)
->setWorkflow(true));
$can_attend = !$event->isImportedEvent(); $can_attend = !$event->isImportedEvent();
if ($is_attending) { if ($is_attending) {

View file

@ -67,12 +67,15 @@ final class PhabricatorCalendarEventEditEngine
$invitee_phids = $object->getInviteePHIDsForEdit(); $invitee_phids = $object->getInviteePHIDsForEdit();
} }
$frequency_options = array( $frequency_map = PhabricatorCalendarEvent::getFrequencyMap();
PhutilCalendarRecurrenceRule::FREQUENCY_DAILY => pht('Daily'), $frequency_options = ipull($frequency_map, 'label');
PhutilCalendarRecurrenceRule::FREQUENCY_WEEKLY => pht('Weekly'),
PhutilCalendarRecurrenceRule::FREQUENCY_MONTHLY => pht('Monthly'), $rrule = $object->newRecurrenceRule();
PhutilCalendarRecurrenceRule::FREQUENCY_YEARLY => pht('Yearly'), if ($rrule) {
); $frequency = $rrule->getFrequency();
} else {
$frequency = null;
}
$fields = array( $fields = array(
id(new PhabricatorTextEditField()) id(new PhabricatorTextEditField())
@ -85,15 +88,38 @@ final class PhabricatorCalendarEventEditEngine
->setConduitDescription(pht('Rename the event.')) ->setConduitDescription(pht('Rename the event.'))
->setConduitTypeDescription(pht('New event name.')) ->setConduitTypeDescription(pht('New event name.'))
->setValue($object->getName()), ->setValue($object->getName()),
id(new PhabricatorRemarkupEditField()) id(new PhabricatorBoolEditField())
->setKey('description') ->setKey('isAllDay')
->setLabel(pht('Description')) ->setLabel(pht('All Day'))
->setDescription(pht('Description of the event.')) ->setOptions(pht('Normal Event'), pht('All Day Event'))
->setTransactionType( ->setTransactionType(
PhabricatorCalendarEventDescriptionTransaction::TRANSACTIONTYPE) PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE)
->setConduitDescription(pht('Update the event description.')) ->setDescription(pht('Marks this as an all day event.'))
->setConduitTypeDescription(pht('New event description.')) ->setConduitDescription(pht('Make the event an all day event.'))
->setValue($object->getDescription()), ->setConduitTypeDescription(pht('Mark the event as an all day event.'))
->setValue($object->getIsAllDay()),
id(new PhabricatorEpochEditField())
->setKey('start')
->setLabel(pht('Start'))
->setIsLockable(false)
->setIsDefaultable(false)
->setTransactionType(
PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('Start time of the event.'))
->setConduitDescription(pht('Change the start time of the event.'))
->setConduitTypeDescription(pht('New event start time.'))
->setValue($object->getStartDateTimeEpoch()),
id(new PhabricatorEpochEditField())
->setKey('end')
->setLabel(pht('End'))
->setIsLockable(false)
->setIsDefaultable(false)
->setTransactionType(
PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('End time of the event.'))
->setConduitDescription(pht('Change the end time of the event.'))
->setConduitTypeDescription(pht('New event end time.'))
->setValue($object->getEndDateTimeEpoch()),
id(new PhabricatorBoolEditField()) id(new PhabricatorBoolEditField())
->setKey('cancelled') ->setKey('cancelled')
->setOptions(pht('Active'), pht('Cancelled')) ->setOptions(pht('Active'), pht('Cancelled'))
@ -128,91 +154,16 @@ final class PhabricatorCalendarEventEditEngine
->setConduitTypeDescription(pht('New event invitees.')) ->setConduitTypeDescription(pht('New event invitees.'))
->setValue($invitee_phids) ->setValue($invitee_phids)
->setCommentActionLabel(pht('Change Invitees')), ->setCommentActionLabel(pht('Change Invitees')),
); id(new PhabricatorRemarkupEditField())
->setKey('description')
if ($this->getIsCreate()) { ->setLabel(pht('Description'))
$fields[] = id(new PhabricatorBoolEditField()) ->setDescription(pht('Description of the event.'))
->setKey('isRecurring')
->setLabel(pht('Recurring'))
->setOptions(pht('One-Time Event'), pht('Recurring Event'))
->setTransactionType( ->setTransactionType(
PhabricatorCalendarEventRecurringTransaction::TRANSACTIONTYPE) PhabricatorCalendarEventDescriptionTransaction::TRANSACTIONTYPE)
->setDescription(pht('One time or recurring event.')) ->setConduitDescription(pht('Update the event description.'))
->setConduitDescription(pht('Make the event recurring.')) ->setConduitTypeDescription(pht('New event description.'))
->setConduitTypeDescription(pht('Mark the event as a recurring event.')) ->setValue($object->getDescription()),
->setValue($object->getIsRecurring()); id(new PhabricatorIconSetEditField())
$rrule = $object->newRecurrenceRule();
if ($rrule) {
$frequency = $rrule->getFrequency();
} else {
$frequency = null;
}
$fields[] = id(new PhabricatorSelectEditField())
->setKey('frequency')
->setLabel(pht('Frequency'))
->setOptions($frequency_options)
->setTransactionType(
PhabricatorCalendarEventFrequencyTransaction::TRANSACTIONTYPE)
->setDescription(pht('Recurring event frequency.'))
->setConduitDescription(pht('Change the event frequency.'))
->setConduitTypeDescription(pht('New event frequency.'))
->setValue($frequency);
}
if ($this->getIsCreate() || $object->getIsRecurring()) {
$fields[] = id(new PhabricatorEpochEditField())
->setIsLockable(false)
->setIsDefaultable(false)
->setAllowNull(true)
->setKey('until')
->setLabel(pht('Repeat Until'))
->setTransactionType(
PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('Last instance of the event.'))
->setConduitDescription(pht('Change when the event repeats until.'))
->setConduitTypeDescription(pht('New final event time.'))
->setValue($object->getUntilDateTimeEpoch());
}
$fields[] = id(new PhabricatorBoolEditField())
->setKey('isAllDay')
->setLabel(pht('All Day'))
->setOptions(pht('Normal Event'), pht('All Day Event'))
->setTransactionType(
PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE)
->setDescription(pht('Marks this as an all day event.'))
->setConduitDescription(pht('Make the event an all day event.'))
->setConduitTypeDescription(pht('Mark the event as an all day event.'))
->setValue($object->getIsAllDay());
$fields[] = id(new PhabricatorEpochEditField())
->setKey('start')
->setLabel(pht('Start'))
->setIsLockable(false)
->setIsDefaultable(false)
->setTransactionType(
PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('Start time of the event.'))
->setConduitDescription(pht('Change the start time of the event.'))
->setConduitTypeDescription(pht('New event start time.'))
->setValue($object->getStartDateTimeEpoch());
$fields[] = id(new PhabricatorEpochEditField())
->setKey('end')
->setLabel(pht('End'))
->setIsLockable(false)
->setIsDefaultable(false)
->setTransactionType(
PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('End time of the event.'))
->setConduitDescription(pht('Change the end time of the event.'))
->setConduitTypeDescription(pht('New event end time.'))
->setValue($object->getEndDateTimeEpoch());
$fields[] = id(new PhabricatorIconSetEditField())
->setKey('icon') ->setKey('icon')
->setLabel(pht('Icon')) ->setLabel(pht('Icon'))
->setIconSet(new PhabricatorCalendarIconSet()) ->setIconSet(new PhabricatorCalendarIconSet())
@ -221,7 +172,42 @@ final class PhabricatorCalendarEventEditEngine
->setDescription(pht('Event icon.')) ->setDescription(pht('Event icon.'))
->setConduitDescription(pht('Change the event icon.')) ->setConduitDescription(pht('Change the event icon.'))
->setConduitTypeDescription(pht('New event icon.')) ->setConduitTypeDescription(pht('New event icon.'))
->setValue($object->getIcon()); ->setValue($object->getIcon()),
id(new PhabricatorBoolEditField())
->setIsHidden($object->getIsRecurring())
->setKey('isRecurring')
->setLabel(pht('Recurring'))
->setOptions(pht('One-Time Event'), pht('Recurring Event'))
->setTransactionType(
PhabricatorCalendarEventRecurringTransaction::TRANSACTIONTYPE)
->setDescription(pht('One time or recurring event.'))
->setConduitDescription(pht('Make the event recurring.'))
->setConduitTypeDescription(pht('Mark the event as a recurring event.'))
->setValue($object->getIsRecurring()),
id(new PhabricatorSelectEditField())
->setKey('frequency')
->setLabel(pht('Frequency'))
->setOptions($frequency_options)
->setTransactionType(
PhabricatorCalendarEventFrequencyTransaction::TRANSACTIONTYPE)
->setDescription(pht('Recurring event frequency.'))
->setConduitDescription(pht('Change the event frequency.'))
->setConduitTypeDescription(pht('New event frequency.'))
->setValue($frequency),
id(new PhabricatorEpochEditField())
->setIsLockable(false)
->setIsDefaultable(false)
->setAllowNull(true)
->setHideTime($object->getIsAllDay())
->setKey('until')
->setLabel(pht('Repeat Until'))
->setTransactionType(
PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE)
->setDescription(pht('Last instance of the event.'))
->setConduitDescription(pht('Change when the event repeats until.'))
->setConduitTypeDescription(pht('New final event time.'))
->setValue($object->getUntilDateTimeEpoch()),
);
return $fields; return $fields;
} }
@ -263,8 +249,28 @@ final class PhabricatorCalendarEventEditEngine
} }
} }
return $fields; return $fields;
} }
protected function newPages($object) {
// Controls for event recurrence behavior go on a separate page which we
// put in a dialog. This simplifies event creation in the common case.
return array(
id(new PhabricatorEditPage())
->setKey('core')
->setLabel(pht('Core'))
->setIsDefault(true),
id(new PhabricatorEditPage())
->setKey('recurring')
->setLabel(pht('Recurrence'))
->setFieldKeys(
array(
'isRecurring',
'frequency',
'until',
)),
);
}
} }

View file

@ -461,6 +461,23 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $this->assertAttached($this->invitees); return $this->assertAttached($this->invitees);
} }
public static function getFrequencyMap() {
return array(
PhutilCalendarRecurrenceRule::FREQUENCY_DAILY => array(
'label' => pht('Daily'),
),
PhutilCalendarRecurrenceRule::FREQUENCY_WEEKLY => array(
'label' => pht('Weekly'),
),
PhutilCalendarRecurrenceRule::FREQUENCY_MONTHLY => array(
'label' => pht('Monthly'),
),
PhutilCalendarRecurrenceRule::FREQUENCY_YEARLY => array(
'label' => pht('Yearly'),
),
);
}
private function newStubInvitees() { private function newStubInvitees() {
$parent = $this->getParentEvent(); $parent = $this->getParentEvent();

View file

@ -30,11 +30,14 @@ final class PhabricatorCalendarEventRecurringTransaction
continue; continue;
} }
if ($xaction->getNewValue()) {
continue;
}
$errors[] = $this->newInvalidError( $errors[] = $this->newInvalidError(
pht( pht(
'An event can only be made recurring when it is created. '. 'An event can not be stopped from recurring once it has been '.
'You can not convert an existing event into a recurring '. 'made recurring. You can cancel the event.'),
'event or vice versa.'),
$xaction); $xaction);
} }