mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Show informative errors when attempting to set a recurrence end date on a non-recurring event.
Summary: Fixes T8458, Show informative errors when attempting to set a recurrence end date on a non-recurring event. Test Plan: Create new event, set recurrence end date via date-picker without setting the "is recurring" checkbox, and attempt to save. Should get error saying there cannot be a recurrence end date on a non-recurring event. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T8458 Differential Revision: https://secure.phabricator.com/D13192
This commit is contained in:
parent
ecc4c531c9
commit
47051643c7
3 changed files with 55 additions and 11 deletions
|
@ -324,7 +324,7 @@ final class PhabricatorCalendarEventEditController
|
||||||
->setID($recurrence_end_date_id)
|
->setID($recurrence_end_date_id)
|
||||||
->setIsTimeDisabled(true)
|
->setIsTimeDisabled(true)
|
||||||
->setAllowNull(true)
|
->setAllowNull(true)
|
||||||
->setIsDisabled(!$is_recurring);
|
->setIsDisabled($recurrence_end_date_value->isDisabled());
|
||||||
|
|
||||||
$recurrence_frequency_select = id(new AphrontFormSelectControl())
|
$recurrence_frequency_select = id(new AphrontFormSelectControl())
|
||||||
->setName('frequency')
|
->setName('frequency')
|
||||||
|
|
|
@ -265,10 +265,20 @@ final class PhabricatorCalendarEventEditor
|
||||||
protected function validateAllTransactions(
|
protected function validateAllTransactions(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
$start_date_xaction = PhabricatorCalendarEventTransaction::TYPE_START_DATE;
|
$start_date_xaction =
|
||||||
$end_date_xaction = PhabricatorCalendarEventTransaction::TYPE_END_DATE;
|
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();
|
$start_date = $object->getDateFrom();
|
||||||
$end_date = $object->getDateTo();
|
$end_date = $object->getDateTo();
|
||||||
|
$recurrence_end = $object->getRecurrenceEndDate();
|
||||||
|
$is_recurring = $object->getIsRecurring();
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
|
@ -276,6 +286,10 @@ final class PhabricatorCalendarEventEditor
|
||||||
$start_date = $xaction->getNewValue()->getEpoch();
|
$start_date = $xaction->getNewValue()->getEpoch();
|
||||||
} else if ($xaction->getTransactionType() == $end_date_xaction) {
|
} else if ($xaction->getTransactionType() == $end_date_xaction) {
|
||||||
$end_date = $xaction->getNewValue()->getEpoch();
|
$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) {
|
if ($start_date > $end_date) {
|
||||||
|
@ -287,6 +301,16 @@ final class PhabricatorCalendarEventEditor
|
||||||
null);
|
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;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,37 @@
|
||||||
|
|
||||||
JX.behavior('recurring-edit', function(config) {
|
JX.behavior('recurring-edit', function(config) {
|
||||||
var checkbox = JX.$(config.isRecurring);
|
var checkbox = JX.$(config.isRecurring);
|
||||||
|
var frequency = JX.$(config.frequency);
|
||||||
|
var end_date = JX.$(config.recurrenceEndDate);
|
||||||
|
|
||||||
|
var end_date_checkbox = JX.DOM.find(end_date, 'input', 'calendar-enable');
|
||||||
|
|
||||||
JX.DOM.listen(checkbox, 'change', null, function() {
|
JX.DOM.listen(checkbox, 'change', null, function() {
|
||||||
var frequency = JX.$(config.frequency);
|
if (checkbox.checked) {
|
||||||
var end_date = JX.$(config.recurrenceEndDate);
|
enableRecurring();
|
||||||
|
} else {
|
||||||
frequency.disabled = checkbox.checked ? false : true;
|
disableRecurring();
|
||||||
end_date.disabled = checkbox.checked ? false : true;
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue