diff --git a/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php b/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php index 75edbcbdf..753ca9cd5 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php +++ b/src/Bundle/ChillDocGeneratorBundle/Entity/DocGeneratorTemplate.php @@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; +use Chill\DocStoreBundle\Entity\StoredObject; /** * @ORM\Entity @@ -46,9 +47,9 @@ class DocGeneratorTemplate private array $entities = []; /** - * @ORM\Column(type="string", length=255) + * @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}).) */ - private string $file; + private ?StoredObject $file = null; /** * @ORM\Id @@ -57,6 +58,7 @@ class DocGeneratorTemplate * @Serializer\Groups({"read"}) */ private int $id; + /** * @ORM\Column(type="json") @@ -79,7 +81,7 @@ class DocGeneratorTemplate return $this->entities; } - public function getFile(): ?string + public function getFile(): ?StoredObject { return $this->file; } @@ -89,10 +91,11 @@ class DocGeneratorTemplate return $this->id; } - public function getName(): ?array + public function getName(): ?array { return $this->name; } + public function setContext(string $context): self { @@ -115,7 +118,7 @@ class DocGeneratorTemplate return $this; } - public function setFile(string $file): self + public function setFile(StoredObject $file): self { $this->file = $file; diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index 75d33d0e5..3da397be9 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -14,8 +14,10 @@ namespace Chill\DocGeneratorBundle\Form; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\DocStoreBundle\Form\StoredObjectType; class DocGeneratorTemplateType extends AbstractType { @@ -25,8 +27,18 @@ class DocGeneratorTemplateType extends AbstractType ->add('name', TranslatableStringFormType::class, [ 'label' => 'Nom', ]) + ->add('context') + ->add('entities', ChoiceType::class, [ + 'multiple' => true, + 'choices' => [ + 'AccompanyingPeriod' => 'Chill\PersonBundle\Entity\AccompanyingPeriod', + 'SocialWork\SocialAction' => 'Chill\PersonBundle\Entity\SocialWork\SocialAction' + ]]) ->add('description') - ->add('file'); + ->add('file', StoredObjectType::class, [ + 'error_bubbling' => true + ]) + ; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/edit.html.twig b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/edit.html.twig index 040dea1c0..81af0037d 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/edit.html.twig +++ b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/edit.html.twig @@ -10,3 +10,12 @@ {% block content_form_actions_save_and_show %}{% endblock %} {% endembed %} {% endblock %} + +{% block js %} + {{ parent() }} + {{ encore_entry_script_tags('mod_async_upload') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_async_upload') }} +{% endblock %} diff --git a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig index c601b8836..2cedff190 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig +++ b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Admin/DocGeneratorTemplate/index.html.twig @@ -5,7 +5,7 @@ {% block table_entities_thead_tr %}