From fc172fdb1f4dfca6b1cda5dc6c03411a89fa45b3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 13:40:25 +0200 Subject: [PATCH] Add documents to Activity Form --- .../ChillActivityBundle/Entity/Activity.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 13 +++++- .../Resources/views/Activity/edit.html.twig | 14 +++++-- .../Resources/views/Activity/new.html.twig | 15 +++++-- .../migrations/Version20210506112500.php | 42 +++++++++++++++++++ 5 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210506112500.php diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index cd00e503a..d66737ff6 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -119,7 +119,7 @@ class Activity implements HasCenterInterface, HasScopeInterface private Collection $thirdParties; /** - * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\Document") + * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject") */ private Collection $documents; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 05a3cac36..c4f918396 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -5,6 +5,8 @@ namespace Chill\ActivityBundle\Form; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityPresence; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\DocStoreBundle\Form\StoredObjectType; +use Chill\MainBundle\Form\Type\ChillCollectionType; use Chill\MainBundle\Form\Type\CommentType; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; @@ -12,6 +14,7 @@ use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -183,8 +186,14 @@ class ActivityType extends AbstractType ]); } - // TODO : documents - //$documents + if ($activityType->isVisible('documents')) { + $builder->add('documents', ChillCollectionType::class, [ + 'entry_type' => StoredObjectType::class, + 'label' => $activityType->getLabel('documents'), + 'required' => $activityType->isRequired('documents'), + 'allow_add' => true, + ]); + } if ($activityType->isVisible('users')) { $builder->add('users', EntityType::class, [ diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index e4db4d943..fb84ae725 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -63,6 +63,9 @@ {%- if form.sentReceived is defined -%} {{ form_row(form.sentReceived) }} {% endif %} + {%- if form.documents is defined -%} + {{ form_row(form.documents) }} + {% endif %} {{ form_widget(edit_form) }}