Page MenuHomePhabricator

D13192.diff
No OneTemporary

D13192.diff

diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
@@ -324,7 +324,7 @@
->setID($recurrence_end_date_id)
->setIsTimeDisabled(true)
->setAllowNull(true)
- ->setIsDisabled(!$is_recurring);
+ ->setIsDisabled($recurrence_end_date_value->isDisabled());
$recurrence_frequency_select = id(new AphrontFormSelectControl())
->setName('frequency')
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
@@ -265,10 +265,20 @@
protected function validateAllTransactions(
PhabricatorLiskDAO $object,
array $xactions) {
- $start_date_xaction = PhabricatorCalendarEventTransaction::TYPE_START_DATE;
- $end_date_xaction = PhabricatorCalendarEventTransaction::TYPE_END_DATE;
+ $start_date_xaction =
+ PhabricatorCalendarEventTransaction::TYPE_START_DATE;
+ $end_date_xaction =
+ PhabricatorCalendarEventTransaction::TYPE_END_DATE;
+ $is_recurrence_xaction =
+ PhabricatorCalendarEventTransaction::TYPE_RECURRING;
+ $recurrence_end_xaction =
+ PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE;
+
$start_date = $object->getDateFrom();
$end_date = $object->getDateTo();
+ $recurrence_end = $object->getRecurrenceEndDate();
+ $is_recurring = $object->getIsRecurring();
+
$errors = array();
foreach ($xactions as $xaction) {
@@ -276,6 +286,10 @@
$start_date = $xaction->getNewValue()->getEpoch();
} else if ($xaction->getTransactionType() == $end_date_xaction) {
$end_date = $xaction->getNewValue()->getEpoch();
+ } else if ($xaction->getTransactionType() == $recurrence_end_xaction) {
+ $recurrence_end = $xaction->getNewValue();
+ } else if ($xaction->getTransactionType() == $is_recurrence_xaction) {
+ $is_recurring = $xaction->getNewValue();
}
}
if ($start_date > $end_date) {
@@ -287,6 +301,16 @@
null);
}
+ if ($recurrence_end && !$is_recurring) {
+ $type =
+ PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE;
+ $errors[] = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Invalid'),
+ pht('Event must be recurring to have a recurrence end date.').
+ null);
+ }
+
return $errors;
}
diff --git a/webroot/rsrc/js/application/calendar/behavior-recurring-edit.js b/webroot/rsrc/js/application/calendar/behavior-recurring-edit.js
--- a/webroot/rsrc/js/application/calendar/behavior-recurring-edit.js
+++ b/webroot/rsrc/js/application/calendar/behavior-recurring-edit.js
@@ -5,17 +5,37 @@
JX.behavior('recurring-edit', function(config) {
var checkbox = JX.$(config.isRecurring);
+ var frequency = JX.$(config.frequency);
+ var end_date = JX.$(config.recurrenceEndDate);
- JX.DOM.listen(checkbox, 'change', null, function() {
- var frequency = JX.$(config.frequency);
- var end_date = JX.$(config.recurrenceEndDate);
+ var end_date_checkbox = JX.DOM.find(end_date, 'input', 'calendar-enable');
- frequency.disabled = checkbox.checked ? false : true;
- end_date.disabled = checkbox.checked ? false : true;
+ JX.DOM.listen(checkbox, 'change', null, function() {
+ if (checkbox.checked) {
+ enableRecurring();
+ } else {
+ disableRecurring();
+ }
+ });
- if (end_date.disabled) {
- JX.DOM.alterClass(end_date, 'datepicker-disabled', !checkbox.checked);
+ JX.DOM.listen(end_date, 'change', null, function() {
+ if (end_date_checkbox.checked) {
+ enableRecurring();
}
});
+ function enableRecurring() {
+ checkbox.checked = true;
+ frequency.disabled = false;
+ end_date.disabled = false;
+ }
+
+ function disableRecurring() {
+ checkbox.checked = false;
+ frequency.disabled = true;
+ end_date.disabled = true;
+ end_date_checkbox.checked = false;
+
+ JX.DOM.alterClass(end_date, 'datepicker-disabled', true);
+ }
});

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 2:37 PM (1 d, 13 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731445
Default Alt Text
D13192.diff (4 KB)

Event Timeline