diff --git a/changelog.md b/changelog.md index 6c65245..48ee832 100644 --- a/changelog.md +++ b/changelog.md @@ -78,6 +78,7 @@ #### Improve - Page layout - Show only active followed task on home page +- When adding a task to an activity, the actor is set by default with the activity one #### Fix - Card diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php index 8a6d97d..752739f 100644 --- a/src/Controller/ActivityController.php +++ b/src/Controller/ActivityController.php @@ -120,7 +120,7 @@ { // Get repositories $entityManager = $this->getDoctrine()->getManager(); - /** @var ActivityRepository $actorRepository */ + /** @var ActivityRepository $activityRepository */ $activityRepository = $entityManager->getRepository(ActivityEntity::class); /** @var ActorRepository $actorRepository */ $actorRepository = $entityManager->getRepository(ActorEntity::class); @@ -189,6 +189,7 @@ /** @var TaskAddForm $taskAddForm */ $taskAddForm = $this->createNamedCustomForm('taskAdd', TaskAddForm::class, [ 'actors' => $actors, + 'actor' => $activity->getActor(), ]); $taskAddForm->handleRequest($request); if ($taskAddForm->isSubmitted() && $taskAddForm->isValid()) { diff --git a/src/Form/Task/TaskAddForm.php b/src/Form/Task/TaskAddForm.php index 64d5bd0..f29327a 100644 --- a/src/Form/Task/TaskAddForm.php +++ b/src/Form/Task/TaskAddForm.php @@ -25,6 +25,11 @@ { $this->actors = $data['actors']; parent::__construct($formBuilder, $data, $usesToken); + if (isset($data['actor'])) { + $this->form->setData([ + 'actor' => $data['actor'] + ]); + } } /** diff --git a/src/Repository/ActivityRepository.php b/src/Repository/ActivityRepository.php index 4abdc95..c6147b5 100644 --- a/src/Repository/ActivityRepository.php +++ b/src/Repository/ActivityRepository.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Query\Expr\Join; +use App\Entity\ActivityEntity; /** * Repository for workspaces @@ -23,6 +24,14 @@ /** * {@inheritdoc} */ + public function find($id, $lockMode = null, $lockVersion = null): ?ActivityEntity + { + return parent::find($id, $lockMode, $lockVersion); + } + + /** + * {@inheritdoc} + */ public function findBy(array $criteria, ?array $orderBy = self::DEFAULT_ORDER, $limit = null, $offset = null) { return parent::findBy($criteria, $orderBy, $limit, $offset);