Allow safe editing of recurring events
Summary: Ref T8472, Allow safe editing of recurring events Test Plan: Create recurring event, edit event, everything but date-related fields should be editable Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8472 Differential Revision: https://secure.phabricator.com/D13230
This commit is contained in:
		| @@ -144,6 +144,7 @@ final class PhabricatorCalendarEventEditController | |||||||
|     $description = $event->getDescription(); |     $description = $event->getDescription(); | ||||||
|     $is_all_day = $event->getIsAllDay(); |     $is_all_day = $event->getIsAllDay(); | ||||||
|     $is_recurring = $event->getIsRecurring(); |     $is_recurring = $event->getIsRecurring(); | ||||||
|  |     $is_parent = $event->getIsRecurrenceParent(); | ||||||
|     $frequency = idx($event->getRecurrenceFrequency(), 'rule'); |     $frequency = idx($event->getRecurrenceFrequency(), 'rule'); | ||||||
|     $icon = $event->getIcon(); |     $icon = $event->getIcon(); | ||||||
|  |  | ||||||
| @@ -190,7 +191,7 @@ final class PhabricatorCalendarEventEditController | |||||||
|           PhabricatorCalendarEventTransaction::TYPE_NAME) |           PhabricatorCalendarEventTransaction::TYPE_NAME) | ||||||
|         ->setNewValue($name); |         ->setNewValue($name); | ||||||
|  |  | ||||||
|       if ($this->isCreate()) { |       if ($is_parent && $this->isCreate()) { | ||||||
|         $xactions[] = id(new PhabricatorCalendarEventTransaction()) |         $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|           ->setTransactionType( |           ->setTransactionType( | ||||||
|             PhabricatorCalendarEventTransaction::TYPE_RECURRING) |             PhabricatorCalendarEventTransaction::TYPE_RECURRING) | ||||||
| @@ -209,25 +210,28 @@ final class PhabricatorCalendarEventEditController | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       $xactions[] = id(new PhabricatorCalendarEventTransaction()) |       if (($is_parent && $this->isCreate()) || !$is_parent) { | ||||||
|         ->setTransactionType( |         $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|           PhabricatorCalendarEventTransaction::TYPE_ALL_DAY) |           ->setTransactionType( | ||||||
|         ->setNewValue($is_all_day); |             PhabricatorCalendarEventTransaction::TYPE_ALL_DAY) | ||||||
|  |           ->setNewValue($is_all_day); | ||||||
|  |  | ||||||
|       $xactions[] = id(new PhabricatorCalendarEventTransaction()) |         $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|         ->setTransactionType( |           ->setTransactionType( | ||||||
|           PhabricatorCalendarEventTransaction::TYPE_ICON) |             PhabricatorCalendarEventTransaction::TYPE_ICON) | ||||||
|         ->setNewValue($icon); |           ->setNewValue($icon); | ||||||
|  |  | ||||||
|       $xactions[] = id(new PhabricatorCalendarEventTransaction()) |         $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|         ->setTransactionType( |           ->setTransactionType( | ||||||
|           PhabricatorCalendarEventTransaction::TYPE_START_DATE) |             PhabricatorCalendarEventTransaction::TYPE_START_DATE) | ||||||
|         ->setNewValue($start_value); |           ->setNewValue($start_value); | ||||||
|  |  | ||||||
|  |         $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|  |           ->setTransactionType( | ||||||
|  |             PhabricatorCalendarEventTransaction::TYPE_END_DATE) | ||||||
|  |           ->setNewValue($end_value); | ||||||
|  |       } | ||||||
|  |  | ||||||
|       $xactions[] = id(new PhabricatorCalendarEventTransaction()) |  | ||||||
|         ->setTransactionType( |  | ||||||
|           PhabricatorCalendarEventTransaction::TYPE_END_DATE) |  | ||||||
|         ->setNewValue($end_value); |  | ||||||
|  |  | ||||||
|       $xactions[] = id(new PhabricatorCalendarEventTransaction()) |       $xactions[] = id(new PhabricatorCalendarEventTransaction()) | ||||||
|         ->setTransactionType( |         ->setTransactionType( | ||||||
| @@ -296,6 +300,12 @@ final class PhabricatorCalendarEventEditController | |||||||
|     $recurrence_end_date_control = null; |     $recurrence_end_date_control = null; | ||||||
|     $recurrence_frequency_select = null; |     $recurrence_frequency_select = null; | ||||||
|  |  | ||||||
|  |     $all_day_checkbox = null; | ||||||
|  |     $start_control = null; | ||||||
|  |     $end_control = null; | ||||||
|  |  | ||||||
|  |     $recurring_date_edit_label = null; | ||||||
|  |  | ||||||
|     $name = id(new AphrontFormTextControl()) |     $name = id(new AphrontFormTextControl()) | ||||||
|       ->setLabel(pht('Name')) |       ->setLabel(pht('Name')) | ||||||
|       ->setName('name') |       ->setName('name') | ||||||
| @@ -325,8 +335,9 @@ final class PhabricatorCalendarEventEditController | |||||||
|         ->setValue($recurrence_end_date_value) |         ->setValue($recurrence_end_date_value) | ||||||
|         ->setID($recurrence_end_date_id) |         ->setID($recurrence_end_date_id) | ||||||
|         ->setIsTimeDisabled(true) |         ->setIsTimeDisabled(true) | ||||||
|  |         ->setIsDisabled($recurrence_end_date_value->isDisabled()) | ||||||
|         ->setAllowNull(true) |         ->setAllowNull(true) | ||||||
|         ->setIsDisabled($recurrence_end_date_value->isDisabled()); |         ->isRequired(false); | ||||||
|  |  | ||||||
|       $recurrence_frequency_select = id(new AphrontFormSelectControl()) |       $recurrence_frequency_select = id(new AphrontFormSelectControl()) | ||||||
|         ->setName('frequency') |         ->setName('frequency') | ||||||
| @@ -342,38 +353,90 @@ final class PhabricatorCalendarEventEditController | |||||||
|         ->setDisabled(!$is_recurring); |         ->setDisabled(!$is_recurring); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Javelin::initBehavior('event-all-day', array( |     if ($this->isCreate() || (!$is_parent && !$this->isCreate())) { | ||||||
|       'allDayID' => $all_day_id, |       Javelin::initBehavior('event-all-day', array( | ||||||
|       'startDateID' => $start_date_id, |         'allDayID' => $all_day_id, | ||||||
|       'endDateID' => $end_date_id, |         'startDateID' => $start_date_id, | ||||||
|     )); |         'endDateID' => $end_date_id, | ||||||
|  |       )); | ||||||
|  |  | ||||||
|     $all_day_checkbox = id(new AphrontFormCheckboxControl()) |       $all_day_checkbox = id(new AphrontFormCheckboxControl()) | ||||||
|       ->addCheckbox( |         ->addCheckbox( | ||||||
|         'isAllDay', |           'isAllDay', | ||||||
|         1, |           1, | ||||||
|         pht('All Day Event'), |           pht('All Day Event'), | ||||||
|         $is_all_day, |           $is_all_day, | ||||||
|         $all_day_id); |           $all_day_id); | ||||||
|  |  | ||||||
|     $start_control = id(new AphrontFormDateControl()) |       $start_control = id(new AphrontFormDateControl()) | ||||||
|       ->setUser($viewer) |         ->setUser($viewer) | ||||||
|       ->setName('start') |         ->setName('start') | ||||||
|       ->setLabel(pht('Start')) |         ->setLabel(pht('Start')) | ||||||
|       ->setError($error_start_date) |         ->setError($error_start_date) | ||||||
|       ->setValue($start_value) |         ->setValue($start_value) | ||||||
|       ->setID($start_date_id) |         ->setID($start_date_id) | ||||||
|       ->setIsTimeDisabled($is_all_day) |         ->setIsTimeDisabled($is_all_day) | ||||||
|       ->setEndDateID($end_date_id); |         ->setEndDateID($end_date_id); | ||||||
|  |  | ||||||
|     $end_control = id(new AphrontFormDateControl()) |       $end_control = id(new AphrontFormDateControl()) | ||||||
|       ->setUser($viewer) |         ->setUser($viewer) | ||||||
|       ->setName('end') |         ->setName('end') | ||||||
|       ->setLabel(pht('End')) |         ->setLabel(pht('End')) | ||||||
|       ->setError($error_end_date) |         ->setError($error_end_date) | ||||||
|       ->setValue($end_value) |         ->setValue($end_value) | ||||||
|       ->setID($end_date_id) |         ->setID($end_date_id) | ||||||
|       ->setIsTimeDisabled($is_all_day); |         ->setIsTimeDisabled($is_all_day); | ||||||
|  |     } else if ($is_parent) { | ||||||
|  |       $recurring_date_edit_label = id(new AphrontFormStaticControl()) | ||||||
|  |         ->setUser($viewer) | ||||||
|  |         ->setValue(pht('Date and time of recurring event cannot be edited.')); | ||||||
|  |  | ||||||
|  |       if (!$recurrence_end_date_value->isDisabled()) { | ||||||
|  |         $disabled_recurrence_end_date_value = | ||||||
|  |           $recurrence_end_date_value->getValueAsFormat('M d, Y'); | ||||||
|  |         $recurrence_end_date_control = id(new AphrontFormStaticControl()) | ||||||
|  |           ->setUser($viewer) | ||||||
|  |           ->setLabel(pht('Recurrence End Date')) | ||||||
|  |           ->setValue($disabled_recurrence_end_date_value) | ||||||
|  |           ->setDisabled(true); | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       $recurrence_frequency_select = id(new AphrontFormSelectControl()) | ||||||
|  |         ->setName('frequency') | ||||||
|  |         ->setOptions(array( | ||||||
|  |             'daily' => pht('Daily'), | ||||||
|  |             'weekly' => pht('Weekly'), | ||||||
|  |             'monthly' => pht('Monthly'), | ||||||
|  |             'yearly' => pht('Yearly'), | ||||||
|  |           )) | ||||||
|  |         ->setValue($frequency) | ||||||
|  |         ->setLabel(pht('Recurring Event Frequency')) | ||||||
|  |         ->setID($frequency_id) | ||||||
|  |         ->setDisabled(true); | ||||||
|  |  | ||||||
|  |       $all_day_checkbox = id(new AphrontFormCheckboxControl()) | ||||||
|  |         ->addCheckbox( | ||||||
|  |           'isAllDay', | ||||||
|  |           1, | ||||||
|  |           pht('All Day Event'), | ||||||
|  |           $is_all_day, | ||||||
|  |           $all_day_id) | ||||||
|  |         ->setDisabled(true); | ||||||
|  |  | ||||||
|  |       $start_disabled = $start_value->getValueAsFormat('M d, Y, g:i A'); | ||||||
|  |       $end_disabled = $end_value->getValueAsFormat('M d, Y, g:i A'); | ||||||
|  |  | ||||||
|  |       $start_control = id(new AphrontFormStaticControl()) | ||||||
|  |         ->setUser($viewer) | ||||||
|  |         ->setLabel(pht('Start')) | ||||||
|  |         ->setValue($start_disabled) | ||||||
|  |         ->setDisabled(true); | ||||||
|  |  | ||||||
|  |       $end_control = id(new AphrontFormStaticControl()) | ||||||
|  |         ->setUser($viewer) | ||||||
|  |         ->setLabel(pht('End')) | ||||||
|  |         ->setValue($end_disabled); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     $description = id(new AphrontFormTextAreaControl()) |     $description = id(new AphrontFormTextAreaControl()) | ||||||
|       ->setLabel(pht('Description')) |       ->setLabel(pht('Description')) | ||||||
| @@ -427,6 +490,9 @@ final class PhabricatorCalendarEventEditController | |||||||
|       ->setUser($viewer) |       ->setUser($viewer) | ||||||
|       ->appendChild($name); |       ->appendChild($name); | ||||||
|  |  | ||||||
|  |     if ($recurring_date_edit_label) { | ||||||
|  |       $form->appendControl($recurring_date_edit_label); | ||||||
|  |     } | ||||||
|     if ($is_recurring_checkbox) { |     if ($is_recurring_checkbox) { | ||||||
|       $form->appendChild($is_recurring_checkbox); |       $form->appendChild($is_recurring_checkbox); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -167,7 +167,7 @@ final class PhabricatorCalendarEventViewController | |||||||
|     } else if ($event->getIsRecurrenceException()) { |     } else if ($event->getIsRecurrenceException()) { | ||||||
|       $edit_label = pht('Edit This Instance'); |       $edit_label = pht('Edit This Instance'); | ||||||
|       $edit_uri = "event/edit/{$id}/"; |       $edit_uri = "event/edit/{$id}/"; | ||||||
|     } else if (!$event->getIsRecurrenceParent()) { |     } else { | ||||||
|       $edit_label = pht('Edit'); |       $edit_label = pht('Edit'); | ||||||
|       $edit_uri = "event/edit/{$id}/"; |       $edit_uri = "event/edit/{$id}/"; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 lkassianik
					lkassianik