diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de2c188a..6e70aaed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,8 @@ and this project adheres to * [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) - - +* [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) +* [activity] do not override location if already exist (when validating new activity) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/470) * [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) * [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) @@ -22,13 +22,14 @@ and this project adheres to * [Person/Household list] when listing other simultaneous members of an household, exclude the members on person, not on members (avoid to show two membersship with the same person) * [draft periods] add a delete button (if acl granted) on each draft period listed on draft period page (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/463) * [Person] Display suffixText in RenderPerson, PersonText.vue, RenderPersonBox.vue (was made for displaying "enfant confie") (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/441) -* [person] residential address: show residential address or info in PersonRenderBox, refactor Residential Address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/439) +* [person] residential address: show residential address or info in PersonRenderBox, refactor Residential Address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/439) * [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) * [documents] Improve flex-table item-col placement when long buttons and long metadata * [thirdparty] Fix display of multiple contact badges so they wrap onto next line (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/482) * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) +* [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) ## Test releases diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 311bdc219..6125140a5 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -110,10 +110,8 @@ export default function prepareLocations(store) { console.log('default loation id', window.default_location_id); if (window.default_location_id) { for (let group of store.state.availableLocations) { - console.log(group); let location = group.locations.find((l) => l.id === window.default_location_id); - console.log(location); - if (location !== undefined) { + if (location !== undefined & store.state.activity.location === null) { store.dispatch('updateLocation', location); break; } diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 81a34d47d..051497b69 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -76,7 +76,7 @@ activity: Insert a document: Insérer un document Remove a document: Supprimer le document comment: Commentaire -No documents: Pas de documents +No documents: Aucun document #timeline '%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"' diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 2aff33af0..000fcb03a 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -207,21 +207,21 @@ final class DocGeneratorTemplateController extends AbstractController $context instanceof DocGeneratorContextWithPublicFormInterface && $context->hasPublicForm($template, $entity) || $isTest ) { - if ($context instanceof DocGeneratorContextWithPublicFormInterface) { + if ($context instanceof DocGeneratorContextWithPublicFormInterface && $context->hasPublicForm($template, $entity)) { $builder = $this->createFormBuilder( array_merge( $context->getFormData($template, $entity), $isTest ? ['test_file' => null] : [] ) ); + + $context->buildPublicForm($builder, $template, $entity); } else { $builder = $this->createFormBuilder( ['test_file' => null] ); } - $context->buildPublicForm($builder, $template, $entity); - if ($isTest) { $builder->add('test_file', FileType::class, [ 'label' => 'Template file', diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 199f88c60..ae8db17f6 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -21,6 +21,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -59,21 +61,37 @@ class DocumentAccompanyingCourseController extends AbstractController } /** - * @Route("/{id}", name="accompanying_course_document_delete", methods="DELETE") + * @Route("/{id}/delete", name="chill_docstore_accompanying_course_document_delete") */ public function delete(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response { $this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::DELETE, $document); - if ($this->isCsrfTokenValid('delete' . $document->getId(), $request->request->get('_token'))) { - $em = $this->getDoctrine()->getManager(); - $em->remove($document); - $em->flush(); + $form = $this->createForm(FormType::class); + $form->add('submit', SubmitType::class, ['label' => 'Delete']); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->remove($document); + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->translator->trans('The document is successfully removed')); + + if ($request->query->has('returnPath')) { + return $this->redirect($request->query->get('returnPath')); + } + + return $this->redirectToRoute('accompanying_course_document_index', ['course' => $course->getId()]); } - return $this->redirectToRoute( - 'accompanying_course_document_index', - ['accompanyingCourse' => $course->getId()] + return $this->render( + 'ChillDocStoreBundle:AccompanyingCourseDocument:delete.html.twig', + [ + 'document' => $document, + 'delete_form' => $form->createView(), + 'accompanyingCourse' => $course, + ] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index fcb3a4958..42e49ad3c 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Form\PersonDocumentType; use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface; +use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -22,6 +23,8 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -64,22 +67,37 @@ class DocumentPersonController extends AbstractController } /** - * @Route("/{id}", name="person_document_delete", methods="DELETE") + * @Route("/{id}/delete", name="chill_docstore_person_document_delete") */ public function delete(Request $request, Person $person, PersonDocument $document): Response { - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_DELETE', $document); + $this->denyAccessUnlessGranted(PersonDocumentVoter::DELETE, $document); - if ($this->isCsrfTokenValid('delete' . $document->getId(), $request->request->get('_token'))) { - $em = $this->getDoctrine()->getManager(); - $em->remove($document); - $em->flush(); + $form = $this->createForm(FormType::class); + $form->add('submit', SubmitType::class, ['label' => 'Delete']); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->remove($document); + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->translator->trans('The document is successfully removed')); + + if ($request->query->has('returnPath')) { + return $this->redirect($request->query->get('returnPath')); + } + + return $this->redirectToRoute('person_document_index', ['person' => $person->getId()]); } - return $this->redirectToRoute( - 'person_document_index', - ['person' => $person->getId()] + return $this->render( + 'ChillDocStoreBundle:PersonDocument:delete.html.twig', + [ + 'document' => $document, + 'delete_form' => $form->createView(), + 'person' => $person, + ] ); } @@ -98,7 +116,6 @@ class DocumentPersonController extends AbstractController PersonDocumentType::class, $document, [ - 'center' => $document->getCenter(), 'role' => 'CHILL_PERSON_DOCUMENT_UPDATE', ] ); @@ -199,7 +216,6 @@ class DocumentPersonController extends AbstractController $document->setDate(new DateTime('Now')); $form = $this->createForm(PersonDocumentType::class, $document, [ - 'center' => $document->getCenter(), 'role' => 'CHILL_PERSON_DOCUMENT_CREATE', ]); $form->handleRequest($request); diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index bcbd4d707..41dc73154 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -13,15 +13,13 @@ namespace Chill\DocStoreBundle\Form; use Chill\DocStoreBundle\Entity\Document; use Chill\DocStoreBundle\Entity\PersonDocument; -use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\ScopePickerType; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; -use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -31,34 +29,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonDocumentType extends AbstractType { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var ObjectManager - */ - protected $om; - - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; - - /** - * the user running this form. - * - * @var User - */ - protected $user; + private CenterResolverDispatcher $centerResolverDispatcher; private ParameterBagInterface $parameterBag; private ScopeResolverDispatcher $scopeResolverDispatcher; + private TranslatableStringHelperInterface $translatableStringHelper; + public function __construct( - TranslatableStringHelper $translatableStringHelper, + TranslatableStringHelperInterface $translatableStringHelper, ScopeResolverDispatcher $scopeResolverDispatcher, ParameterBagInterface $parameterBag ) { @@ -96,7 +76,7 @@ class PersonDocumentType extends AbstractType if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { $builder->add('scope', ScopePickerType::class, [ - 'center' => $options['center'], + 'center' => $this->centerResolverDispatcher->resolveCenter($document), 'role' => $options['role'], ]); } @@ -108,8 +88,7 @@ class PersonDocumentType extends AbstractType 'data_class' => Document::class, ]); - $resolver->setRequired(['role', 'center']) - ->setAllowedTypes('role', ['string']) - ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]); + $resolver->setRequired(['role']) + ->setAllowedTypes('role', ['string']); } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig deleted file mode 100644 index 90ee734e0..000000000 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -
- - - -
diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig new file mode 100644 index 000000000..a6679829b --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig @@ -0,0 +1,43 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %}{{ 'Delete document ?' }}{% endblock %} + +{% block docdescription %} +
+
{{ 'Title'|trans }}
+
{{ document.title }}
+ + {% if document.scope is not null %} +
{{ 'Scope' | trans }}
+
{{ document.scope.name | localize_translatable_string }}
+ {% endif %} + +
{{ 'Category'|trans }}
+
{{ document.category.name|localize_translatable_string }}
+ +
{{ 'Description' | trans }}
+
+ {% if document.description is empty %} + {{ 'Any description'|trans }} + {% else %} +
+ {{ document.description|chill_markdown_to_html }} +
+ {% endif %} +
+
+{% endblock %} + +{% block content %} +{{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Delete document ?'|trans, + 'display_content' : block('docdescription'), + 'confirm_question' : 'Are you sure you want to remove this document ?'|trans, + 'cancel_route' : 'accompanying_course_document_index', + 'cancel_parameters' : {'course' : accompanyingCourse.id, 'id': document.id}, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig index d7a5325cf..0ca5661fc 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig @@ -25,8 +25,13 @@ {{ 'Back to the list' | trans }} -
  • - + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %} +
  • + +
  • + {% endif %} +
  • +
  • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig index 1e4fdb8e6..45ed3988b 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -49,12 +49,9 @@ {{ 'Back to the list' | trans }} -
  • - {{ m.download_button(document.object, document.title) }} -
  • - {% if chill_document_is_editable(document.object) %} -
  • - {{ document.object|chill_document_edit_button }} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %} +
  • +
  • {% endif %} {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} @@ -63,6 +60,14 @@ class="btn btn-edit" title="{{ 'Edit attributes' | trans }}"> {% endif %} +
  • + {{ m.download_button(document.object, document.title) }} +
  • + {% if chill_document_is_editable(document.object) %} +
  • + {{ document.object|chill_document_edit_button }} +
  • + {% endif %} {% set workflows_frame = chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) %} {% if workflows_frame is not empty %}
  • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig index 5ce03091b..8fbc3fa5c 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig @@ -44,6 +44,16 @@ - + diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig new file mode 100644 index 000000000..e3f6687fd --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig @@ -0,0 +1,43 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %}{{ 'Delete document ?' }}{% endblock %} + +{% block docdescription %} +
    +
    {{ 'Title'|trans }}
    +
    {{ document.title }}
    + + {% if document.scope is not null %} +
    {{ 'Scope' | trans }}
    +
    {{ document.scope.name | localize_translatable_string }}
    + {% endif %} + +
    {{ 'Category'|trans }}
    +
    {{ document.category.name|localize_translatable_string }}
    + +
    {{ 'Description' | trans }}
    +
    + {% if document.description is empty %} + {{ 'Any description'|trans }} + {% else %} +
    + {{ document.description|chill_markdown_to_html }} +
    + {% endif %} +
    +
    +{% endblock %} + +{% block personcontent %} +{{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Delete document ?'|trans, + 'display_content' : block('docdescription'), + 'confirm_question' : 'Are you sure you want to remove this document ?'|trans, + 'cancel_route' : 'person_document_index', + 'cancel_parameters' : {'person' : person.id, 'id': document.id}, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig index 7533f1120..4a9eab8e3 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig @@ -36,20 +36,20 @@ {{ form_row(form.description) }} {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} -