Add / Edit / Delete activity from Accompanying Course

This commit is contained in:
Jean-Francois Monfort
2021-05-20 15:56:34 +02:00
parent c59cf3f0df
commit 8fe00b4c2b
24 changed files with 795 additions and 433 deletions

View File

@@ -82,10 +82,13 @@ class ActivityType extends AbstractType
throw new \InvalidArgumentException('Activity type must be active');
}
$builder->add('scope', ScopePickerType::class, [
'center' => $options['center'],
'role' => $options['role']
]);
// TODO revoir la gestion des center au niveau du form des activité.
if ($options['center']) {
$builder->add('scope', ScopePickerType::class, [
'center' => $options['center'],
'role' => $options['role']
]);
}
if ($activityType->isVisible('date')) {
$builder->add('date', ChillDateType::class, [
@@ -108,7 +111,7 @@ class ActivityType extends AbstractType
$builder->add('travelTime', ChoiceType::class, $durationTimeOptions);
}
if ($activityType->isVisible('travelTime')) {
if ($activityType->isVisible('attendee')) {
$builder->add('attendee', EntityType::class, [
'label' => $activityType->getLabel('attendee'),
'required' => $activityType->isRequired('attendee'),
@@ -123,7 +126,7 @@ class ActivityType extends AbstractType
]);
}
if ($activityType->isVisible('user')) {
if ($activityType->isVisible('user') && $options['center']) {
$builder->add('user', UserPickerType::class, [
'label' => $activityType->getLabel('user'),
'required' => $activityType->isRequired('user'),
@@ -229,6 +232,10 @@ class ActivityType extends AbstractType
}
foreach (['durationTime', 'travelTime'] as $fieldName) {
if (!$activityType->isVisible($fieldName)) {
continue;
}
$builder->get($fieldName)
->addModelTransformer($durationTimeTransformer);
@@ -279,7 +286,7 @@ class ActivityType extends AbstractType
$resolver
->setRequired(['center', 'role', 'activityType'])
->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center')
->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center'])
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
;