Check if the start date is before due date

This commit is contained in:
Frederic Guillot 2017-11-09 11:17:07 -08:00
parent d8e88582f7
commit a12e159de0
32 changed files with 83 additions and 36 deletions

View File

@ -9,10 +9,12 @@ Breaking changes:
New features: New features:
* Add predefined templates for task descriptions * Add predefined templates for task descriptions
* Romanian translation
Improvements: Improvements:
* Improve iCalendar feed to include tasks with start/end date and due date with a time * Improve iCalendar feed to include tasks with start/end date and due date with a time
* Check if the start date is before due date
* You can get an archive of Kanboard by using the download button in Github or the command git archive * You can get an archive of Kanboard by using the download button in Github or the command git archive
Version 1.0.48 (October 23, 2017) Version 1.0.48 (October 23, 2017)

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
'Template removed successfully.' => 'Modèle supprimé avec succès.', 'Template removed successfully.' => 'Modèle supprimé avec succès.',
'Unable to remove this template.' => 'Impossible de supprimer ce modèle.', 'Unable to remove this template.' => 'Impossible de supprimer ce modèle.',
'Template for the task description' => 'Modèle pour la description des tâches', 'Template for the task description' => 'Modèle pour la description des tâches',
'The start date is greater than the end date' => 'La date de début est plus grande que la date d\'échéance',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -22,7 +22,7 @@ return array(
'Dark Grey' => 'Gri închis', 'Dark Grey' => 'Gri închis',
'Pink' => 'Roz', 'Pink' => 'Roz',
'Teal' => 'Turcoaz', 'Teal' => 'Turcoaz',
'Cyan'=> 'Bleu', 'Cyan' => 'Bleu',
'Lime' => 'Lime', 'Lime' => 'Lime',
'Light Green' => 'Verde deschis', 'Light Green' => 'Verde deschis',
'Amber' => 'Ambră', 'Amber' => 'Ambră',
@ -685,8 +685,8 @@ return array(
'Search by color: ' => 'Caută după culoare: ', 'Search by color: ' => 'Caută după culoare: ',
'Search by category: ' => 'Caută după categorie: ', 'Search by category: ' => 'Caută după categorie: ',
'Search by description: ' => 'Caută după descriere: ', 'Search by description: ' => 'Caută după descriere: ',
'Average time spent into each column' => 'Timp mediu petrecut în fiecare coloană',
'Search by due date: ' => 'Caută după dată scadentă: ', 'Search by due date: ' => 'Caută după dată scadentă: ',
'Average time spent into each column' => 'Timp mediu petrecut în fiecare coloană',
'Average time spent' => 'Timp mediu utilizat', 'Average time spent' => 'Timp mediu utilizat',
'This chart show the average time spent into each column for the last %d tasks.' => 'Acest grafic arată timpul mediu petrecut în fiecare coloană pentru ultimele %d sarcini.', 'This chart show the average time spent into each column for the last %d tasks.' => 'Acest grafic arată timpul mediu petrecut în fiecare coloană pentru ultimele %d sarcini.',
'Average Lead and Cycle time' => 'Durată medie de Avans si Ciclu', 'Average Lead and Cycle time' => 'Durată medie de Avans si Ciclu',
@ -1355,5 +1355,6 @@ return array(
'Unable to update this template.' => 'Nu am putut actualiza modelul.', 'Unable to update this template.' => 'Nu am putut actualiza modelul.',
'Template removed successfully.' => 'Model șters.', 'Template removed successfully.' => 'Model șters.',
'Unable to remove this template.' => 'Nu am putut șterge modelul.', 'Unable to remove this template.' => 'Nu am putut șterge modelul.',
'Description Templates' => 'Modele de descriere', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1362,4 +1362,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '', // 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '', // 'Unable to remove this template.' => '',
// 'Template for the task description' => '', // 'Template for the task description' => '',
// 'The start date is greater than the end date' => '',
); );

View File

@ -49,6 +49,20 @@ class TaskValidator extends BaseValidator
); );
} }
public function validateStartAndDueDate(array $values)
{
if (!empty($values['date_started']) && !empty($values['date_due'])) {
$startDate = $this->dateParser->getTimestamp($values['date_started']);
$endDate = $this->dateParser->getTimestamp($values['date_due']);
if ($startDate > $endDate) {
return array(false, array('date_started' => array(t('The start date is greater than the end date'))));
}
}
return array(true, array());
}
/** /**
* Validate task creation * Validate task creation
* *
@ -64,11 +78,14 @@ class TaskValidator extends BaseValidator
); );
$v = new Validator($values, array_merge($rules, $this->commonValidationRules())); $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
$result = $v->execute();
$errors = $v->getErrors();
return array( if ($result) {
$v->execute(), list($result, $errors) = $this->validateStartAndDueDate($values);
$v->getErrors() }
);
return array($result, $errors);
} }
/** /**
@ -133,11 +150,14 @@ class TaskValidator extends BaseValidator
); );
$v = new Validator($values, array_merge($rules, $this->commonValidationRules())); $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
$result = $v->execute();
$errors = $v->getErrors();
return array( if ($result) {
$v->execute(), list($result, $errors) = $this->validateStartAndDueDate($values);
$v->getErrors() }
);
return array($result, $errors);
} }
/** /**
@ -154,11 +174,14 @@ class TaskValidator extends BaseValidator
); );
$v = new Validator($values, array_merge($rules, $this->commonValidationRules())); $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
$result = $v->execute();
$errors = $v->getErrors();
return array( if ($result) {
$v->execute(), list($result, $errors) = $this->validateStartAndDueDate($values);
$v->getErrors() }
);
return array($result, $errors);
} }
/** /**
@ -183,27 +206,6 @@ class TaskValidator extends BaseValidator
); );
} }
/**
* Validate time tracking modification (form)
*
* @access public
* @param array $values Form values
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
*/
public function validateTimeModification(array $values)
{
$rules = array(
new Validators\Required('id', t('The id is required')),
);
$v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
return array(
$v->execute(),
$v->getErrors()
);
}
/** /**
* Validate task email creation * Validate task email creation
* *

View File

@ -67,4 +67,18 @@ class TaskValidatorTest extends Base
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'swimlane_id' => 0)); $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'swimlane_id' => 0));
$this->assertFalse($result[0]); $this->assertFalse($result[0]);
} }
public function testStartAndDueDateFields()
{
$taskValidator = new TaskValidator($this->container);
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 9:50'));
$this->assertTrue($result[0]);
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 10:50'));
$this->assertTrue($result[0]);
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 11:50'));
$this->assertFalse($result[0]);
}
} }