1
0
Fork 0
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:
lkassianik 2015-06-07 15:57:19 -07:00
parent ecc4c531c9
commit 47051643c7
3 changed files with 55 additions and 11 deletions

View file

@ -324,7 +324,7 @@ final class PhabricatorCalendarEventEditController
->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')

View file

@ -265,10 +265,20 @@ final class PhabricatorCalendarEventEditor
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 @@ final class PhabricatorCalendarEventEditor
$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 @@ final class PhabricatorCalendarEventEditor
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;
}

View file

@ -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);
var end_date_checkbox = JX.DOM.find(end_date, 'input', 'calendar-enable');
JX.DOM.listen(checkbox, 'change', null, function() {
var frequency = JX.$(config.frequency);
var end_date = JX.$(config.recurrenceEndDate);
frequency.disabled = checkbox.checked ? false : true;
end_date.disabled = checkbox.checked ? false : true;
if (end_date.disabled) {
JX.DOM.alterClass(end_date, 'datepicker-disabled', !checkbox.checked);
if (checkbox.checked) {
enableRecurring();
} else {
disableRecurring();
}
});
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);
}
});