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:
2019-07-01 15:21:34 +02:00
parent 5b60415166
commit 19cc54a674
13 changed files with 173 additions and 31 deletions

View File

@@ -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)