mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-22 22:55:00 +00:00
Compare commits
4 Commits
signature-
...
fix/person
Author | SHA1 | Date | |
---|---|---|---|
eb3e333ff7 | |||
505f2d2ad5 | |||
57d92ad7f2 | |||
6a46e99bb0 |
@@ -23,6 +23,8 @@ and this project adheres to
|
|||||||
* improve graph refresh mechanism
|
* improve graph refresh mechanism
|
||||||
* add feature to export canvas as image (png)
|
* add feature to export canvas as image (png)
|
||||||
* [person suggest] In widget "add person", improve the pertinence of persons when one of the names starts with the pattern;
|
* [person suggest] In widget "add person", improve the pertinence of persons when one of the names starts with the pattern;
|
||||||
|
* [person] do not ask for center any more on person creation
|
||||||
|
* [3party] do not ask for center any more on 3party creation
|
||||||
|
|
||||||
|
|
||||||
## Test releases
|
## Test releases
|
||||||
|
@@ -104,6 +104,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->booleanNode('form_show_scopes')
|
->booleanNode('form_show_scopes')
|
||||||
->defaultTrue()
|
->defaultTrue()
|
||||||
->end()
|
->end()
|
||||||
|
->booleanNode('form_show_centers')
|
||||||
|
->defaultTrue()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('redis')
|
->arrayNode('redis')
|
||||||
|
@@ -10,30 +10,32 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if form.checkboxes|length > 0 %}
|
{% if form.checkboxes is defined %}
|
||||||
{% for checkbox_name, options in form.checkboxes %}
|
{% if form.checkboxes|length > 0 %}
|
||||||
<div class="row gx-0">
|
{% for checkbox_name, options in form.checkboxes %}
|
||||||
<div class="col-md-12">
|
|
||||||
{% for c in form['checkboxes'][checkbox_name].children %}
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
{{ form_widget(c) }}
|
|
||||||
{{ form_label(c) }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if loop.last %}
|
|
||||||
<div class="row gx-0">
|
<div class="row gx-0">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<ul class="record_actions">
|
{% for c in form['checkboxes'][checkbox_name].children %}
|
||||||
<li>
|
<div class="form-check form-check-inline">
|
||||||
<button type="submit" class="btn btn-misc"><i class="fa fa-filter"></i></button>
|
{{ form_widget(c) }}
|
||||||
</li>
|
{{ form_label(c) }}
|
||||||
</ul>
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% if loop.last %}
|
||||||
{% endfor %}
|
<div class="row gx-0">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="btn btn-misc"><i class="fa fa-filter"></i></button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
|
@@ -1182,9 +1182,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @param string $phonenumber
|
* @param string $phonenumber
|
||||||
* @return Person
|
* @return Person
|
||||||
*/
|
*/
|
||||||
public function setPhonenumber($phonenumber = '')
|
public function setPhonenumber(?string $phonenumber = '')
|
||||||
{
|
{
|
||||||
$this->phonenumber = $phonenumber;
|
$this->phonenumber = (string) $phonenumber;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -1205,9 +1205,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @param string $mobilenumber
|
* @param string $mobilenumber
|
||||||
* @return Person
|
* @return Person
|
||||||
*/
|
*/
|
||||||
public function setMobilenumber($mobilenumber = '')
|
public function setMobilenumber(?string $mobilenumber = '')
|
||||||
{
|
{
|
||||||
$this->mobilenumber = $mobilenumber;
|
$this->mobilenumber = (string) $mobilenumber;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ use Chill\MainBundle\Form\Event\CustomizeFormEvent;
|
|||||||
use Chill\MainBundle\Repository\CenterRepository;
|
use Chill\MainBundle\Repository\CenterRepository;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -54,14 +55,18 @@ final class CreationPersonType extends AbstractType
|
|||||||
|
|
||||||
private EventDispatcherInterface $dispatcher;
|
private EventDispatcherInterface $dispatcher;
|
||||||
|
|
||||||
|
private bool $askCenters;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CenterRepository $centerRepository,
|
CenterRepository $centerRepository,
|
||||||
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
|
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
|
||||||
EventDispatcherInterface $dispatcher
|
EventDispatcherInterface $dispatcher,
|
||||||
|
ParameterBagInterface $parameterBag
|
||||||
) {
|
) {
|
||||||
$this->centerTransformer = $centerRepository;
|
$this->centerTransformer = $centerRepository;
|
||||||
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
|
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
|
$this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,12 +83,15 @@ final class CreationPersonType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('gender', GenderType::class, array(
|
->add('gender', GenderType::class, array(
|
||||||
'required' => true, 'placeholder' => null
|
'required' => true, 'placeholder' => null
|
||||||
))
|
));
|
||||||
->add('center', PickCenterType::class, [
|
|
||||||
'required' => false,
|
if ($this->askCenters) {
|
||||||
'role' => PersonVoter::CREATE,
|
$builder
|
||||||
])
|
->add('center', PickCenterType::class, [
|
||||||
;
|
'required' => false,
|
||||||
|
'role' => PersonVoter::CREATE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->configPersonAltNamesHelper->hasAltNames()) {
|
if ($this->configPersonAltNamesHelper->hasAltNames()) {
|
||||||
$builder->add('altNames', PersonAltNameType::class, [
|
$builder->add('altNames', PersonAltNameType::class, [
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Validator\Constraints\Person;
|
namespace Chill\PersonBundle\Validator\Constraints\Person;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
@@ -10,10 +11,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
|||||||
class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintValidator
|
class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintValidator
|
||||||
{
|
{
|
||||||
private bool $centerRequired;
|
private bool $centerRequired;
|
||||||
|
private CenterResolverDispatcher $centerResolverDispatcher;
|
||||||
|
|
||||||
public function __construct(ParameterBagInterface $parameterBag)
|
public function __construct(ParameterBagInterface $parameterBag, CenterResolverDispatcher $centerResolverDispatcher)
|
||||||
{
|
{
|
||||||
$this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required'];
|
$this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required'];
|
||||||
|
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +32,7 @@ class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintVa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL === $person->getCenter()) {
|
if (NULL === $this->centerResolverDispatcher->resolveCenter($person)) {
|
||||||
$this
|
$this
|
||||||
->context
|
->context
|
||||||
->buildViolation($constraint->message)
|
->buildViolation($constraint->message)
|
||||||
|
@@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManager;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
@@ -46,18 +47,22 @@ class ThirdPartyType extends AbstractType
|
|||||||
|
|
||||||
protected EntityManagerInterface $om;
|
protected EntityManagerInterface $om;
|
||||||
|
|
||||||
|
private bool $askCenter;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
TokenStorageInterface $tokenStorage,
|
TokenStorageInterface $tokenStorage,
|
||||||
ThirdPartyTypeManager $typesManager,
|
ThirdPartyTypeManager $typesManager,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
EntityManagerInterface $om
|
EntityManagerInterface $om,
|
||||||
|
ParameterBagInterface $parameterBag
|
||||||
) {
|
) {
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
$this->typesManager = $typesManager;
|
$this->typesManager = $typesManager;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->om = $om;
|
$this->om = $om;
|
||||||
|
$this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,16 +83,19 @@ class ThirdPartyType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('comment', ChillTextareaType::class, [
|
->add('comment', ChillTextareaType::class, [
|
||||||
'required' => false
|
'required' => false
|
||||||
])
|
]);
|
||||||
->add('centers', PickCenterType::class, [
|
|
||||||
'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
|
if ($this->askCenter) {
|
||||||
ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
|
$builder
|
||||||
'choice_options' => [
|
->add('centers', PickCenterType::class, [
|
||||||
'multiple' => true,
|
'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
|
||||||
'attr' => ['class' => 'select2']
|
ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
|
||||||
]
|
'choice_options' => [
|
||||||
])
|
'multiple' => true,
|
||||||
;
|
'attr' => ['class' => 'select2']
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Contact Person ThirdParty (child)
|
// Contact Person ThirdParty (child)
|
||||||
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
||||||
|
@@ -30,38 +30,10 @@
|
|||||||
|
|
||||||
{{ form_row(form.address) }}
|
{{ form_row(form.address) }}
|
||||||
|
|
||||||
{#
|
|
||||||
<div class="mb-3 row">
|
|
||||||
{{ form_label(form.address) }}
|
|
||||||
{{ form_widget(form.address) }}
|
|
||||||
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{% if thirdParty.address %}
|
|
||||||
{# include vue_address component #
|
|
||||||
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
|
|
||||||
targetEntity: { name: 'thirdparty', id: thirdParty.id },
|
|
||||||
mode: 'edit',
|
|
||||||
addressId: thirdParty.address.id,
|
|
||||||
buttonSize: 'btn-sm',
|
|
||||||
} %}
|
|
||||||
{#
|
|
||||||
backUrl: path('chill_3party_3party_new'),
|
|
||||||
#
|
|
||||||
{% else %}
|
|
||||||
{# include vue_address component #
|
|
||||||
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
|
|
||||||
targetEntity: { name: 'thirdparty', id: thirdParty.id },
|
|
||||||
mode: 'new',
|
|
||||||
buttonSize: 'btn-sm',
|
|
||||||
buttonText: 'Create a new address',
|
|
||||||
modalTitle: 'Create a new address',
|
|
||||||
} %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
#}
|
|
||||||
|
|
||||||
{{ form_row(form.comment) }}
|
{{ form_row(form.comment) }}
|
||||||
|
|
||||||
|
{% if form.centers is defined %}
|
||||||
{{ form_row(form.centers) }}
|
{{ form_row(form.centers) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_row(form.active) }}
|
{{ form_row(form.active) }}
|
||||||
|
Reference in New Issue
Block a user