diff --git a/src/Bundle/ChillMainBundle/Form/NotificationType.php b/src/Bundle/ChillMainBundle/Form/NotificationType.php
index b54752cde..fa06007a2 100644
--- a/src/Bundle/ChillMainBundle/Form/NotificationType.php
+++ b/src/Bundle/ChillMainBundle/Form/NotificationType.php
@@ -14,6 +14,7 @@ namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillTextareaType;
+use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -24,11 +25,8 @@ class NotificationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('addressees', EntityType::class, [
- 'class' => User::class,
- 'choice_label' => 'label',
+ ->add('addressees', PickUserDynamicType::class, [
'multiple' => true,
- 'by_reference' => true,
])
->add('message', ChillTextareaType::class, [
'required' => false,
diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/UserToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/UserToJsonTransformer.php
new file mode 100644
index 000000000..497cbcdd9
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/UserToJsonTransformer.php
@@ -0,0 +1,70 @@
+denormalizer = $denormalizer;
+ $this->serializer = $serializer;
+ $this->multiple = $multiple;
+ }
+
+ /**
+ * @param User|User[] $value
+ */
+ public function transform($value): string
+ {
+ if (null === $value) {
+ return $this->multiple ? "null" : "[]";
+ }
+
+ return $this->serializer->serialize($value, 'json', [
+ AbstractNormalizer::GROUPS => ['read'],
+ ]);
+ }
+
+ public function reverseTransform($value)
+ {
+ if ($this->multiple) {
+ return \array_map(
+ function($item) { return $this->denormalizeOne($item);},
+ json_decode($value, true)
+ );
+ }
+
+ return $this->denormalizeOne(json_decode($value, true));
+ }
+
+ private function denormalizeOne(array $item): User
+ {
+ if (!array_key_exists('type', $item)) {
+ throw new TransformationFailedException('the key "type" is missing on element');
+ }
+ if (!array_key_exists('id', $item)) {
+ throw new TransformationFailedException('the key "id" is missing on element');
+ }
+
+ return
+ $this->denormalizer->denormalize(
+ ['type' => $item['type'], 'id' => $item['id']],
+ User::class,
+ 'json',
+ [AbstractNormalizer::GROUPS => ['read']],
+ );
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php
new file mode 100644
index 000000000..0ddff7b1e
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php
@@ -0,0 +1,59 @@
+denormalizer = $denormalizer;
+ $this->serializer = $serializer;
+ }
+
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder->addViewTransformer(new UserToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple']));
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver
+ ->setDefault('multiple', false)
+ ->setAllowedTypes('multiple', ['bool'])
+ ->setDefault('compound', false)
+ ;
+ }
+
+ public function buildView(FormView $view, FormInterface $form, array $options)
+ {
+ $view->vars['multiple'] = $options['multiple'];
+ $view->vars['types'] = ['user'];
+ $view->vars['uniqid'] = uniqid('pick_user_dyn');
+ }
+
+ public function getBlockPrefix()
+ {
+ return 'pick_user_dynamic';
+ }
+
+}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js
new file mode 100644
index 000000000..26cbff735
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js
@@ -0,0 +1,59 @@
+import {createApp} from 'vue';
+import PickEntity from 'ChillMainAssets/vuejs/PickEntity/PickEntity.vue';
+import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
+import {activityMessages} from "../../../../../ChillActivityBundle/Resources/public/vuejs/Activity/i18n";
+
+window.addEventListener('DOMContentLoaded', function(e) {
+ let
+ apps = document.querySelectorAll('[data-module="pick-dynamic"]');
+
+ apps.forEach(function(el) {
+ const
+ isMultiple = parseInt(el.dataset.multiple) === 1,
+ input = document.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'),
+ picked = isMultiple ? JSON.parse(input.value) : [JSON.parse(input.value)],
+ i18n = _createI18n({});
+
+ createApp({
+ template: '
+
+
+
+
+
+
+
+
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js
new file mode 100644
index 000000000..78a0a9c90
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js
@@ -0,0 +1,17 @@
+import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
+
+const messages = {
+ fr: {
+ pick_entity: {
+ add: 'Ajouter',
+ modal_title: 'Ajouter des',
+ user: 'Utilisateurs',
+ person: 'Usagers',
+ thirdparty: 'Tiers',
+ }
+ }
+}
+
+const full = Object.assign(messages, personMessages);
+
+export default full;
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
index 1426841bb..25f1363c3 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
@@ -215,3 +215,8 @@
{{ form_widget(form.center) }}
{% endif %}
{% endblock %}
+
+{% block pick_user_dynamic_widget %}
+
+