mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 17:28:23 +00:00 
			
		
		
		
	remove glitch from filter when no task states in database
This commit is contained in:
		| @@ -306,7 +306,7 @@ final class SingleTaskController extends AbstractController | ||||
|  | ||||
|         $flags = array_merge( | ||||
|             $filterOrder->getCheckboxData('status'), | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->hasCheckboxData('states') ? $filterOrder->getCheckboxData('states') : []) | ||||
|         ); | ||||
|         $nb = $this->singleTaskAclAwareRepository->countByAllViewable( | ||||
|             $filterOrder->getQueryString(), | ||||
| @@ -353,7 +353,7 @@ final class SingleTaskController extends AbstractController | ||||
|         $filterOrder = $this->buildFilterOrder(); | ||||
|         $flags = array_merge( | ||||
|             $filterOrder->getCheckboxData('status'), | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->hasCheckboxData('states') ? $filterOrder->getCheckboxData('states') : []) | ||||
|         ); | ||||
|         $nb = $this->singleTaskAclAwareRepository->countByCourse( | ||||
|             $course, | ||||
| @@ -402,7 +402,7 @@ final class SingleTaskController extends AbstractController | ||||
|         $filterOrder = $this->buildFilterOrder(); | ||||
|         $flags = array_merge( | ||||
|             $filterOrder->getCheckboxData('status'), | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->hasCheckboxData('states') ? $filterOrder->getCheckboxData('states') : []) | ||||
|         ); | ||||
|         $nb = $this->singleTaskAclAwareRepository->countByPerson( | ||||
|             $person, | ||||
| @@ -457,7 +457,7 @@ final class SingleTaskController extends AbstractController | ||||
|         $filterOrder = $this->buildFilterOrder(false); | ||||
|         $flags = array_merge( | ||||
|             $filterOrder->getCheckboxData('status'), | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) | ||||
|             array_map(static fn ($i) => 'state_' . $i, $filterOrder->hasCheckboxData('states') ? $filterOrder->getCheckboxData('states') : []) | ||||
|         ); | ||||
|         $nb = $this->singleTaskAclAwareRepository->countByCurrentUsersTasks( | ||||
|             $filterOrder->getQueryString(), | ||||
| @@ -677,15 +677,19 @@ final class SingleTaskController extends AbstractController | ||||
|             'Tasks near deadline', | ||||
|             'Tasks over deadline', | ||||
|         ]; | ||||
|         $states = $this->singleTaskStateRepository->findAllExistingStates(); | ||||
|         $checked = array_values(array_filter($states, fn (string $state) => !in_array($state, ['closed', 'canceled', 'validated'], true))); | ||||
|  | ||||
|         $filterBuilder = $this->filterOrderHelperFactory | ||||
|             ->create(self::class) | ||||
|             ->addSearchBox() | ||||
|             ->addCheckbox('status', $statuses, $statuses, $statusTrans) | ||||
|             ->addCheckbox('states', $states, $checked) | ||||
|         ; | ||||
|             ->addCheckbox('status', $statuses, $statuses, $statusTrans); | ||||
|  | ||||
|         $states = $this->singleTaskStateRepository->findAllExistingStates(); | ||||
|         $checked = array_values(array_filter($states, fn (string $state) => !in_array($state, ['closed', 'canceled', 'validated'], true))); | ||||
|  | ||||
|         if ([] !== $states) { | ||||
|             $filterBuilder | ||||
|                 ->addCheckbox('states', $states, $checked); | ||||
|         } | ||||
|  | ||||
|         if ($includeFilterByUser) { | ||||
|             $filterBuilder | ||||
|   | ||||
		Reference in New Issue
	
	Block a user