mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Merge branch 'calendar/finalization' into testing
This commit is contained in:
commit
c16454214d
@ -234,7 +234,7 @@ class CalendarController extends AbstractController
|
|||||||
'paginator' => $paginator,
|
'paginator' => $paginator,
|
||||||
'filterOrder' => $filterOrder,
|
'filterOrder' => $filterOrder,
|
||||||
'nbIgnored' => $this->calendarACLAwareRepository->countIgnoredByAccompanyingPeriod($accompanyingPeriod, $from, $to),
|
'nbIgnored' => $this->calendarACLAwareRepository->countIgnoredByAccompanyingPeriod($accompanyingPeriod, $from, $to),
|
||||||
'hasDocs' => 0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class),
|
'templates' => $this->docGeneratorTemplateRepository->findByEntity(Calendar::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ class CalendarController extends AbstractController
|
|||||||
'paginator' => $paginator,
|
'paginator' => $paginator,
|
||||||
'filterOrder' => $filterOrder,
|
'filterOrder' => $filterOrder,
|
||||||
'nbIgnored' => $this->calendarACLAwareRepository->countIgnoredByPerson($person, $from, $to),
|
'nbIgnored' => $this->calendarACLAwareRepository->countIgnoredByPerson($person, $from, $to),
|
||||||
'hasDocs' => 0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class),
|
'templates' => $this->docGeneratorTemplateRepository->findByEntity(Calendar::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,8 @@ use Chill\CalendarBundle\Entity\CalendarDoc;
|
|||||||
use Chill\CalendarBundle\Form\CalendarDocCreateType;
|
use Chill\CalendarBundle\Form\CalendarDocCreateType;
|
||||||
use Chill\CalendarBundle\Form\CalendarDocEditType;
|
use Chill\CalendarBundle\Form\CalendarDocEditType;
|
||||||
use Chill\CalendarBundle\Security\Voter\CalendarDocVoter;
|
use Chill\CalendarBundle\Security\Voter\CalendarDocVoter;
|
||||||
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
|
||||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
@ -28,7 +26,6 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
@ -237,59 +234,4 @@ class CalendarDocController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{_locale}/calendar/docgen/pick/{id}", name="chill_calendar_calendardoc_pick_template")
|
|
||||||
*/
|
|
||||||
public function pickTemplate(Calendar $calendar, Request $request): Response
|
|
||||||
{
|
|
||||||
if (!$this->security->isGranted(CalendarVoter::SEE, $calendar)) {
|
|
||||||
throw new AccessDeniedException('Not authorized to see this calendar');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 === $number = $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) {
|
|
||||||
throw new RuntimeException('should not be redirected to this page if no template');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 === $number) {
|
|
||||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
|
||||||
|
|
||||||
if ($request->query->has('returnPath')) {
|
|
||||||
$returnPathParam = ['returnPath' => $request->query->get('returnPath')];
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RedirectResponse(
|
|
||||||
$this->urlGenerator->generate(
|
|
||||||
'chill_docgenerator_generate_from_template',
|
|
||||||
array_merge(
|
|
||||||
$returnPathParam ?? [],
|
|
||||||
[
|
|
||||||
'template' => $templates[0]->getId(),
|
|
||||||
'entityClassName' => Calendar::class,
|
|
||||||
'entityId' => $calendar->getId(),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($calendar->getContext()) {
|
|
||||||
case 'person':
|
|
||||||
return new Response(
|
|
||||||
$this->engine->render('@ChillCalendar/CalendarDoc/pick_template_person.html.twig', [
|
|
||||||
'calendar' => $calendar,
|
|
||||||
])
|
|
||||||
);
|
|
||||||
|
|
||||||
case 'accompanying_period':
|
|
||||||
return new Response(
|
|
||||||
$this->engine->render('@ChillCalendar/CalendarDoc/pick_template_accompanying_period.html.twig', [
|
|
||||||
'calendar' => $calendar,
|
|
||||||
])
|
|
||||||
);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new UnexpectedValueException('calendar context not expected : ' . $calendar->getContext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@
|
|||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) %}
|
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) %}
|
||||||
{% if not hasDocs %}
|
{% if templates|length == 0 %}
|
||||||
<li>
|
<li>
|
||||||
<a class="btn btn-create"
|
<a class="btn btn-create"
|
||||||
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
||||||
@ -127,18 +127,21 @@
|
|||||||
{{ 'chill_calendar.Add a document'|trans }}
|
{{ 'chill_calendar.Add a document'|trans }}
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
|
||||||
<a class="dropdown-item"
|
|
||||||
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_pick_template', {'id': calendar.id }) }}">
|
|
||||||
{{ 'chill_calendar.Add a document from template'|trans }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item"
|
<a class="dropdown-item"
|
||||||
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
||||||
{{ 'chill_calendar.Upload a document'|trans }}
|
{{ 'chill_calendar.Upload a document'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% for template in templates %}
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item"
|
||||||
|
href="{{ chill_path_add_return_path('chill_docgenerator_generate_from_template', {'template': template.id, 'entityClassName': 'Chill\\CalendarBundle\\Entity\\Calendar', 'entityId': calendar.id}) }}"
|
||||||
|
>
|
||||||
|
{{ template.name|localize_translatable_string }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
|
||||||
|
|
||||||
{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %}
|
|
||||||
|
|
||||||
{% set user_id = null %}
|
|
||||||
{% set accompanyingCourse = calendar.accompanyingPeriod %}
|
|
||||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h1>{{ 'chill_calendar.Add a document'|trans }}</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
|
|
||||||
{{ calendar.startDate|format_datetime('short', 'short') }}
|
|
||||||
- {{ calendar.endDate|format_datetime('short', 'short') }}
|
|
||||||
{% else %}
|
|
||||||
{{ calendar.startDate|format_datetime('short', 'short') }}
|
|
||||||
- {{ calendar.endDate|format_datetime('none', 'short') }}
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div data-docgen-template-picker="data-docgen-template-picker" data-entity-id="{{ calendar.id }}" data-entity-class="{{ 'Chill\\CalendarBundle\\Entity\\Calendar'|e('html_attr') }}"></div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,35 +0,0 @@
|
|||||||
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
|
||||||
|
|
||||||
{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %}
|
|
||||||
|
|
||||||
{% set person = calendar.person %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h1>{{ 'chill_calendar.Add a document'|trans }}</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
|
|
||||||
{{ calendar.startDate|format_datetime('short', 'short') }}
|
|
||||||
- {{ calendar.endDate|format_datetime('short', 'short') }}
|
|
||||||
{% else %}
|
|
||||||
{{ calendar.startDate|format_datetime('short', 'short') }}
|
|
||||||
- {{ calendar.endDate|format_datetime('none', 'short') }}
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div data-docgen-template-picker="data-docgen-template-picker" data-entity-id="{{ calendar.id }}" data-entity-class="{{ 'Chill\\CalendarBundle\\Entity\\Calendar'|e('html_attr') }}"></div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
Loading…
x
Reference in New Issue
Block a user