mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			453-bug-cs
			...
			issue386_d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a47fc3dbb7 | |||
| fc28ada811 | |||
| e121c241c6 | |||
| 9e2208f29c | |||
| c3c80abed1 | |||
| 92788ccdc0 | |||
| 84993ca05b | |||
| 972657b38e | |||
| b26d0905a3 | 
@@ -40,6 +40,7 @@ and this project adheres to
 | 
			
		||||
* [main] location form type: fix unmapped address field (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/246)
 | 
			
		||||
* [activity] fix wrong import of js assets for adding and viewing documents in activity (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/83 & https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/176)
 | 
			
		||||
* [person]: space added between deathdate and age in twig renderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/380)
 | 
			
		||||
* [forms] dynamic picker types for user/person/thirdparty types created (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/386)
 | 
			
		||||
 | 
			
		||||
### test release 2022-01-17
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
 | 
			
		||||
use Symfony\Component\Serializer\SerializerInterface;
 | 
			
		||||
use function array_key_exists;
 | 
			
		||||
 | 
			
		||||
class UserToJsonTransformer implements DataTransformerInterface
 | 
			
		||||
class EntityToJsonTransformer implements DataTransformerInterface
 | 
			
		||||
{
 | 
			
		||||
    private DenormalizerInterface $denormalizer;
 | 
			
		||||
 | 
			
		||||
@@ -27,11 +27,14 @@ class UserToJsonTransformer implements DataTransformerInterface
 | 
			
		||||
 | 
			
		||||
    private SerializerInterface $serializer;
 | 
			
		||||
 | 
			
		||||
    public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple)
 | 
			
		||||
    private string $type;
 | 
			
		||||
 | 
			
		||||
    public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple, string $type)
 | 
			
		||||
    {
 | 
			
		||||
        $this->denormalizer = $denormalizer;
 | 
			
		||||
        $this->serializer = $serializer;
 | 
			
		||||
        $this->multiple = $multiple;
 | 
			
		||||
        $this->type = $type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function reverseTransform($value)
 | 
			
		||||
@@ -79,7 +82,7 @@ class UserToJsonTransformer implements DataTransformerInterface
 | 
			
		||||
        return
 | 
			
		||||
            $this->denormalizer->denormalize(
 | 
			
		||||
                ['type' => $item['type'], 'id' => $item['id']],
 | 
			
		||||
                User::class,
 | 
			
		||||
                $this->type,
 | 
			
		||||
                'json',
 | 
			
		||||
                [AbstractNormalizer::GROUPS => ['read']],
 | 
			
		||||
            );
 | 
			
		||||
@@ -12,7 +12,7 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\MainBundle\Form\Type;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Form\Type\DataTransformer\UserToJsonTransformer;
 | 
			
		||||
use Chill\MainBundle\Form\Type\DataTransformer\EntityToJsonTransformer;
 | 
			
		||||
use Symfony\Component\Form\AbstractType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Form\FormInterface;
 | 
			
		||||
@@ -38,7 +38,7 @@ class PickUserDynamicType extends AbstractType
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $builder->addViewTransformer(new UserToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple']));
 | 
			
		||||
        $builder->addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'user'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildView(FormView $view, FormInterface $form, array $options)
 | 
			
		||||
@@ -58,6 +58,6 @@ class PickUserDynamicType extends AbstractType
 | 
			
		||||
 | 
			
		||||
    public function getBlockPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        return 'pick_user_dynamic';
 | 
			
		||||
        return 'pick_entity_dynamic';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -216,7 +216,7 @@
 | 
			
		||||
    {% endif %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block pick_user_dynamic_widget %}
 | 
			
		||||
{% block pick_entity_dynamic_widget %}
 | 
			
		||||
    <input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
 | 
			
		||||
    <div data-module="pick-dynamic" data-types="{{ form.vars['types']|json_encode }}" data-multiple="{{ form.vars['multiple'] }}" data-uniqid="{{ form.vars['uniqid'] }}"></div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Chill is a software for social workers
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view
 | 
			
		||||
 * the LICENSE file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\PersonBundle\Form\Type;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Form\Type\DataTransformer\EntityToJsonTransformer;
 | 
			
		||||
use Symfony\Component\Form\AbstractType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Form\FormInterface;
 | 
			
		||||
use Symfony\Component\Form\FormView;
 | 
			
		||||
use Symfony\Component\OptionsResolver\OptionsResolver;
 | 
			
		||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
 | 
			
		||||
use Symfony\Component\Serializer\SerializerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pick user dymically, using vuejs module "AddPerson".
 | 
			
		||||
 */
 | 
			
		||||
class PickPersonDynamicType extends AbstractType
 | 
			
		||||
{
 | 
			
		||||
    private DenormalizerInterface $denormalizer;
 | 
			
		||||
 | 
			
		||||
    private SerializerInterface $serializer;
 | 
			
		||||
 | 
			
		||||
    public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer)
 | 
			
		||||
    {
 | 
			
		||||
        $this->denormalizer = $denormalizer;
 | 
			
		||||
        $this->serializer = $serializer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $builder->addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'person'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildView(FormView $view, FormInterface $form, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $view->vars['multiple'] = $options['multiple'];
 | 
			
		||||
        $view->vars['types'] = ['person'];
 | 
			
		||||
        $view->vars['uniqid'] = uniqid('pick_user_dyn');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function configureOptions(OptionsResolver $resolver)
 | 
			
		||||
    {
 | 
			
		||||
        $resolver
 | 
			
		||||
            ->setDefault('multiple', false)
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool'])
 | 
			
		||||
            ->setDefault('compound', false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getBlockPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        return 'pick_entity_dynamic';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Chill is a software for social workers
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view
 | 
			
		||||
 * the LICENSE file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\ThirdPartyBundle\Form\Type;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Form\Type\DataTransformer\EntityToJsonTransformer;
 | 
			
		||||
use Symfony\Component\Form\AbstractType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Form\FormInterface;
 | 
			
		||||
use Symfony\Component\Form\FormView;
 | 
			
		||||
use Symfony\Component\OptionsResolver\OptionsResolver;
 | 
			
		||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
 | 
			
		||||
use Symfony\Component\Serializer\SerializerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pick user dymically, using vuejs module "AddPerson".
 | 
			
		||||
 */
 | 
			
		||||
class PickThirdpartyDynamicType extends AbstractType
 | 
			
		||||
{
 | 
			
		||||
    private DenormalizerInterface $denormalizer;
 | 
			
		||||
 | 
			
		||||
    private SerializerInterface $serializer;
 | 
			
		||||
 | 
			
		||||
    public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer)
 | 
			
		||||
    {
 | 
			
		||||
        $this->denormalizer = $denormalizer;
 | 
			
		||||
        $this->serializer = $serializer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $builder->addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'thirdparty'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildView(FormView $view, FormInterface $form, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $view->vars['multiple'] = $options['multiple'];
 | 
			
		||||
        $view->vars['types'] = ['thirdparty'];
 | 
			
		||||
        $view->vars['uniqid'] = uniqid('pick_user_dyn');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function configureOptions(OptionsResolver $resolver)
 | 
			
		||||
    {
 | 
			
		||||
        $resolver
 | 
			
		||||
            ->setDefault('multiple', false)
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool'])
 | 
			
		||||
            ->setDefault('compound', false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getBlockPrefix()
 | 
			
		||||
    {
 | 
			
		||||
        return 'pick_entity_dynamic';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user