mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
merge calendar/finalization into testing: fix conflicts
This commit is contained in:
commit
72ae6fb2cd
@ -16,6 +16,7 @@ use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
@ -23,6 +24,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class CalendarDocController
|
||||
{
|
||||
@ -47,7 +49,7 @@ class CalendarDocController
|
||||
/**
|
||||
* @Route("/{_locale}/calendar/docgen/pick/{id}", name="chill_calendar_calendardoc_pick_template")
|
||||
*/
|
||||
public function pickTemplate(Calendar $calendar): Response
|
||||
public function pickTemplate(Calendar $calendar, Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted(CalendarVoter::SEE, $calendar)) {
|
||||
throw new AccessDeniedException('Not authorized to see this calendar');
|
||||
@ -60,23 +62,42 @@ class CalendarDocController
|
||||
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',
|
||||
[
|
||||
'template' => $templates[0]->getId(),
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $calendar->getId(),
|
||||
]
|
||||
array_merge(
|
||||
$returnPathParam ?? [],
|
||||
[
|
||||
'template' => $templates[0]->getId(),
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $calendar->getId(),
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new Response(
|
||||
$this->engine->render('@ChillCalendar/CalendarDoc/pick_template.html.twig', [
|
||||
'calendar' => $calendar,
|
||||
'accompanyingCourse' => $calendar->getAccompanyingPeriod(),
|
||||
])
|
||||
);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@ -36,20 +35,12 @@ class BetweenDatesFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->gte('cal.startDate', ':dateFrom'),
|
||||
$qb->expr()->lte('cal.endDate', ':dateTo')
|
||||
);
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter(
|
||||
'dateFrom',
|
||||
$this->rollingDateConverter->convert($data['date_from'])
|
||||
@ -79,7 +70,7 @@ class BetweenDatesFilter implements FilterInterface
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return ['Filtered by appointments between %dateFrom% and %dateTo%', [
|
||||
return ['Filtered by calendars between %dateFrom% and %dateTo%', [
|
||||
'%dateFrom%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
|
||||
'%dateTo%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
|
||||
]];
|
||||
|
@ -1,7 +1,5 @@
|
||||
{# list used in context of person or accompanyingPeriod #}
|
||||
|
||||
{{ filterOrder|chill_render_filter_order_helper }}
|
||||
|
||||
{% if calendarItems|length > 0 %}
|
||||
<div class="flex-table list-records context-accompanyingCourse">
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
<h1>{{ 'Calendar list' |trans }}</h1>
|
||||
|
||||
{{ filterOrder|chill_render_filter_order_helper }}
|
||||
|
||||
{% if calendarItems|length == 0 %}
|
||||
<p class="chill-no-data-statement">
|
||||
{{ "There is no calendar items."|trans }}
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
<h1>{{ 'Calendar list' |trans }}</h1>
|
||||
|
||||
{{ filterOrder|chill_render_filter_order_helper }}
|
||||
|
||||
{% if calendarItems|length == 0 %}
|
||||
<p class="chill-no-data-statement">
|
||||
{{ "There is no calendar items."|trans }}
|
||||
|
@ -5,6 +5,7 @@
|
||||
{% 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 %}
|
||||
@ -19,6 +20,18 @@
|
||||
|
||||
{% 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 %}
|
@ -0,0 +1,35 @@
|
||||
{% 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 %}
|
@ -1 +1 @@
|
||||
Votre travailleur social {{ calendar.mainUser.label }} vous rencontrera le {{ calendar.startDate|format_date('short', locale='fr') }} à {{ calendar.startDate|format_time('short', locale='fr') }} - LIEU.{% if calendar.mainUser.mainLocation is not null and calendar.mainUser.mainLocation.phonenumber1 is not null %} En cas d'indisponibilité, appelez-nous au {{ calendar.mainUser.mainLocation.phonenumber1|chill_format_phonenumber }}.{% endif %}
|
||||
Votre travailleur social {{ calendar.mainUser.label }} vous rencontrera le {{ calendar.startDate|format_date('short', locale='fr') }} à {{ calendar.startDate|format_time('short', locale='fr') }} - {% if calendar.location is not null%}{{ calendar.location.name }}{% endif %}{% if calendar.mainUser.mainLocation is not null and calendar.mainUser.mainLocation.phonenumber1 is not null %} En cas d'indisponibilité, appelez-nous au {{ calendar.mainUser.mainLocation.phonenumber1|chill_format_phonenumber }}.{% endif %}
|
||||
|
@ -61,6 +61,9 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
public function getRoles(): array
|
||||
{
|
||||
return [
|
||||
self::CREATE,
|
||||
self::DELETE,
|
||||
self::EDIT,
|
||||
self::SEE,
|
||||
];
|
||||
}
|
||||
@ -72,7 +75,12 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
self::CREATE,
|
||||
self::DELETE,
|
||||
self::EDIT,
|
||||
self::SEE,
|
||||
];
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject): bool
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Calendar;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20221125144205 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->throwIrreversibleMigrationException();
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Calendar: remove association between scope and calendar';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(
|
||||
sprintf(
|
||||
'UPDATE role_scopes SET scope_id=NULL WHERE role IN (\'%s\', \'%s\', \'%s\', \'%s\')',
|
||||
'CHILL_CALENDAR_CALENDAR_CREATE',
|
||||
'CHILL_CALENDAR_CALENDAR_DELETE',
|
||||
'CHILL_CALENDAR_CALENDAR_EDIT',
|
||||
'CHILL_CALENDAR_CALENDAR_SEE'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -131,3 +131,9 @@ docgen:
|
||||
Destinee: Destinataire
|
||||
None: Aucun choix
|
||||
title of the generated document: Titre du document généré
|
||||
|
||||
CHILL_CALENDAR_CALENDAR_CREATE: Créer les rendez-vous
|
||||
CHILL_CALENDAR_CALENDAR_EDIT: Modifier les rendez-vous
|
||||
CHILL_CALENDAR_CALENDAR_DELETE: Supprimer les rendez-vous
|
||||
CHILL_CALENDAR_CALENDAR_SEE: Voir les rendez-vous
|
||||
|
||||
|
@ -44,6 +44,11 @@ class PickRollingDateType extends AbstractType
|
||||
$builder->setDataMapper(new RollingDateDataMapper());
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['uniqid'] = uniqid('rollingdate-');
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
@ -65,9 +70,4 @@ class PickRollingDateType extends AbstractType
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['uniqid'] = uniqid('rollingdate-');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user