add closed tasks

- the entity has a new column / property "closed" (boolean)
- An event listener in created during container compilation, which listen on tasks
  status changed
- The taskworkflow manager and task workflow definition indicate if the tasks is closed ;
- Add list for closed tasks in controller, and change parameter 'date_status' to 'status';
- and change query to allow to filter on closed tasks
This commit is contained in:
2018-04-26 12:11:06 +02:00
parent d251074430
commit eadaeaef35
9 changed files with 131 additions and 31 deletions

View File

@@ -69,6 +69,8 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
* - `person` : filter by person associated with the task ;
* - `date_status`: type of task. To choose between :
* `ended`, `warning`, `current`, `not_started`
* - `is_closed`: boolean. Indicate if the tasks must be closed (true) or
* opened
*
* @param type $params
* @param User $currentUser
@@ -90,14 +92,18 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
{
$this->buildACLQuery($qb, $currentUser);
if (\array_key_exists('person', $params)) {
if (\array_key_exists('person', $params) and !empty($params['person'])) {
$qb->andWhere($qb->expr()->eq('st.person', ':person'));
$qb->setParameter('person', $params['person']);
}
if (\array_key_exists('date_status', $params)) {
if (\array_key_exists('date_status', $params) and !empty($params['date_status'])) {
$this->addTypeFilter($qb, $params);
}
if (\array_key_exists('is_closed', $params)) {
$qb->andWhere($this->buildIsClosed($qb, !$params['is_closed']));
}
}
protected function addTypeFilter(QueryBuilder $qb, $params)
@@ -106,7 +112,9 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
switch ($params['date_status']) {
case self::DATE_STATUS_ENDED:
$andWhere->add($this->buildNowIsAfterEndDate($qb));
$andWhere
->add($this->buildNowIsAfterEndDate($qb))
;
break;
case self::DATE_STATUS_WARNING:
@@ -155,7 +163,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
}
}
private function buildNowIsAfterWarningDate(QueryBuilder $qb, $negative = false)
private function buildNowIsAfterWarningDate(QueryBuilder $qb, bool $negative = false)
{
if ($negative === false) {
return $qb->expr()->andX()
@@ -181,7 +189,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
}
}
private function buildNowIsAfterStartDate(QueryBuilder $qb, $negative = false)
private function buildNowIsAfterStartDate(QueryBuilder $qb, bool $negative = false)
{
if ($negative === false) {
return $qb->expr()->orX()
@@ -197,6 +205,15 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
}
}
private function buildIsClosed(QueryBuilder $qb, bool $negative = false)
{
if ($negative === false) {
return $qb->expr()->eq('st.closed', "'TRUE'");
} else {
return $qb->expr()->eq('st.closed', "'FALSE'");
}
}
protected function buildACLQuery(QueryBuilder $qb, User $currentUser)
{