mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add default status on rdv when creating a new rdv
This commit is contained in:
parent
4b8736ae57
commit
227be0b482
@ -158,6 +158,7 @@ class CalendarController extends AbstractController
|
||||
|
||||
$entity = new Calendar();
|
||||
$entity->setUser($this->getUser());
|
||||
$entity->setStatus($entity::STATUS_VALID);
|
||||
|
||||
// if ($user instanceof User) {
|
||||
// $entity->setPerson($user);
|
||||
@ -167,9 +168,6 @@ class CalendarController extends AbstractController
|
||||
$entity->setAccompanyingPeriod($accompanyingPeriod);
|
||||
}
|
||||
|
||||
// $entity->setType($activityType);
|
||||
// $entity->setDate(new \DateTime('now'));
|
||||
|
||||
$form = $this->createForm(CalendarType::class, $entity, [
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
@ -191,7 +189,6 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
|
||||
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||
dump($entity_array);
|
||||
|
||||
return $this->render($view, [
|
||||
'user' => $user,
|
||||
|
@ -23,6 +23,10 @@ use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
*/
|
||||
class Calendar
|
||||
{
|
||||
const STATUS_VALID = 'valid';
|
||||
const STATUS_CANCELED = 'canceled';
|
||||
const STATUS_MOVED = 'moved';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
|
@ -8,24 +8,33 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
|
||||
class CalendarType extends AbstractType
|
||||
{
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
protected TranslatableStringHelper $translatableStringHelper;
|
||||
protected ObjectManager $om;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
public function __construct(
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
ObjectManager $om
|
||||
)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->om = $om;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,12 +47,12 @@ class CalendarType extends AbstractType
|
||||
'required' => false
|
||||
))
|
||||
->add('startDate', DateType::class, array(
|
||||
'required' => false,
|
||||
'required' => true,
|
||||
'input' => 'datetime_immutable',
|
||||
'widget' => 'single_text'
|
||||
))
|
||||
->add('endDate', DateType::class, array(
|
||||
'required' => false,
|
||||
'required' => true,
|
||||
'input' => 'datetime_immutable',
|
||||
'widget' => 'single_text'
|
||||
))
|
||||
@ -102,8 +111,8 @@ class CalendarType extends AbstractType
|
||||
))
|
||||
;
|
||||
|
||||
// $builder->add('users', HiddenType::class);
|
||||
// $builder->get('users')
|
||||
// $builder->add('invites', HiddenType::class);
|
||||
// $builder->get('invites')
|
||||
// ->addModelTransformer(new CallbackTransformer(
|
||||
// function (iterable $usersAsIterable): string {
|
||||
// $userIds = [];
|
||||
@ -114,7 +123,7 @@ class CalendarType extends AbstractType
|
||||
// },
|
||||
// function (?string $usersAsString): array {
|
||||
// return array_map(
|
||||
// fn(string $id): ?User => $this->om->getRepository(User::class)->findOneBy(['id' => (int) $id]),
|
||||
// fn(string $id): ?Invite => $this->om->getRepository(Invite::class)->findOneBy(['id' => (int) $id]),
|
||||
// explode(',', $usersAsString)
|
||||
// );
|
||||
// }
|
||||
|
@ -4,6 +4,7 @@ services:
|
||||
class: Chill\CalendarBundle\Form\CalendarType
|
||||
arguments:
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@doctrine.orm.entity_manager"
|
||||
|
||||
tags:
|
||||
- { name: form.type, alias: chill_calendarbundle_calendar }
|
Loading…
x
Reference in New Issue
Block a user