mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
rdv: add new rdv form
This commit is contained in:
parent
b01eba2533
commit
114df16e0f
@ -156,17 +156,6 @@ class CalendarController extends AbstractController
|
|||||||
// $view = 'ChillCalendarBundle:Calendar:newUser.html.twig';
|
// $view = 'ChillCalendarBundle:Calendar:newUser.html.twig';
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $activityType_id = $request->get('activityType_id', 0);
|
|
||||||
// $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
|
|
||||||
// ->find($activityType_id);
|
|
||||||
|
|
||||||
// if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType ||
|
|
||||||
// !$activityType->isActive()) {
|
|
||||||
|
|
||||||
// $params = $this->buildParamsToUrl($user, $accompanyingPeriod);
|
|
||||||
// return $this->redirectToRoute('chill_activity_activity_select_type', $params);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$entity = new Calendar();
|
$entity = new Calendar();
|
||||||
$entity->setUser($this->getUser());
|
$entity->setUser($this->getUser());
|
||||||
|
|
||||||
@ -181,28 +170,25 @@ class CalendarController extends AbstractController
|
|||||||
// $entity->setType($activityType);
|
// $entity->setType($activityType);
|
||||||
// $entity->setDate(new \DateTime('now'));
|
// $entity->setDate(new \DateTime('now'));
|
||||||
|
|
||||||
// $form = $this->createForm(ActivityType::class, $entity, [
|
$form = $this->createForm(CalendarType::class, $entity, [
|
||||||
// 'center' => $entity->getCenter(),
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
// 'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
])->handleRequest($request);
|
||||||
// 'activityType' => $entity->getType(),
|
|
||||||
// 'accompanyingPeriod' => $accompanyingPeriod,
|
|
||||||
// ])->handleRequest($request);
|
|
||||||
|
|
||||||
// if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// $em->persist($entity);
|
$em->persist($entity);
|
||||||
// $em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// $this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
|
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!'));
|
||||||
|
|
||||||
// $params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
$params = $this->buildParamsToUrl($user, $accompanyingPeriod); //TODO useful?
|
||||||
// $params['id'] = $entity->getId();
|
$params['id'] = $entity->getId();
|
||||||
|
|
||||||
// return $this->redirectToRoute('chill_activity_activity_show', $params);
|
return $this->redirectToRoute('chill_calendar_calendar_show', $params);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if ($view === null) {
|
if ($view === null) {
|
||||||
// throw $this->createNotFoundException('Template not found');
|
throw $this->createNotFoundException('Template not found');
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
// $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||||
|
|
||||||
@ -210,7 +196,7 @@ class CalendarController extends AbstractController
|
|||||||
'user' => $user,
|
'user' => $user,
|
||||||
'accompanyingCourse' => $accompanyingPeriod,
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
// 'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
//'activity_json' => $calendar_array
|
//'activity_json' => $calendar_array
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -456,20 +442,20 @@ class CalendarController extends AbstractController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// private function buildParamsToUrl(
|
private function buildParamsToUrl(
|
||||||
// ?Person $person,
|
?User $user,
|
||||||
// ?AccompanyingPeriod $accompanyingPeriod
|
?AccompanyingPeriod $accompanyingPeriod
|
||||||
// ): array {
|
): array {
|
||||||
// $params = [];
|
$params = [];
|
||||||
|
|
||||||
// if ($person) {
|
if ($user) {
|
||||||
// $params['person_id'] = $person->getId();
|
$params['user_id'] = $user->getId();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if ($accompanyingPeriod) {
|
if ($accompanyingPeriod) {
|
||||||
// $params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
$params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return $params;
|
return $params;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
|
|||||||
$loader->load('services.yml');
|
$loader->load('services.yml');
|
||||||
$loader->load('services/controller.yml');
|
$loader->load('services/controller.yml');
|
||||||
$loader->load('services/fixtures.yml');
|
$loader->load('services/fixtures.yml');
|
||||||
|
$loader->load('services/form.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
|
80
src/Bundle/ChillCalendarBundle/Form/CalendarType.php
Normal file
80
src/Bundle/ChillCalendarBundle/Form/CalendarType.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\CalendarBundle\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Form\Type\CommentType;
|
||||||
|
use Chill\CalendarBundle\Entity\Calendar;
|
||||||
|
use Chill\CalendarBundle\Entity\CancelReason;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
|
||||||
|
class CalendarType extends AbstractType
|
||||||
|
{
|
||||||
|
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('comment', CommentType::class, array(
|
||||||
|
'required' => false
|
||||||
|
))
|
||||||
|
->add('startDate', DateType::class, array(
|
||||||
|
'required' => false,
|
||||||
|
'input' => 'datetime_immutable',
|
||||||
|
'widget' => 'single_text'
|
||||||
|
))
|
||||||
|
->add('endDate', DateType::class, array(
|
||||||
|
'required' => false,
|
||||||
|
'input' => 'datetime_immutable',
|
||||||
|
'widget' => 'single_text'
|
||||||
|
))
|
||||||
|
->add('cancelReason', EntityType::class, array(
|
||||||
|
'required' => false,
|
||||||
|
'class' => CancelReason::class,
|
||||||
|
'choice_label' => function (CancelReason $entity) {
|
||||||
|
return $this->translatableStringHelper->localize($entity->getName());
|
||||||
|
},
|
||||||
|
))
|
||||||
|
;
|
||||||
|
|
||||||
|
}/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'data_class' => Calendar::class
|
||||||
|
));
|
||||||
|
|
||||||
|
$resolver
|
||||||
|
->setRequired(['accompanyingPeriod'])
|
||||||
|
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null'])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return 'chill_calendarbundle_calendar';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\CalendarBundle\Repository;
|
namespace Chill\CalendarBundle\Repository;
|
||||||
|
|
||||||
use CalendarBundle\Entity\CancelReason;
|
use Chill\CalendarBundle\Entity\CancelReason;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\CalendarBundle\Repository;
|
namespace Chill\CalendarBundle\Repository;
|
||||||
|
|
||||||
use CalendarBundle\Entity\Invite;
|
use Chill\CalendarBundle\Entity\Invite;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
chill.calendar.form.type.calendar:
|
||||||
|
class: Chill\CalendarBundle\Form\CalendarType
|
||||||
|
arguments:
|
||||||
|
- "@chill.main.helper.translatable_string"
|
||||||
|
|
||||||
|
tags:
|
||||||
|
- { name: form.type, alias: chill_calendarbundle_calendar }
|
@ -0,0 +1,80 @@
|
|||||||
|
<h1>{{ "Calendar item creation"|trans ~ ' :' }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
|
{%- if form.mainUser is defined -%}
|
||||||
|
{{ form_widget(form.mainUser) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.persons is defined -%}
|
||||||
|
{{ form_widget(form.persons) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.nonProfessionals is defined -%}
|
||||||
|
{{ form_widget(form.nonProfessionals) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.users is defined -%}
|
||||||
|
{{ form_widget(form.users) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="add-persons"></div>
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Calendar data'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.startDate is defined -%}
|
||||||
|
{{ form_row(form.startDate) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.endDate is defined -%}
|
||||||
|
{{ form_row(form.endDate) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
.. location
|
||||||
|
|
||||||
|
{%- if form.status is defined -%}
|
||||||
|
{{ form_row(form.status) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.cancelReason is defined -%}
|
||||||
|
{{ form_row(form.cancelReason) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.comment is defined -%}
|
||||||
|
{{ form_row(form.comment) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.activity is defined -%}
|
||||||
|
{{ form_row(form.activity) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.sendSMS is defined -%}
|
||||||
|
{{ form_row(form.sendSMS) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
..calendarRange
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a
|
||||||
|
class="btn btn-cancel"
|
||||||
|
{%- if context == 'person' -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}"
|
||||||
|
{%- else -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}"
|
||||||
|
{%- endif -%}
|
||||||
|
>
|
||||||
|
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-create" type="submit">
|
||||||
|
{{ 'Create'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{ form_end(form) }}
|
@ -25,13 +25,10 @@
|
|||||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
});
|
});
|
||||||
window.calendar = {{ calendar_json|json_encode|raw }};
|
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_calendar') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||||
{{ encore_entry_link_tags('vue_calendar') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user