mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Move AccompanyingPeriodType, remove custom definition.
This commit is contained in:
parent
92b6f4e206
commit
a9bdb1fe3b
@ -23,12 +23,6 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: closing_motive }
|
- { name: form.type, alias: closing_motive }
|
||||||
|
|
||||||
Chill\PersonBundle\Form\AccompanyingPeriodType:
|
|
||||||
arguments:
|
|
||||||
$config: "%chill_person.accompanying_period_fields%"
|
|
||||||
tags:
|
|
||||||
- { name: form.type }
|
|
||||||
|
|
||||||
chill.person.form.type.pick_person:
|
chill.person.form.type.pick_person:
|
||||||
class: Chill\PersonBundle\Form\Type\PickPersonType
|
class: Chill\PersonBundle\Form\Type\PickPersonType
|
||||||
arguments:
|
arguments:
|
||||||
|
@ -26,7 +26,7 @@ use Chill\PersonBundle\Privacy\PrivacyEvent;
|
|||||||
use Doctrine\DBAL\Exception;
|
use Doctrine\DBAL\Exception;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Form\AccompanyingPeriodType;
|
use Chill\PersonBundle\Form\Type\AccompanyingPeriodType;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Form;
|
namespace Chill\PersonBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
@ -14,12 +14,10 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|||||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Chill\PersonBundle\Form\Type\ClosingMotivePickerType;
|
use Chill\PersonBundle\Form\Type\ClosingMotivePickerType;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccompanyingPeriodType
|
* Class AccompanyingPeriodType
|
||||||
*
|
|
||||||
* @package Chill\PersonBundle\Form
|
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriodType extends AbstractType
|
class AccompanyingPeriodType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -33,15 +31,11 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
protected $config = [];
|
protected $config = [];
|
||||||
|
|
||||||
/**
|
public function __construct(ParameterBagInterface $parameterBag)
|
||||||
*
|
|
||||||
* @param string[] $config configuration of visibility of some fields
|
|
||||||
*/
|
|
||||||
public function __construct(array $config)
|
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $parameterBag->get('chill_person.accompanying_period_fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FormBuilderInterface $builder
|
* @param FormBuilderInterface $builder
|
||||||
* @param array $options
|
* @param array $options
|
||||||
@ -58,12 +52,12 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// closingDate should be seen only if
|
// closingDate should be seen only if
|
||||||
// period_action = close
|
// period_action = close
|
||||||
// OR ( period_action = update AND accompanying period is already closed )
|
// OR ( period_action = update AND accompanying period is already closed )
|
||||||
$accompanyingPeriod = $options['data'];
|
$accompanyingPeriod = $options['data'];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
($options['period_action'] === 'close')
|
($options['period_action'] === 'close')
|
||||||
OR
|
OR
|
||||||
@ -71,16 +65,16 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
OR
|
OR
|
||||||
($options['period_action'] === 'update' AND !$accompanyingPeriod->isOpen())
|
($options['period_action'] === 'update' AND !$accompanyingPeriod->isOpen())
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$builder->add('closingDate', DateType::class, [
|
$builder->add('closingDate', DateType::class, [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'format' => 'dd-MM-yyyy'
|
'format' => 'dd-MM-yyyy'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('closingMotive', ClosingMotivePickerType::class);
|
$builder->add('closingMotive', ClosingMotivePickerType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['user'] === 'visible') {
|
if ($this->config['user'] === 'visible') {
|
||||||
$builder->add('user', UserPickerType::class, [
|
$builder->add('user', UserPickerType::class, [
|
||||||
'center' => $options['center'],
|
'center' => $options['center'],
|
||||||
@ -110,7 +104,7 @@ class AccompanyingPeriodType extends AbstractType
|
|||||||
->setAllowedTypes('center', Center::class)
|
->setAllowedTypes('center', Center::class)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FormView $view
|
* @param FormView $view
|
||||||
* @param FormInterface $form
|
* @param FormInterface $form
|
Loading…
x
Reference in New Issue
Block a user