mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
only add scope field conditionally in personDocumentType analogue to SingleTaskType
This commit is contained in:
parent
1c055e842e
commit
a28d8a7287
@ -18,6 +18,7 @@ use Chill\MainBundle\Form\Type\ChillDateType;
|
|||||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
@ -51,14 +52,22 @@ class PersonDocumentType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
private ScopeResolverDispatcher $scopeResolverDispatcher;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $translatableStringHelper
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
|
ScopeResolverDispatcher $scopeResolverDispatcher
|
||||||
) {
|
) {
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
if (null !== $document = $options['data']) {
|
||||||
|
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($document);
|
||||||
|
}
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('title', TextType::class)
|
->add('title', TextType::class)
|
||||||
->add('description', ChillTextareaType::class, [
|
->add('description', ChillTextareaType::class, [
|
||||||
@ -67,10 +76,6 @@ class PersonDocumentType extends AbstractType
|
|||||||
->add('object', StoredObjectType::class, [
|
->add('object', StoredObjectType::class, [
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
])
|
])
|
||||||
->add('scope', ScopePickerType::class, [
|
|
||||||
'center' => $options['center'],
|
|
||||||
'role' => $options['role'],
|
|
||||||
])
|
|
||||||
->add('date', ChillDateType::class)
|
->add('date', ChillDateType::class)
|
||||||
->add('category', EntityType::class, [
|
->add('category', EntityType::class, [
|
||||||
'placeholder' => 'Choose a document category',
|
'placeholder' => 'Choose a document category',
|
||||||
@ -84,6 +89,12 @@ class PersonDocumentType extends AbstractType
|
|||||||
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
|
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
|
||||||
|
$builder->add('scope', ScopePickerType::class, [
|
||||||
|
'center' => $options['center'],
|
||||||
|
'role' => $options['role'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
@ -16,8 +16,10 @@ services:
|
|||||||
|
|
||||||
Chill\DocStoreBundle\Form\PersonDocumentType:
|
Chill\DocStoreBundle\Form\PersonDocumentType:
|
||||||
class: Chill\DocStoreBundle\Form\PersonDocumentType
|
class: Chill\DocStoreBundle\Form\PersonDocumentType
|
||||||
arguments:
|
autowire: true
|
||||||
- "@chill.main.helper.translatable_string"
|
autoconfigure: true
|
||||||
|
# arguments:
|
||||||
|
# - "@chill.main.helper.translatable_string"
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: chill_docstorebundle_form_document }
|
- { name: form.type, alias: chill_docstorebundle_form_document }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user