mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
Add a link between accompanying period and user
It is now allowed to indicates who make/made the accompanying period. This feature may be hidden by a specific configuration option. Default to visible.
This commit is contained in:
@@ -11,11 +11,33 @@ use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use Chill\PersonBundle\Form\Type\ClosingMotiveType;
|
||||
|
||||
class AccompanyingPeriodType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* array of configuration for accompanying_periods.
|
||||
*
|
||||
* Contains whether we should add fields some optional fields (optional per
|
||||
* instance)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $config = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string[] $config configuration of visibility of some fields
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
@@ -53,6 +75,13 @@ class AccompanyingPeriodType extends AbstractType
|
||||
$form->add('closingMotive', ClosingMotiveType::class);
|
||||
}
|
||||
});
|
||||
|
||||
if ($this->config['user'] === 'visible') {
|
||||
$builder->add('user', UserPickerType::class, [
|
||||
'center' => $options['center'],
|
||||
'role' => new Role(PersonVoter::SEE),
|
||||
]);
|
||||
}
|
||||
|
||||
$builder->add('remark', TextareaType::class, array(
|
||||
'required' => false
|
||||
@@ -71,9 +100,12 @@ class AccompanyingPeriodType extends AbstractType
|
||||
|
||||
$resolver
|
||||
->setRequired(array('period_action'))
|
||||
->addAllowedTypes('period_action','string')
|
||||
->addAllowedTypes('period_action', 'string')
|
||||
->addAllowedValues('period_action', array(
|
||||
'update', 'open', 'close', 'create'));
|
||||
'update', 'open', 'close', 'create'))
|
||||
->setRequired('center')
|
||||
->setAllowedTypes('center', \Chill\MainBundle\Entity\Center::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
|
Reference in New Issue
Block a user