mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'calendar/finalization' into testing
This commit is contained in:
commit
feb760a97b
@ -22,6 +22,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
@ -65,6 +66,8 @@ class CalendarController extends AbstractController
|
||||
|
||||
private SerializerInterface $serializer;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private UserRepositoryInterface $userRepository;
|
||||
|
||||
public function __construct(
|
||||
@ -75,6 +78,7 @@ class CalendarController extends AbstractController
|
||||
PaginatorFactory $paginator,
|
||||
RemoteCalendarConnectorInterface $remoteCalendarConnector,
|
||||
SerializerInterface $serializer,
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
PersonRepository $personRepository,
|
||||
AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
UserRepositoryInterface $userRepository
|
||||
@ -86,6 +90,7 @@ class CalendarController extends AbstractController
|
||||
$this->paginator = $paginator;
|
||||
$this->remoteCalendarConnector = $remoteCalendarConnector;
|
||||
$this->serializer = $serializer;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->personRepository = $personRepository;
|
||||
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
|
||||
$this->userRepository = $userRepository;
|
||||
@ -171,8 +176,13 @@ class CalendarController extends AbstractController
|
||||
$form = $this->createForm(CalendarType::class, $entity)
|
||||
->add('save', SubmitType::class);
|
||||
|
||||
if (0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) {
|
||||
$form->add('save_and_create_doc', SubmitType::class);
|
||||
$form->add('save_and_upload_doc', SubmitType::class);
|
||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
|
||||
$form->handleRequest($request);
|
||||
@ -182,8 +192,18 @@ class CalendarController extends AbstractController
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!'));
|
||||
|
||||
if ($form->has('save_and_create_doc') && $form->get('save_and_create_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]);
|
||||
if ($form->get('save_and_upload_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
'template' => $template->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return new RedirectResponse($redirectRoute);
|
||||
@ -201,6 +221,7 @@ class CalendarController extends AbstractController
|
||||
'accompanyingCourse' => $entity->getAccompanyingPeriod(),
|
||||
'person' => $entity->getPerson(),
|
||||
'entity_json' => $entity_array,
|
||||
'templates' => $templates,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -333,8 +354,13 @@ class CalendarController extends AbstractController
|
||||
$form = $this->createForm(CalendarType::class, $entity)
|
||||
->add('save', SubmitType::class);
|
||||
|
||||
if (0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) {
|
||||
$form->add('save_and_create_doc', SubmitType::class);
|
||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
||||
$form->add('save_and_upload_doc', SubmitType::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
|
||||
$form->handleRequest($request);
|
||||
@ -345,8 +371,18 @@ class CalendarController extends AbstractController
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!'));
|
||||
|
||||
if ($form->has('save_and_create_doc') && $form->get('save_and_create_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]);
|
||||
if ($form->get('save_and_upload_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
'template' => $template->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ('' !== $redirectRoute) {
|
||||
@ -373,6 +409,7 @@ class CalendarController extends AbstractController
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'entity_json' => $entity_array,
|
||||
'templates' => $templates,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,26 @@
|
||||
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||
</a>
|
||||
</li>
|
||||
{% if form.save_and_create_doc is defined %}
|
||||
{% if templates|length == 0 %}
|
||||
<li>
|
||||
{{ form_widget(form.save_and_create_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Save and add a document'|trans }) }}
|
||||
{{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Create and add a document'|trans }) }}
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-create dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{{ 'chill_calendar.Add a document'|trans }}
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
{{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'dropdown-item' }, 'label': 'chill_calendar.Upload a document'|trans }) }}
|
||||
</li>
|
||||
{% for template in templates %}
|
||||
{{ form_widget(form['save_and_generate_doc_' ~ template.id ], {'attr' : { 'class' : 'dropdown-item'}}) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
|
@ -77,10 +77,27 @@
|
||||
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||
</a>
|
||||
</li>
|
||||
{% if form.save_and_create_doc is defined %}
|
||||
{% if templates|length == 0 %}
|
||||
<li>
|
||||
{{ form_widget(form.save_and_create_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Create and add a document'|trans }) }}
|
||||
{{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Create and add a document'|trans }) }}
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-create dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{{ 'chill_calendar.Add a document'|trans }}
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
{{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'dropdown-item' }, 'label': 'chill_calendar.Upload a document'|trans }) }}
|
||||
</li>
|
||||
{% for template in templates %}
|
||||
{{ form_widget(form['save_and_generate_doc_' ~ template.id ], {'attr' : { 'class' : 'dropdown-item'}}) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
{{ form_widget(form.save, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'Create'|trans }) }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user