mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +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';
|
||||
// }
|
||||
|
||||
// $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->setUser($this->getUser());
|
||||
|
||||
@ -181,28 +170,25 @@ class CalendarController extends AbstractController
|
||||
// $entity->setType($activityType);
|
||||
// $entity->setDate(new \DateTime('now'));
|
||||
|
||||
// $form = $this->createForm(ActivityType::class, $entity, [
|
||||
// 'center' => $entity->getCenter(),
|
||||
// 'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||
// 'activityType' => $entity->getType(),
|
||||
// 'accompanyingPeriod' => $accompanyingPeriod,
|
||||
// ])->handleRequest($request);
|
||||
$form = $this->createForm(CalendarType::class, $entity, [
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
|
||||
// if ($form->isSubmitted() && $form->isValid()) {
|
||||
// $em->persist($entity);
|
||||
// $em->flush();
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em->persist($entity);
|
||||
$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['id'] = $entity->getId();
|
||||
$params = $this->buildParamsToUrl($user, $accompanyingPeriod); //TODO useful?
|
||||
$params['id'] = $entity->getId();
|
||||
|
||||
// return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||
// }
|
||||
return $this->redirectToRoute('chill_calendar_calendar_show', $params);
|
||||
}
|
||||
|
||||
// if ($view === null) {
|
||||
// throw $this->createNotFoundException('Template not found');
|
||||
// }
|
||||
if ($view === null) {
|
||||
throw $this->createNotFoundException('Template not found');
|
||||
}
|
||||
|
||||
// $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||
|
||||
@ -210,7 +196,7 @@ class CalendarController extends AbstractController
|
||||
'user' => $user,
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'entity' => $entity,
|
||||
// 'form' => $form->createView(),
|
||||
'form' => $form->createView(),
|
||||
//'activity_json' => $calendar_array
|
||||
]);
|
||||
}
|
||||
@ -456,20 +442,20 @@ class CalendarController extends AbstractController
|
||||
];
|
||||
}
|
||||
|
||||
// private function buildParamsToUrl(
|
||||
// ?Person $person,
|
||||
// ?AccompanyingPeriod $accompanyingPeriod
|
||||
// ): array {
|
||||
// $params = [];
|
||||
private function buildParamsToUrl(
|
||||
?User $user,
|
||||
?AccompanyingPeriod $accompanyingPeriod
|
||||
): array {
|
||||
$params = [];
|
||||
|
||||
// if ($person) {
|
||||
// $params['person_id'] = $person->getId();
|
||||
// }
|
||||
if ($user) {
|
||||
$params['user_id'] = $user->getId();
|
||||
}
|
||||
|
||||
// if ($accompanyingPeriod) {
|
||||
// $params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
||||
// }
|
||||
if ($accompanyingPeriod) {
|
||||
$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/controller.yml');
|
||||
$loader->load('services/fixtures.yml');
|
||||
$loader->load('services/form.yml');
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
use CalendarBundle\Entity\CancelReason;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Chill\CalendarBundle\Repository;
|
||||
|
||||
use CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
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 }}"]',
|
||||
'{{ "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>
|
||||
{{ encore_entry_script_tags('vue_calendar') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||
{{ encore_entry_link_tags('vue_calendar') }}
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user