mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: [Calendar doc] complete CRUD for associating documents within Calendar
This commit is contained in:
parent
fc15b85d11
commit
39f410dc8f
@ -12,12 +12,20 @@ declare(strict_types=1);
|
|||||||
namespace Chill\CalendarBundle\Controller;
|
namespace Chill\CalendarBundle\Controller;
|
||||||
|
|
||||||
use Chill\CalendarBundle\Entity\Calendar;
|
use Chill\CalendarBundle\Entity\Calendar;
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
use Chill\CalendarBundle\Form\CalendarDocCreateType;
|
||||||
|
use Chill\CalendarBundle\Form\CalendarDocEditType;
|
||||||
|
use Chill\CalendarBundle\Security\Voter\CalendarDocVoter;
|
||||||
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
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\Exception\AccessDeniedException;
|
||||||
@ -32,18 +40,202 @@ class CalendarDocController
|
|||||||
|
|
||||||
private EngineInterface $engine;
|
private EngineInterface $engine;
|
||||||
|
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
private FormFactoryInterface $formFactory;
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
private SerializerInterface $serializer;
|
private SerializerInterface $serializer;
|
||||||
|
|
||||||
private UrlGeneratorInterface $urlGenerator;
|
private UrlGeneratorInterface $urlGenerator;
|
||||||
|
|
||||||
public function __construct(Security $security, DocGeneratorTemplateRepository $docGeneratorTemplateRepository, UrlGeneratorInterface $urlGenerator, EngineInterface $engine)
|
public function __construct(
|
||||||
{
|
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||||
$this->security = $security;
|
EngineInterface $engine,
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
FormFactoryInterface $formFactory,
|
||||||
|
Security $security,
|
||||||
|
UrlGeneratorInterface $urlGenerator
|
||||||
|
) {
|
||||||
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
$this->engine = $engine;
|
$this->engine = $engine;
|
||||||
|
$this->entityManager = $entityManager;
|
||||||
|
$this->formFactory = $formFactory;
|
||||||
|
$this->security = $security;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{_locale}/calendar/calendar-doc/{id}/new", name="chill_calendar_calendardoc_new")
|
||||||
|
*/
|
||||||
|
public function create(Calendar $calendar, Request $request): Response
|
||||||
|
{
|
||||||
|
$calendarDoc = (new CalendarDoc($calendar, null))->setCalendar($calendar);
|
||||||
|
|
||||||
|
if (!$this->security->isGranted(CalendarDocVoter::EDIT, $calendarDoc)) {
|
||||||
|
throw new AccessDeniedHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// set variables
|
||||||
|
switch ($calendarDoc->getCalendar()->getContext()) {
|
||||||
|
case 'accompanying_period':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/new_accompanying_period.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_period';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getAccompanyingPeriod()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'person':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/new_person.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_person';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getPerson()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new UnexpectedValueException('Unsupported context');
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendarDocDTO = new CalendarDoc\CalendarDocCreateDTO();
|
||||||
|
$form = $this->formFactory->create(CalendarDocCreateType::class, $calendarDocDTO);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$calendarDoc->createFromDTO($calendarDocDTO);
|
||||||
|
|
||||||
|
$this->entityManager->persist($calendarDoc);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
if ($request->query->has('returnPath')) {
|
||||||
|
return new RedirectResponse($request->query->get('returnPath'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RedirectResponse(
|
||||||
|
$this->urlGenerator->generate($returnRoute, $returnParams)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
$this->engine->render(
|
||||||
|
$view,
|
||||||
|
['calendar_doc' => $calendarDoc, 'form' => $form->createView()]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{_locale}/calendar/calendar-doc/{id}/delete", name="chill_calendar_calendardoc_delete")
|
||||||
|
*/
|
||||||
|
public function delete(CalendarDoc $calendarDoc, Request $request): Response
|
||||||
|
{
|
||||||
|
if (!$this->security->isGranted(CalendarDocVoter::EDIT, $calendarDoc)) {
|
||||||
|
throw new AccessDeniedHttpException('Not authorized to delete document');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($calendarDoc->getCalendar()->getContext()) {
|
||||||
|
case 'accompanying_period':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/delete_accompanying_period.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_period';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getAccompanyingPeriod()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'person':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/delete_person.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_person';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getPerson()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = $this->formFactory->createBuilder()
|
||||||
|
->add('submit', SubmitType::class, [
|
||||||
|
'label' => 'Delete',
|
||||||
|
])
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted()) {
|
||||||
|
$this->entityManager->remove($calendarDoc);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
if ($request->query->has('returnPath')) {
|
||||||
|
return new RedirectResponse($request->query->get('returnPath'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RedirectResponse(
|
||||||
|
$this->urlGenerator->generate($returnRoute, $returnParams)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
$this->engine->render(
|
||||||
|
$view,
|
||||||
|
[
|
||||||
|
'calendar_doc' => $calendarDoc,
|
||||||
|
'form' => $form->createView(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{_locale}/calendar/calendar-doc/{id}/edit", name="chill_calendar_calendardoc_edit")
|
||||||
|
*/
|
||||||
|
public function edit(CalendarDoc $calendarDoc, Request $request): Response
|
||||||
|
{
|
||||||
|
if (!$this->security->isGranted(CalendarDocVoter::EDIT, $calendarDoc)) {
|
||||||
|
throw new AccessDeniedHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// set variables
|
||||||
|
switch ($calendarDoc->getCalendar()->getContext()) {
|
||||||
|
case 'accompanying_period':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/edit_accompanying_period.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_period';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getAccompanyingPeriod()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'person':
|
||||||
|
$view = '@ChillCalendar/CalendarDoc/edit_person.html.twig';
|
||||||
|
$returnRoute = 'chill_calendar_calendar_list_by_person';
|
||||||
|
$returnParams = ['id' => $calendarDoc->getCalendar()->getPerson()->getId()];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new UnexpectedValueException('Unsupported context');
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendarDocEditDTO = new CalendarDoc\CalendarDocEditDTO($calendarDoc);
|
||||||
|
$form = $this->formFactory->create(CalendarDocEditType::class, $calendarDocEditDTO);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$calendarDoc->editFromDTO($calendarDocEditDTO);
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
if ($request->query->has('returnPath')) {
|
||||||
|
return new RedirectResponse($request->query->get('returnPath'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RedirectResponse(
|
||||||
|
$this->urlGenerator->generate($returnRoute, $returnParams)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
$this->engine->render(
|
||||||
|
$view,
|
||||||
|
['calendar_doc' => $calendarDoc, 'form' => $form->createView()]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\CalendarBundle\Entity;
|
namespace Chill\CalendarBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocCreateDTO;
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocEditDTO;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||||
@ -52,14 +54,14 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"})
|
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"})
|
||||||
* @ORM\JoinColumn(nullable=false)
|
* @ORM\JoinColumn(nullable=false)
|
||||||
*/
|
*/
|
||||||
private StoredObject $storedObject;
|
private ?StoredObject $storedObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="boolean", nullable=false, options={"default": false})
|
* @ORM\Column(type="boolean", nullable=false, options={"default": false})
|
||||||
*/
|
*/
|
||||||
private bool $trackDateTimeVersion = false;
|
private bool $trackDateTimeVersion = false;
|
||||||
|
|
||||||
public function __construct(Calendar $calendar, StoredObject $storedObject)
|
public function __construct(Calendar $calendar, ?StoredObject $storedObject)
|
||||||
{
|
{
|
||||||
$this->setCalendar($calendar);
|
$this->setCalendar($calendar);
|
||||||
|
|
||||||
@ -67,6 +69,22 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
$this->datetimeVersion = $calendar->getDateTimeVersion();
|
$this->datetimeVersion = $calendar->getDateTimeVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createFromDTO(CalendarDocCreateDTO $calendarDocCreateDTO): void
|
||||||
|
{
|
||||||
|
$this->storedObject = $calendarDocCreateDTO->doc;
|
||||||
|
$this->storedObject->setTitle($calendarDocCreateDTO->title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editFromDTO(CalendarDocEditDTO $calendarDocEditDTO): void
|
||||||
|
{
|
||||||
|
if (null !== $calendarDocEditDTO->doc) {
|
||||||
|
$calendarDocEditDTO->doc->setTitle($this->getStoredObject()->getTitle());
|
||||||
|
$this->setStoredObject($calendarDocEditDTO->doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getStoredObject()->setTitle($calendarDocEditDTO->title);
|
||||||
|
}
|
||||||
|
|
||||||
public function getCalendar(): Calendar
|
public function getCalendar(): Calendar
|
||||||
{
|
{
|
||||||
return $this->calendar;
|
return $this->calendar;
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?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\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class CalendarDocCreateDTO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Assert\NotNull
|
||||||
|
* @Assert\Valid
|
||||||
|
*/
|
||||||
|
public ?StoredObject $doc = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Assert\NotBlank
|
||||||
|
* @Assert\NotNull
|
||||||
|
*/
|
||||||
|
public ?string $title = '';
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
<?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\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class CalendarDocEditDTO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Assert\Valid
|
||||||
|
*/
|
||||||
|
public ?StoredObject $doc = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Assert\NotBlank
|
||||||
|
* @Assert\NotNull
|
||||||
|
*/
|
||||||
|
public ?string $title = '';
|
||||||
|
|
||||||
|
public function __construct(CalendarDoc $calendarDoc)
|
||||||
|
{
|
||||||
|
$this->title = $calendarDoc->getStoredObject()->getTitle();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?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\CalendarBundle\Form;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocCreateDTO;
|
||||||
|
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class CalendarDocCreateType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('title', TextType::class, [
|
||||||
|
'label' => 'chill_calendar.Document title',
|
||||||
|
'required' => true,
|
||||||
|
])
|
||||||
|
->add('doc', StoredObjectType::class, [
|
||||||
|
'label' => 'chill_calendar.Document object',
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CalendarDocCreateDTO::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
41
src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php
Normal file
41
src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php
Normal file
@ -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\CalendarBundle\Form;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocEditDTO;
|
||||||
|
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class CalendarDocEditType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('title', TextType::class, [
|
||||||
|
'label' => 'chill_calendar.Document title',
|
||||||
|
'required' => true,
|
||||||
|
])
|
||||||
|
->add('doc', StoredObjectType::class, [
|
||||||
|
'label' => 'chill_calendar.Document object',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CalendarDocEditDTO::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -17,27 +17,37 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for d in calendar.documents %}
|
{% for d in calendar.documents %}
|
||||||
<tr>
|
{% if is_granted('CHILL_CALENDAR_DOC_SEE', d) %}
|
||||||
<td class="eval">
|
<tr>
|
||||||
<ul class="eval_title">
|
<td class="eval">
|
||||||
<li>
|
<ul class="eval_title">
|
||||||
{{ mm.mimeIcon(d.storedObject.type) }}
|
|
||||||
{{ d.storedObject.title }}
|
|
||||||
|
|
||||||
<ul class="record_actions small inline">
|
|
||||||
{% if chill_document_is_editable(d.storedObject) %}
|
|
||||||
<li>
|
|
||||||
{{ d.storedObject|chill_document_edit_button }}
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
<li>
|
<li>
|
||||||
{{ m.download_button(d.storedObject, d.storedObject.title) }}
|
{{ mm.mimeIcon(d.storedObject.type) }}
|
||||||
|
{{ d.storedObject.title }}
|
||||||
|
|
||||||
|
<ul class="record_actions small inline">
|
||||||
|
{% if chill_document_is_editable(d.storedObject) and is_granted('CHILL_CALENDAR_DOC_EDIT', d) %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ chill_path_add_return_path('chill_calendar_calendardoc_delete', {'id': d.id})}}" class="btn btn-delete"></a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ d.storedObject|chill_document_edit_button }}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_CALENDAR_DOC_EDIT', d) %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ chill_path_add_return_path('chill_calendar_calendardoc_edit', {'id': d.id})}}" class="btn btn-edit"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
<li>
|
||||||
|
{{ m.download_button(d.storedObject, d.storedObject.title) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</td>
|
||||||
</ul>
|
</tr>
|
||||||
</td>
|
{% endif %}
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -112,13 +112,37 @@
|
|||||||
|
|
||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) and hasDocs %}
|
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) %}
|
||||||
<li>
|
{% if not hasDocs %}
|
||||||
<a class="btn btn-create"
|
<li>
|
||||||
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_pick_template', {'id': calendar.id }) }}">
|
<a class="btn btn-create"
|
||||||
{{ 'chill_calendar.Add a document'|trans }}
|
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
||||||
</a>
|
{{ 'chill_calendar.Add a document'|trans }}
|
||||||
</li>
|
</a>
|
||||||
|
</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>
|
||||||
|
<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>
|
||||||
|
<a class="dropdown-item"
|
||||||
|
href="{{ chill_path_add_return_path('chill_calendar_calendardoc_new', {'id': calendar.id }) }}">
|
||||||
|
{{ 'chill_calendar.Upload a document'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if accompanyingCourse is defined and is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %}
|
{% if accompanyingCourse is defined and is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %}
|
||||||
<li>
|
<li>
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'chill_calendar.Remove a calendar document' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% set accompanyingCourse = calendar_doc.calendar.accompanyingPeriod %}
|
||||||
|
{% set accompanyingCourseId = accompanyingCourse.id %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'chill_calendar.Remove a calendar document'|trans,
|
||||||
|
'confirm_question' : 'chill_calendar.Are you sure you want to remove the doc?'|trans,
|
||||||
|
'cancel_route' : 'chill_calendar_calendar_list_by_period',
|
||||||
|
'cancel_parameters' : { 'id' : accompanyingCourse.id },
|
||||||
|
'form' : form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,18 @@
|
|||||||
|
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'chill_calendar.Edit a document' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% set person = calendar_doc.calendar.person %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'chill_calendar.Remove a calendar document'|trans,
|
||||||
|
'confirm_question' : 'chill_calendar.Are you sure you want to remove the doc?'|trans,
|
||||||
|
'cancel_route' : 'chill_calendar_calendar_list_by_person',
|
||||||
|
'cancel_parameters' : { 'id' : person.id },
|
||||||
|
'form' : form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,40 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'chill_calendar.Edit a document' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% set accompanyingCourse = calendar_doc.calendar.accompanyingPeriod %}
|
||||||
|
{% set accompanyingCourseId = accompanyingCourse.id %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{ 'chill_calendar.Edit a document'|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.title) }}
|
||||||
|
{{ form_row(form.doc) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_accompanying_period', {'id': accompanyingCourse.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-save" type="submit">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,39 @@
|
|||||||
|
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'chill_calendar.Edit a document' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% set person = calendar_doc.calendar.person %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{ 'chill_calendar.Edit a document'|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.title) }}
|
||||||
|
{{ form_row(form.doc) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_person', {'id': person.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-save" type="submit">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,40 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% set accompanyingCourse = calendar_doc.calendar.accompanyingPeriod %}
|
||||||
|
{% set accompanyingCourseId = accompanyingCourse.id %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{ 'chill_calendar.Add a document'|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.title) }}
|
||||||
|
{{ form_row(form.doc) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_accompanying_period', {'id': accompanyingCourse.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-save" type="submit">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,39 @@
|
|||||||
|
{% 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_doc.calendar.person %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{ 'chill_calendar.Add a document'|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.title) }}
|
||||||
|
{{ form_row(form.doc) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_person', {'id': person.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-save" type="submit">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
{% endblock %}
|
@ -0,0 +1,63 @@
|
|||||||
|
<?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\CalendarBundle\Tests\Entity;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\Calendar;
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class CalendarDocTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testCreateEditFromDTO(): void
|
||||||
|
{
|
||||||
|
$doc = new CalendarDoc(new Calendar(), null);
|
||||||
|
|
||||||
|
$create = new CalendarDoc\CalendarDocCreateDTO();
|
||||||
|
$create->title = 'tagada';
|
||||||
|
$create->doc = $obj1 = new StoredObject();
|
||||||
|
|
||||||
|
$doc->createFromDTO($create);
|
||||||
|
|
||||||
|
$this->assertSame($obj1, $doc->getStoredObject());
|
||||||
|
$this->assertEquals('tagada', $doc->getStoredObject()->getTitle());
|
||||||
|
|
||||||
|
$edit = new CalendarDoc\CalendarDocEditDTO($doc);
|
||||||
|
$edit->title = 'tsointsoin';
|
||||||
|
|
||||||
|
$doc->editFromDTO($edit);
|
||||||
|
|
||||||
|
$this->assertSame($obj1, $doc->getStoredObject());
|
||||||
|
$this->assertEquals('tsointsoin', $doc->getStoredObject()->getTitle());
|
||||||
|
|
||||||
|
$edit2 = new CalendarDoc\CalendarDocEditDTO($doc);
|
||||||
|
$edit2->doc = $obj2 = new StoredObject();
|
||||||
|
|
||||||
|
$doc->editFromDTO($edit2);
|
||||||
|
|
||||||
|
$this->assertSame($obj2, $doc->getStoredObject());
|
||||||
|
$this->assertEquals('tsointsoin', $doc->getStoredObject()->getTitle());
|
||||||
|
|
||||||
|
$edit3 = new CalendarDoc\CalendarDocEditDTO($doc);
|
||||||
|
$edit3->doc = $obj3 = new StoredObject();
|
||||||
|
$edit3->title = 'tagada';
|
||||||
|
|
||||||
|
$doc->editFromDTO($edit3);
|
||||||
|
|
||||||
|
$this->assertSame($obj3, $doc->getStoredObject());
|
||||||
|
$this->assertEquals('tagada', $doc->getStoredObject()->getTitle());
|
||||||
|
}
|
||||||
|
}
|
@ -55,6 +55,13 @@ chill_calendar:
|
|||||||
Create and add a document: Créer et ajouter un document
|
Create and add a document: Créer et ajouter un document
|
||||||
Save and add a document: Enregistrer et ajouter un document
|
Save and add a document: Enregistrer et ajouter un document
|
||||||
Create for me: Créer un rendez-vous pour moi-même
|
Create for me: Créer un rendez-vous pour moi-même
|
||||||
|
Edit a document: Modifier un document
|
||||||
|
Document title: Titre
|
||||||
|
Document object: Document
|
||||||
|
Add a document from template: Ajouter un document depuis un gabarit
|
||||||
|
Upload a document: Téléverser un document
|
||||||
|
Remove a calendar document: Supprimer un document d'un rendez-vous
|
||||||
|
Are you sure you want to remove the doc?: Êtes-vous sûr·e de vouloir supprimer le document associé ?
|
||||||
|
|
||||||
|
|
||||||
remote_ms_graph:
|
remote_ms_graph:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user