condition added to display thirdparty centers or not

This commit is contained in:
Julie Lenaerts 2022-03-09 09:19:29 +01:00
parent 13d579dc33
commit b8d9d59d76
3 changed files with 32 additions and 27 deletions

View File

@ -34,6 +34,7 @@ and this project adheres to
* [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) * [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490)
* [person] Add link to current household in person banner (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/484) * [person] Add link to current household in person banner (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/484)
* [person] Change 'personne' with 'usager' and '&' with 'ET' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/499) * [person] Change 'personne' with 'usager' and '&' with 'ET' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/499)
* [thirdparty] Add parameter condition to display centers or not (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/500)
## Test releases ## Test releases

View File

@ -20,6 +20,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface; use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter; use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
use LogicException; use LogicException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
@ -31,37 +32,39 @@ use function array_merge;
final class ThirdPartyController extends CRUDController final class ThirdPartyController extends CRUDController
{ {
/** protected AuthorizationHelper $authorizationHelper;
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/** protected PaginatorFactory $paginatorFactory;
* @var PaginatorFactory
*/
protected $paginatorFactory;
protected RequestStack $requestStack; protected RequestStack $requestStack;
protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository; protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository;
/** protected TranslatorInterface $translator;
* @var TranslatorInterface
*/ private bool $askCenter;
protected $translator;
public function __construct( public function __construct(
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TranslatorInterface $translator, TranslatorInterface $translator,
PaginatorFactory $paginatorFactory, PaginatorFactory $paginatorFactory,
RequestStack $requestStack, RequestStack $requestStack,
ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository,
ParameterBagInterface $parameterBag
) { ) {
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->translator = $translator; $this->translator = $translator;
$this->paginatorFactory = $paginatorFactory; $this->paginatorFactory = $paginatorFactory;
$this->requestStack = $requestStack; $this->requestStack = $requestStack;
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository; $this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
$this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
}
public function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = [])
{
$defaultTemplateParameters['askCenter'] = $this->askCenter;
return $defaultTemplateParameters;
} }
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper

View File

@ -123,6 +123,7 @@
</dd> </dd>
{% endif %} {% endif %}
{% if askCenter %}
<dt>{{ 'Centers'|trans }}</dt> <dt>{{ 'Centers'|trans }}</dt>
<dd> <dd>
{% set centers = thirdParty|chill_resolve_center %} {% set centers = thirdParty|chill_resolve_center %}
@ -135,7 +136,7 @@
{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ centers }} {{ 'The party is visible in those centers'|trans }}&nbsp;: {{ centers }}
{% endif %} {% endif %}
</dd> </dd>
{% endif %}
</dl> </dl>
{% endblock %} {% endblock %}
{% block content_form_actions_delete %}{% endblock %} {% block content_form_actions_delete %}{% endblock %}