From 24a7d7b34b5e9d690b3b0e00c49c836cb0878a86 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 1 Apr 2021 15:44:05 +0200 Subject: [PATCH 001/116] new entity ActivityTypeCategory + CRUD --- .../AdminActivityTypeCategoryController.php | 25 ++++ .../ChillActivityExtension.php | 40 +++++- .../Entity/ActivityTypeCategory.php | 123 ++++++++++++++++++ .../Form/ActivityTypeCategoryType.php | 33 +++++ .../views/ActivityTypeCategory/edit.html.twig | 12 ++ .../ActivityTypeCategory/index.html.twig | 44 +++++++ .../views/ActivityTypeCategory/new.html.twig | 11 ++ .../ChillActivityBundle/config/routes.yaml | 10 ++ .../migrations/Version20210401090853.php | 36 +++++ .../translations/messages.fr.yml | 9 ++ 10 files changed, 338 insertions(+), 5 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php create mode 100644 src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php create mode 100644 src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/edit.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/index.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/new.html.twig create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210401090853.php diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php new file mode 100644 index 000000000..6abc3ac65 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php @@ -0,0 +1,25 @@ +orderBy('e.id', 'ASC'); + } +} diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index b43703b67..6007a6267 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -3,7 +3,7 @@ /* * Chill is a software for social workers * - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * , * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - + $container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); @@ -57,17 +57,18 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf $loader->load('services/form.yaml'); $loader->load('services/templating.yaml'); } - + public function prepend(ContainerBuilder $container) { $this->prependRoutes($container); $this->prependAuthorization($container); + $this->prependCruds($container); } /* (non-PHPdoc) * @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend() */ - public function prependRoutes(ContainerBuilder $container) + public function prependRoutes(ContainerBuilder $container) { //add routes for custom bundle $container->prependExtensionConfig('chill_main', array( @@ -78,7 +79,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf ) )); } - + public function prependAuthorization(ContainerBuilder $container) { $container->prependExtensionConfig('security', array( @@ -90,4 +91,33 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf ) )); } + + protected function prependCruds(ContainerBuilder $container) + { + $container->prependExtensionConfig('chill_main', [ + 'cruds' => [ + [ + 'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class, + 'name' => 'activity_type_category', + 'base_path' => '/admin/activity_type_category', + 'form_class' => \Chill\ActivityBundle\Form\ActivityTypeCategoryType::class, + 'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeCategoryController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillActivity/ActivityTypeCategory/index.html.twig', + 'role' => 'ROLE_ADMIN' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityTypeCategory/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityTypeCategory/edit.html.twig', + ] + ] + ] + ] + ]); + } } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php new file mode 100644 index 000000000..006a50c28 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -0,0 +1,123 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +use Doctrine\ORM\Mapping as ORM; + +/** + * Class ActivityTypeCateogry + * + * @package Chill\ActivityBundle\Entity + * @ORM\Entity() + * @ORM\Table(name="activitytypecategory") + * @ORM\HasLifecycleCallbacks() + */ +class ActivityTypeCategory +{ + /** + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") + */ + private ?int $id; + + /** + * @ORM\Column(type="json_array") + */ + private array $name = []; + + /** + * @ORM\Column(type="boolean") + */ + private bool $active = true; + + /** + * Get id + * + * @return integer + */ + public function getId(): int + { + return $this->id; + } + + /** + * Set name + */ + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return array | string + */ + public function getName(?string $locale = null) + { + if ($locale) { + if (isset($this->name[$locale])) { + return $this->name[$locale]; + } else { + foreach ($this->name as $name) { + if (!empty($name)) { + return $name; + } + } + } + return ''; + } else { + return $this->name; + } + } + + /** + * Get active + * return true if the category type is active. + */ + public function getActive(): bool + { + return $this->active; + } + + /** + * Is active + * return true if the category type is active + */ + public function isActive(): bool + { + return $this->getActive(); + } + + /** + * Set active + * set to true if the category type is active + */ + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } +} diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php new file mode 100644 index 000000000..8cc90b061 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php @@ -0,0 +1,33 @@ +add('name', TranslatableStringFormType::class) + ->add('active', ChoiceType::class, array( + 'choices' => array( + 'Yes' => true, + 'No' => false + ), + 'expanded' => true + )); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults(array( + 'data_class' => ActivityTypeCategory::class + )); + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/edit.html.twig new file mode 100644 index 000000000..16cf893e8 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/edit.html.twig @@ -0,0 +1,12 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block title %} +{% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/index.html.twig new file mode 100644 index 000000000..2834e50dd --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/index.html.twig @@ -0,0 +1,44 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block admin_content %} +

{{ 'ActivityTypeCategory list'|trans }}

+ + + + + + + + + + + {% for entity in entities %} + + + + + + {% endfor %} + +
{{ 'Name'|trans }}{{ 'Active'|trans }}{{ 'Actions'|trans }}
{{ entity.name|localize_translatable_string }} + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + +
    +
  • + +
  • +
+
+ + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/new.html.twig new file mode 100644 index 000000000..c95711529 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityTypeCategory/new.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block title %} +{% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/config/routes.yaml b/src/Bundle/ChillActivityBundle/config/routes.yaml index 86b5d6764..4940d8df3 100644 --- a/src/Bundle/ChillActivityBundle/config/routes.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes.yaml @@ -14,6 +14,7 @@ chill_activity_activitytype: resource: "@ChillActivityBundle/config/routes/activitytype.yaml" prefix: / + chill_admin_activity_index: path: /{_locale}/admin/activity controller: Chill\ActivityBundle\Controller\AdminController::indexActivityAction @@ -32,3 +33,12 @@ chill_admin_activity_redirect_to_admin_index: admin_activity: order: 0 label: Main admin menu + +chill_activity_type_category_admin: + path: /{_locale}/admin/activity/type_category + controller: cscrud_activity_type_category_controller:index + options: + menus: + admin_activity: + order: 2999 + label: 'Activity Types Categories' diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210401090853.php b/src/Bundle/ChillActivityBundle/migrations/Version20210401090853.php new file mode 100644 index 000000000..43f8c8460 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210401090853.php @@ -0,0 +1,36 @@ +addSql('CREATE SEQUENCE activitytypecategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1000'); + $this->addSql('CREATE TABLE activitytypecategory (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN activitytypecategory.name IS \'(DC2Type:json_array)\''); + $this->addSql('INSERT INTO activitytypecategory VALUES(1, \'{"fr": "Défaut", "en": "Default"}\', true)'); + + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP SEQUENCE activitytypecategory_id_seq CASCADE'); + $this->addSql('DROP TABLE activitytypecategory'); + } +} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 92ac3f7b4..b038269b9 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -77,6 +77,7 @@ Activity configuration menu: Configuration des activités Activity Types: Types d'activité Activity Reasons: Sujets d'une activité Activity Reasons Category: Catégories de sujet d'activités +Activity Types Categories: Catégories des types d'activité # activity reason admin ActivityReason list: Liste des sujets @@ -99,6 +100,14 @@ ActivityReasonCategory is active and will be proposed: La catégorie est active ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée # activity type admin +ActivityTypeCategory list: Liste des catégories des types d'activité +Create a new activity type category: Créer une nouvelle catégorie de type d'activité +crud: + activity_type_category: + title_new: Nouvelle catégorie de type d'activité + title_edit: Edition d'une catégorie de type d'activité + +# activitycategory type admin ActivityType list: Types d'activités Create a new activity type: Créer un nouveau type d'activité ActivityType creation: Nouveau type d'activité From 580dc712181c12df5390b10c8f5e6066baf9535f Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 1 Apr 2021 16:22:33 +0200 Subject: [PATCH 002/116] ActivityType replace Admin Conroller with Crud system --- .../Controller/ActivityTypeController.php | 178 ------------------ .../AdminActivityTypeCategoryController.php | 2 - .../AdminActivityTypeController.php | 23 +++ .../ChillActivityExtension.php | 21 +++ .../Form/ActivityTypeType.php | 10 +- .../views/ActivityType/edit.html.twig | 46 +---- .../views/ActivityType/index.html.twig | 9 +- .../views/ActivityType/new.html.twig | 43 +---- .../views/ActivityType/show.html.twig | 42 ----- .../ChillActivityBundle/config/routes.yaml | 14 +- .../config/routes/activitytype.yaml | 35 ---- .../translations/messages.fr.yml | 26 +-- 12 files changed, 88 insertions(+), 361 deletions(-) delete mode 100644 src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php create mode 100644 src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php delete mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityType/show.html.twig delete mode 100644 src/Bundle/ChillActivityBundle/config/routes/activitytype.yaml diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php deleted file mode 100644 index f27bea0ae..000000000 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php +++ /dev/null @@ -1,178 +0,0 @@ -getDoctrine()->getManager(); - - $entities = $em->getRepository('ChillActivityBundle:ActivityType')->findAll(); - - return $this->render('ChillActivityBundle:ActivityType:index.html.twig', array( - 'entities' => $entities, - )); - } - /** - * Creates a new ActivityType entity. - * - */ - public function createAction(Request $request) - { - $entity = new ActivityType(); - $form = $this->createCreateForm($entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $em->persist($entity); - $em->flush(); - - return $this->redirect($this->generateUrl('chill_activity_activitytype_show', array('id' => $entity->getId()))); - } - - return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } - - /** - * Creates a form to create a ActivityType entity. - * - * @param ActivityType $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(ActivityType $entity) - { - $form = $this->createForm(ActivityTypeType::class, $entity, array( - 'action' => $this->generateUrl('chill_activity_activitytype_create'), - 'method' => 'POST', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Create')); - - return $form; - } - - /** - * Displays a form to create a new ActivityType entity. - * - */ - public function newAction() - { - $entity = new ActivityType(); - $form = $this->createCreateForm($entity); - - return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } - - /** - * Finds and displays a ActivityType entity. - * - */ - public function showAction($id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - return $this->render('ChillActivityBundle:ActivityType:show.html.twig', array( - 'entity' => $entity, - )); - } - - /** - * Displays a form to edit an existing ActivityType entity. - * - */ - public function editAction($id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - $editForm = $this->createEditForm($entity); - - return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array( - 'entity' => $entity, - 'edit_form' => $editForm->createView() - )); - } - - /** - * Creates a form to edit a ActivityType entity. - * - * @param ActivityType $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(ActivityType $entity) - { - $form = $this->createForm(ActivityTypeType::class, $entity, array( - 'action' => $this->generateUrl('chill_activity_activitytype_update', array('id' => $entity->getId())), - 'method' => 'PUT', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Update')); - - return $form; - } - /** - * Edits an existing ActivityType entity. - * - */ - public function updateAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - $editForm = $this->createEditForm($entity); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $em->flush(); - - return $this->redirect($this->generateUrl('chill_activity_activitytype_edit', array('id' => $id))); - } - - return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array( - 'entity' => $entity, - 'edit_form' => $editForm->createView(), - )); - } -} diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php index 6abc3ac65..149e83d28 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php @@ -1,9 +1,7 @@ orderBy('e.id', 'ASC'); + } +} diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 6007a6267..3107c9705 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -96,6 +96,27 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf { $container->prependExtensionConfig('chill_main', [ 'cruds' => [ + [ + 'class' => \Chill\ActivityBundle\Entity\ActivityType::class, + 'name' => 'activity_type', + 'base_path' => '/admin/activity_type', + 'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class, + 'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillActivity/ActivityType/index.html.twig', + 'role' => 'ROLE_ADMIN' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityType/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityType/edit.html.twig', + ] + ] + ], [ 'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class, 'name' => 'activity_type_category', diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index a402f584c..f241509ef 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -33,15 +33,7 @@ class ActivityTypeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'data_class' => 'Chill\ActivityBundle\Entity\ActivityType' + 'data_class' => \Chill\ActivityBundle\Entity\ActivityType::class )); } - - /** - * @return string - */ - public function getBlockPrefix() - { - return 'chill_activitybundle_activitytype'; - } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig index 99bc71057..dacee767c 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig @@ -1,40 +1,12 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} {% extends "@ChillActivity/Admin/layout_activity.html.twig" %} -{% block admin_content %} -

{{ 'ActivityType edit'|trans }}

- - {{ form_start(edit_form) }} - {{ form_row(edit_form.active) }} - {{ form_row(edit_form.name) }} - - - - - - {{ form_end(edit_form) }} +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig index d9f0cbca6..fd1fd8e29 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig @@ -30,7 +30,7 @@ {% for entity in entities %} - {{ entity.name|localize_translatable_string }} + {{ entity.name|localize_translatable_string }} {%- if entity.active -%} @@ -41,10 +41,7 @@
  • - -
  • -
  • - +
@@ -55,7 +52,7 @@
  • - + {{ 'Create a new activity type'|trans }}
  • diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/new.html.twig index efc294efd..d7ac89752 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/new.html.twig @@ -1,38 +1,11 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} {% extends "@ChillActivity/Admin/layout_activity.html.twig" %} -{% block admin_content %} -

    {{ 'ActivityType creation'|trans }}

    - - {{ form_start(form) }} - {{ form_row(form.active) }} - {{ form_row(form.name) }} - - - {{ form_end(form) }} - +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/show.html.twig deleted file mode 100644 index bce0ed95b..000000000 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/show.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} - -{% block admin_content %} -

    {{ 'ActivityType'|trans }}

    - - - - - - - - -
    {{ 'Name'|trans }}{{ entity.name|localize_translatable_string }}
    - -{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/config/routes.yaml b/src/Bundle/ChillActivityBundle/config/routes.yaml index 4940d8df3..3e1766adf 100644 --- a/src/Bundle/ChillActivityBundle/config/routes.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes.yaml @@ -10,11 +10,6 @@ chill_activity_activityreasoncategory: resource: "@ChillActivityBundle/config/routes/activityreasoncategory.yaml" prefix: / -chill_activity_activitytype: - resource: "@ChillActivityBundle/config/routes/activitytype.yaml" - prefix: / - - chill_admin_activity_index: path: /{_locale}/admin/activity controller: Chill\ActivityBundle\Controller\AdminController::indexActivityAction @@ -34,6 +29,15 @@ chill_admin_activity_redirect_to_admin_index: order: 0 label: Main admin menu +chill_activity_type_admin: + path: /{_locale}/admin/activity/type + controller: cscrud_activity_type_controller:index + options: + menus: + admin_activity: + order: 2020 + label: 'Activity Types' + chill_activity_type_category_admin: path: /{_locale}/admin/activity/type_category controller: cscrud_activity_type_category_controller:index diff --git a/src/Bundle/ChillActivityBundle/config/routes/activitytype.yaml b/src/Bundle/ChillActivityBundle/config/routes/activitytype.yaml deleted file mode 100644 index 2995458f1..000000000 --- a/src/Bundle/ChillActivityBundle/config/routes/activitytype.yaml +++ /dev/null @@ -1,35 +0,0 @@ -chill_activity_activitytype: - path: /{_locale}/admin/activitytype/ - controller: Chill\ActivityBundle\Controller\ActivityTypeController::indexAction - options: - menus: - admin_activity: - order: 2020 - label: "Activity Types" - -chill_activity_activitytype_show: - path: /{_locale}/admin/activitytype/{id}/show - controller: Chill\ActivityBundle\Controller\ActivityTypeController::showAction - -chill_activity_activitytype_new: - path: /{_locale}/admin/activitytype/new - controller: Chill\ActivityBundle\Controller\ActivityTypeController::newAction - -chill_activity_activitytype_create: - path: /{_locale}/admin/activitytype/create - controller: Chill\ActivityBundle\Controller\ActivityTypeController::createAction - methods: POST - -chill_activity_activitytype_edit: - path: /{_locale}/admin/activitytype/{id}/edit - controller: Chill\ActivityBundle\Controller\ActivityTypeController::editAction - -chill_activity_activitytype_update: - path: /{_locale}/admin/activitytype/{id}/update - controller: Chill\ActivityBundle\Controller\ActivityTypeController::updateAction - methods: [POST, PUT] - -chill_activity_activitytype_delete: - path: /{_locale}/admin/activitytype/{id}/delete - controller: Chill\ActivityBundle\Controller\ActivityTypeController::deleteAction - methods: [POST, DELETE] diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index b038269b9..cac24b314 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -79,6 +79,15 @@ Activity Reasons: Sujets d'une activité Activity Reasons Category: Catégories de sujet d'activités Activity Types Categories: Catégories des types d'activité +# Crud +crud: + activity_type: + title_new: Nouveau type d'activité + title_edit: Edition d'un type d'activité + activity_type_category: + title_new: Nouvelle catégorie de type d'activité + title_edit: Edition d'une catégorie de type d'activité + # activity reason admin ActivityReason list: Liste des sujets Create a new activity reason: Créer un nouveau sujet @@ -99,20 +108,13 @@ ActivityReasonCategory: Catégorie de sujet d'activité ActivityReasonCategory is active and will be proposed: La catégorie est active et sera proposée ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée -# activity type admin -ActivityTypeCategory list: Liste des catégories des types d'activité -Create a new activity type category: Créer une nouvelle catégorie de type d'activité -crud: - activity_type_category: - title_new: Nouvelle catégorie de type d'activité - title_edit: Edition d'une catégorie de type d'activité - -# activitycategory type admin +# activity type type admin ActivityType list: Types d'activités Create a new activity type: Créer un nouveau type d'activité -ActivityType creation: Nouveau type d'activité -ActivityType: Type d'activité -ActivityType edit: Modifier une activité + +# activity type category admin +ActivityTypeCategory list: Liste des catégories des types d'activité +Create a new activity type category: Créer une nouvelle catégorie de type d'activité # activity delete Remove activity: Supprimer une activité From 37b395ee5221ec9060ec0fd59cc94cbdcaa38ca8 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 8 Apr 2021 16:10:04 +0200 Subject: [PATCH 003/116] ActivityType add new fields --- .../Entity/ActivityType.php | 518 ++++++++++++++++-- .../Entity/ActivityTypeCategory.php | 2 - .../Form/ActivityTypeType.php | 43 +- .../Form/Type/ActivityFieldPresence.php | 29 + .../config/services/form.yaml | 13 +- .../migrations/Version20210408122329.php | 93 ++++ 6 files changed, 658 insertions(+), 40 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Form/Type/ActivityFieldPresence.php create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210408122329.php diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 25854d385..ca492fbf4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -1,19 +1,19 @@ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ @@ -32,6 +32,10 @@ use Doctrine\ORM\Mapping as ORM; */ class ActivityType { + const FIELD_INVISIBLE = 0; + const FIELD_OPTIONAL = 1; + const FIELD_REQUIRED = 2; + /** * @var integer * @@ -39,38 +43,185 @@ class ActivityType * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id; /** - * @var array * @ORM\Column(type="json_array") */ - private $name; - + private array $name = []; + /** - * @var bool * @ORM\Column(type="boolean") */ - private $active = true; + private bool $active = true; + /** + * ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityTypeCategory") + */ + private ?ActivityTypeCategory $category = null; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=2}) + */ + private int $personVisible = self::FIELD_REQUIRED; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $personLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=2}) + */ + private int $userVisible = self::FIELD_REQUIRED; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $userLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=2}) + */ + private int $dateVisible = self::FIELD_REQUIRED; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $dateLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $placeVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $placeLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $personsVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $personsLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $thirdpartyVisible = self::FIELD_INVISIBLE; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $thirdpartyLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $durationTimeVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $durationTimeLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $attendeeVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $attendeeLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $reasonsVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $reasonsLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $commentVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $commentLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $sentReceivedVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $sentReceivedLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $documentVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $documentLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $emergencyVisible = self::FIELD_INVISIBLE; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $emergencyLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $accompanyingPeriodLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $socialDataVisible = self::FIELD_INVISIBLE; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $socialDataLabel = ''; /** * Get id - * - * @return integer */ - public function getId() + public function getId(): int { return $this->id; } /** * Set name - * - * @param array $name - * @return ActivityType */ - public function setName($name) + public function setName(string $name): self { $this->name = $name; @@ -82,7 +233,7 @@ class ActivityType * * @return array | string */ - public function getName($locale = null) + public function getName(?string $locale = null) { if ($locale) { if (isset($this->name[$locale])) { @@ -99,38 +250,343 @@ class ActivityType return $this->name; } } - + /** * Get active * return true if the type is active. - * - * @return boolean */ - public function getActive() { + public function getActive(): bool + { return $this->active; } - + /** * Is active * return true if the type is active - * - * @return boolean */ - public function isActive() { + public function isActive(): bool + { return $this->getActive(); } /** * Set active * set to true if the type is active - * - * @param boolean $active - * @return ActivityType */ - public function setActive($active) { + public function setActive(bool $active): self + { $this->active = $active; + return $this; } -} + public function getCategory(): ?ActivityTypeCategory + { + return $this->category; + } + public function setCategory(?ActivityTypeCategory $category): void + { + $this->category = $category; + } + + public function getPersonVisible(): int + { + return $this->personVisible; + } + + public function setPersonVisible(int $personVisible): void + { + $this->personVisible = $personVisible; + } + + public function getPersonLabel(): string + { + return $this->personLabel; + } + + public function setPersonLabel(string $personLabel): void + { + $this->personLabel = $personLabel; + } + + public function getUserVisible(): int + { + return $this->userVisible; + } + + public function setUserVisible(int $userVisible): void + { + $this->userVisible = $userVisible; + } + + public function getUserLabel(): string + { + return $this->userLabel; + } + + public function setUserLabel(string $userLabel): void + { + $this->userLabel = $userLabel; + } + + public function getDateVisible(): int + { + return $this->dateVisible; + } + + public function setDateVisible(int $dateVisible): void + { + $this->dateVisible = $dateVisible; + } + + public function getDateLabel(): string + { + return $this->dateLabel; + } + + public function setDateLabel(string $dateLabel): void + { + $this->dateLabel = $dateLabel; + } + + public function getPlaceVisible(): int + { + return $this->placeVisible; + } + + public function setPlaceVisible(int $placeVisible): void + { + $this->placeVisible = $placeVisible; + } + + public function getPlaceLabel(): string + { + return $this->placeLabel; + } + + public function setPlaceLabel(string $placeLabel): void + { + $this->placeLabel = $placeLabel; + } + + public function getPersonsVisible(): int + { + return $this->personsVisible; + } + + public function setPersonsVisible(int $personsVisible): void + { + $this->personsVisible = $personsVisible; + } + + public function getPersonsLabel(): string + { + return $this->personsLabel; + } + + public function setPersonsLabel(string $personsLabel): void + { + $this->personsLabel = $personsLabel; + } + + public function getThirdpartyVisible(): int + { + return $this->thirdpartyVisible; + } + + public function setThirdpartyVisible(int $thirdpartyVisible): void + { + $this->thirdpartyVisible = $thirdpartyVisible; + } + + public function getThirdpartyLabel(): string + { + return $this->thirdpartyLabel; + } + + public function setThirdpartyLabel(string $thirdpartyLabel): void + { + $this->thirdpartyLabel = $thirdpartyLabel; + } + + public function getDurationTimeVisible(): int + { + return $this->durationTimeVisible; + } + + public function setDurationTimeVisible(int $durationTimeVisible): void + { + $this->durationTimeVisible = $durationTimeVisible; + } + + public function getDurationTimeLabel(): string + { + return $this->durationTimeLabel; + } + + public function setDurationTimeLabel(string $durationTimeLabel): void + { + $this->durationTimeLabel = $durationTimeLabel; + } + + public function getAttendeeVisible(): int + { + return $this->attendeeVisible; + } + + public function setAttendeeVisible(int $attendeeVisible): void + { + $this->attendeeVisible = $attendeeVisible; + } + + public function getAttendeeLabel(): string + { + return $this->attendeeLabel; + } + + public function setAttendeeLabel(string $attendeeLabel): void + { + $this->attendeeLabel = $attendeeLabel; + } + + public function getReasonsVisible(): int + { + return $this->reasonsVisible; + } + + public function setReasonsVisible(int $reasonsVisible): void + { + $this->reasonsVisible = $reasonsVisible; + } + + public function getReasonsLabel(): string + { + return $this->reasonsLabel; + } + + public function setReasonsLabel(string $reasonsLabel): void + { + $this->reasonsLabel = $reasonsLabel; + } + + public function getCommentVisible(): int + { + return $this->commentVisible; + } + + public function setCommentVisible(int $commentVisible): void + { + $this->commentVisible = $commentVisible; + } + + public function getCommentLabel(): string + { + return $this->commentLabel; + } + + public function setCommentLabel(string $commentLabel): void + { + $this->commentLabel = $commentLabel; + } + + public function getSentReceivedVisible(): int + { + return $this->sentReceivedVisible; + } + + public function setSentReceivedVisible(int $sentReceivedVisible): void + { + $this->sentReceivedVisible = $sentReceivedVisible; + } + + public function getSentReceivedLabel(): string + { + return $this->sentReceivedLabel; + } + + public function setSentReceivedLabel(string $sentReceivedLabel): void + { + $this->sentReceivedLabel = $sentReceivedLabel; + } + + public function getDocumentVisible(): int + { + return $this->documentVisible; + } + + public function setDocumentVisible(int $documentVisible): void + { + $this->documentVisible = $documentVisible; + } + + public function getDocumentLabel(): string + { + return $this->documentLabel; + } + + public function setDocumentLabel(string $documentLabel): void + { + $this->documentLabel = $documentLabel; + } + + public function getEmergencyVisible(): int + { + return $this->emergencyVisible; + } + + public function setEmergencyVisible(int $emergencyVisible): void + { + $this->emergencyVisible = $emergencyVisible; + } + + public function getEmergencyLabel(): string + { + return $this->emergencyLabel; + } + + public function setEmergencyLabel(string $emergencyLabel): void + { + $this->emergencyLabel = $emergencyLabel; + } + + public function getAccompanyingPeriodVisible(): int + { + return $this->accompanyingPeriodVisible; + } + + public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): void + { + $this->accompanyingPeriodVisible = $accompanyingPeriodVisible; + } + + public function getAccompanyingPeriodLabel(): string + { + return $this->accompanyingPeriodLabel; + } + + public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): void + { + $this->accompanyingPeriodLabel = $accompanyingPeriodLabel; + } + + public function getSocialDataVisible(): int + { + return $this->socialDataVisible; + } + + public function setSocialDataVisible(int $socialDataVisible): void + { + $this->socialDataVisible = $socialDataVisible; + } + + public function getSocialDataLabel(): string + { + return $this->socialDataLabel; + } + + public function setSocialDataLabel(string $socialDataLabel): void + { + $this->socialDataLabel = $socialDataLabel; + } +} diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index 006a50c28..eaf347cb4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -51,8 +51,6 @@ class ActivityTypeCategory /** * Get id - * - * @return integer */ public function getId(): int { diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index f241509ef..bf587c5d8 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -2,7 +2,12 @@ namespace Chill\ActivityBundle\Form; +use Chill\ActivityBundle\Entity\ActivityTypeCategory; +use Chill\ActivityBundle\Form\Type\ActivityFieldPresence; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -10,6 +15,13 @@ use Chill\MainBundle\Form\Type\TranslatableStringFormType; class ActivityTypeType extends AbstractType { + private TranslatableStringHelper $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) + { + $this->translatableStringHelper = $translatableStringHelper; + } + /** * @param FormBuilderInterface $builder * @param array $options @@ -18,13 +30,36 @@ class ActivityTypeType extends AbstractType { $builder ->add('name', TranslatableStringFormType::class) - ->add('active', ChoiceType::class, array( - 'choices' => array( + ->add('active', ChoiceType::class, [ + 'choices' => [ 'Yes' => true, 'No' => false - ), + ], 'expanded' => true - )); + ]) + ->add('category', EntityType::class, [ + 'class' => ActivityTypeCategory::class, + 'choice_label' => function (ActivityTypeCategory $activityTypeCategory) { + return $this->translatableStringHelper->localize($activityTypeCategory->getName()); + }, + ]) + ; + + $fields = [ + 'person', 'user', 'date', 'place', 'persons', + 'thirdparty', 'durationTime', 'attendee', + 'reasons', 'comment', 'sentReceived', 'document', + 'emergency', 'accompanyingPeriod', 'socialData' + ]; + + foreach ($fields as $field) { + $builder + ->add($field.'Visible', ActivityFieldPresence::class) + ->add($field.'Label', TextType::class, [ + 'required' => false, + 'empty_data' => '', + ]); + } } /** diff --git a/src/Bundle/ChillActivityBundle/Form/Type/ActivityFieldPresence.php b/src/Bundle/ChillActivityBundle/Form/Type/ActivityFieldPresence.php new file mode 100644 index 000000000..8de67b546 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Form/Type/ActivityFieldPresence.php @@ -0,0 +1,29 @@ +setDefaults( + array( + 'choices' => [ + 'Invisible' => ActivityType::FIELD_INVISIBLE, + 'Optional' => ActivityType::FIELD_OPTIONAL, + 'Required' => ActivityType::FIELD_REQUIRED, + ], + ) + ); + } +} diff --git a/src/Bundle/ChillActivityBundle/config/services/form.yaml b/src/Bundle/ChillActivityBundle/config/services/form.yaml index e9f81c14e..106ee5cf8 100644 --- a/src/Bundle/ChillActivityBundle/config/services/form.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/form.yaml @@ -6,7 +6,7 @@ services: - "@request_stack" tags: - { name: form.type, alias: translatable_activity_reason_category } - + chill.activity.form.type.translatableactivityreason: class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason arguments: @@ -14,7 +14,7 @@ services: $reasonRender: '@Chill\ActivityBundle\Templating\Entity\ActivityReasonRender' tags: - { name: form.type, alias: translatable_activity_reason } - + chill.activity.form.type.translatableactivitytype: class: Chill\ActivityBundle\Form\Type\TranslatableActivityType arguments: @@ -22,7 +22,7 @@ services: - "@chill_activity.repository.activity_type" tags: - { name: form.type, alias: translatable_activity_type } - + chill.activity.form.type.activity: class: Chill\ActivityBundle\Form\ActivityType arguments: @@ -33,3 +33,10 @@ services: - "%chill_activity.form.time_duration%" tags: - { name: form.type, alias: chill_activitybundle_activity } + + chill.activity.form.type.activityTypeType: + class: Chill\ActivityBundle\Form\ActivityTypeType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type, alias: translatable_activity_type } diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210408122329.php b/src/Bundle/ChillActivityBundle/migrations/Version20210408122329.php new file mode 100644 index 000000000..53a5219bd --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210408122329.php @@ -0,0 +1,93 @@ +addSql('ALTER TABLE activitytype ADD personVisible SMALLINT DEFAULT 2 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD personLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD userVisible SMALLINT DEFAULT 2 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD userLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD dateVisible SMALLINT DEFAULT 2 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD dateLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD placeVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD placeLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD personsVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD personsLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD thirdpartyVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD thirdpartyLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD durationTimeVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD durationTimeLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD attendeeVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD attendeeLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD reasonsVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD reasonsLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD commentVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD commentLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD sentReceivedVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD sentReceivedLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD emergencyVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD emergencyLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD accompanyingPeriodVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD accompanyingPeriodLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD socialDataVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD socialDataLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ALTER name SET NOT NULL'); + $this->addSql('ALTER TABLE activitytype ALTER active DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN activitytype.name IS \'(DC2Type:json_array)\''); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activitytype DROP personVisible'); + $this->addSql('ALTER TABLE activitytype DROP personLabel'); + $this->addSql('ALTER TABLE activitytype DROP userVisible'); + $this->addSql('ALTER TABLE activitytype DROP userLabel'); + $this->addSql('ALTER TABLE activitytype DROP dateVisible'); + $this->addSql('ALTER TABLE activitytype DROP dateLabel'); + $this->addSql('ALTER TABLE activitytype DROP placeVisible'); + $this->addSql('ALTER TABLE activitytype DROP placeLabel'); + $this->addSql('ALTER TABLE activitytype DROP personsVisible'); + $this->addSql('ALTER TABLE activitytype DROP personsLabel'); + $this->addSql('ALTER TABLE activitytype DROP thirdpartyVisible'); + $this->addSql('ALTER TABLE activitytype DROP thirdpartyLabel'); + $this->addSql('ALTER TABLE activitytype DROP durationTimeVisible'); + $this->addSql('ALTER TABLE activitytype DROP durationTimeLabel'); + $this->addSql('ALTER TABLE activitytype DROP attendeeVisible'); + $this->addSql('ALTER TABLE activitytype DROP attendeeLabel'); + $this->addSql('ALTER TABLE activitytype DROP reasonsVisible'); + $this->addSql('ALTER TABLE activitytype DROP reasonsLabel'); + $this->addSql('ALTER TABLE activitytype DROP commentVisible'); + $this->addSql('ALTER TABLE activitytype DROP commentLabel'); + $this->addSql('ALTER TABLE activitytype DROP sentReceivedVisible'); + $this->addSql('ALTER TABLE activitytype DROP sentReceivedLabel'); + $this->addSql('ALTER TABLE activitytype DROP documentVisible'); + $this->addSql('ALTER TABLE activitytype DROP documentLabel'); + $this->addSql('ALTER TABLE activitytype DROP emergencyVisible'); + $this->addSql('ALTER TABLE activitytype DROP emergencyLabel'); + $this->addSql('ALTER TABLE activitytype DROP accompanyingPeriodVisible'); + $this->addSql('ALTER TABLE activitytype DROP accompanyingPeriodLabel'); + $this->addSql('ALTER TABLE activitytype DROP socialDataVisible'); + $this->addSql('ALTER TABLE activitytype DROP socialDataLabel'); + $this->addSql('ALTER TABLE activitytype ALTER name DROP NOT NULL'); + $this->addSql('ALTER TABLE activitytype ALTER active SET DEFAULT \'true\''); + $this->addSql('COMMENT ON COLUMN activitytype.name IS NULL'); + } +} From dad8fd5378558f45d7e78493a1f08cc960e1d04c Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 8 Apr 2021 16:19:54 +0200 Subject: [PATCH 004/116] ActivityType add new fields : add translations --- src/Bundle/ChillActivityBundle/translations/messages.fr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index cac24b314..cc323f392 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -29,6 +29,9 @@ person_firstname: prénom person_lastname: nom de famille person_id: identifiant de la personne Type: Type +Invisible: Invisible +Optional: Optionnel +Required: Obligatoire #forms Activity creation: Nouvelle activité @@ -51,7 +54,6 @@ Choose a type: Choisir un type 1 hour 45: 1 heure 45 2 hours: 2 heures - #timeline '%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"' From ff450215c6a8c9d96a1246ff1ac34aaa87bd7722 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 15 Apr 2021 13:08:30 +0200 Subject: [PATCH 005/116] Add first step to select Activity Type --- .../Controller/ActivityController.php | 70 ++++++++++++++----- .../Entity/ActivityType.php | 1 + .../Entity/ActivityTypeCategory.php | 17 +---- .../Form/ActivitySelectTypeType.php | 19 +++++ .../ChillActivityBundle/Form/ActivityType.php | 8 +-- .../Resources/views/Activity/new.html.twig | 9 ++- .../views/Activity/selectType.html.twig | 19 +++++ .../config/routes/activity.yaml | 4 ++ 8 files changed, 101 insertions(+), 46 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 3b5517a70..58d7e68ea 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -22,6 +22,7 @@ namespace Chill\ActivityBundle\Controller; +use Chill\ActivityBundle\Form\ActivitySelectTypeType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; @@ -29,9 +30,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Role\Role; use Chill\ActivityBundle\Entity\Activity; -use Chill\PersonBundle\Entity\Person; use Chill\ActivityBundle\Form\ActivityType; /** @@ -41,27 +42,18 @@ use Chill\ActivityBundle\Form\ActivityType; */ class ActivityController extends AbstractController { + protected EventDispatcherInterface $eventDispatcher; - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; + protected AuthorizationHelper $authorizationHelper; - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var LoggerInterface - */ - protected $logger; + protected LoggerInterface $logger; /** * ActivityController constructor. * * @param EventDispatcherInterface $eventDispatcher * @param AuthorizationHelper $authorizationHelper + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( EventDispatcherInterface $eventDispatcher, @@ -89,7 +81,7 @@ class ActivityController extends AbstractController $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $reachableScopes = $this->authorizationHelper - ->getReachableScopes($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), + ->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), $person->getCenter()); $activities = $em->getRepository('ChillActivityBundle:Activity') @@ -109,6 +101,35 @@ class ActivityController extends AbstractController 'person' => $person )); } + + public function selectTypeAction(int $person_id, Request $request): Response + { + $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('Person not found'); + } + + $form = $this->createForm(ActivitySelectTypeType::class); + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $activityType = $form->get('type')->getData(); + if ($activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) { + return $this->redirectToRoute('chill_activity_activity_new', [ + 'person_id' => $person->getId(), + 'activityType_id' => $activityType->getId(), + ]); + } + } + + return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ + 'form' => $form->createView(), + 'person' => $person + ]); + } + /** * Creates a new Activity entity. * @@ -126,7 +147,7 @@ class ActivityController extends AbstractController $entity = new Activity(); $entity->setPerson($person); - $form = $this->createCreateForm($entity, $person); + $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { @@ -190,7 +211,7 @@ class ActivityController extends AbstractController * Displays a form to create a new Activity entity. * */ - public function newAction($person_id) + public function newAction($person_id, Request $request) { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -199,16 +220,27 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Person not found'); } + $activityType_id = $request->get('activityType_id', 0); + $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) + ->find($activityType_id); + + if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) { + return $this->redirectToRoute('chill_activity_activity_select_type', [ + 'person_id' => $person->getId(), + ]); + } + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $entity = new Activity(); - $entity->setUser($this->get('security.token_storage')->getToken()->getUser()); + $entity->setUser($this->getUser()); $entity->setPerson($person); + $entity->setType($activityType); $entity->setDate(new \DateTime('now')); $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); - $form = $this->createCreateForm($entity, $person); + $form = $this->createCreateForm($entity); return $this->render('ChillActivityBundle:Activity:new.html.twig', array( 'person' => $person, diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index ca492fbf4..7dc2fbaa9 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -235,6 +235,7 @@ class ActivityType */ public function getName(?string $locale = null) { + // TODO if ($locale) { if (isset($this->name[$locale])) { return $this->name[$locale]; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index eaf347cb4..82d96b93e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -72,22 +72,9 @@ class ActivityTypeCategory * * @return array | string */ - public function getName(?string $locale = null) + public function getName(): array { - if ($locale) { - if (isset($this->name[$locale])) { - return $this->name[$locale]; - } else { - foreach ($this->name as $name) { - if (!empty($name)) { - return $name; - } - } - } - return ''; - } else { - return $this->name; - } + return $this->name; } /** diff --git a/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php new file mode 100644 index 000000000..c637e5bcc --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php @@ -0,0 +1,19 @@ +add('type', TranslatableActivityType::class, array( + 'placeholder' => 'Choose a type', + 'active_only' => true, + 'mapped' => false, + )); + } +} diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index ad0e55aa7..eb63b6beb 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Chill\ActivityBundle\Form\Type\TranslatableActivityType; use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; use Chill\MainBundle\Form\Type\UserPickerType; @@ -24,7 +23,6 @@ use Chill\MainBundle\Form\Type\ChillDateType; class ActivityType extends AbstractType { - /** * the user running this form * @@ -36,7 +34,7 @@ class ActivityType extends AbstractType * * @var AuthorizationHelper */ - protected $authorizationHelper; + protected AuthorizationHelper $authorizationHelper; /** * @@ -113,10 +111,6 @@ class ActivityType extends AbstractType 'multiple' => true, 'required' => false, )) - ->add('type', TranslatableActivityType::class, array( - 'placeholder' => 'Choose a type', - 'active_only' => true - )) ->add('comment', CommentType::class, [ 'required' => false, ]) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index e069bfce3..24c659a56 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -21,7 +21,7 @@ {% block title 'Activity creation' |trans %} {% block personcontent %} -

    {{ "Activity creation"|trans }}

    +

    {{ "Activity creation"|trans }}

    {{ form_start(form) }} @@ -32,14 +32,13 @@ {{ form_row(form.date) }} {{ form_row(form.durationTime) }} - {{ form_row(form.type) }} {{ form_row(form.attendee) }} {{ form_row(form.reasons) }} {{ form_row(form.comment) }} -
    - -
    +
    + +
    {{ form_end(form) }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig new file mode 100644 index 000000000..e6ab83482 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -0,0 +1,19 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation'|trans %} + +{% block personcontent %} +

    {{ "Activity creation"|trans }}

    + + {{ form_start(form) }} + + {{ form_row(form.type) }} + +
    + +
    + + {{ form_end(form) }} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml index a320bb2ac..342ccf7d3 100644 --- a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml @@ -6,6 +6,10 @@ chill_activity_activity_show: path: /{_locale}/person/{person_id}/activity/{id}/show controller: Chill\ActivityBundle\Controller\ActivityController::showAction +chill_activity_activity_select_type: + path: /{_locale}/person/{person_id}/activity/select-type + controller: Chill\ActivityBundle\Controller\ActivityController::selectTypeAction + chill_activity_activity_new: path: /{_locale}/person/{person_id}/activity/new controller: Chill\ActivityBundle\Controller\ActivityController::newAction From cb5cf5763ef0524fd382659bf3c28cda820fc3c9 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 15 Apr 2021 13:56:39 +0200 Subject: [PATCH 006/116] ActivityType : rename some fields --- .../Entity/ActivityType.php | 63 +++++++------------ .../Form/ActivityTypeType.php | 14 +---- .../migrations/Version20210415113216.php | 43 +++++++++++++ 3 files changed, 70 insertions(+), 50 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210415113216.php diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index ca492fbf4..7f909db3f 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -43,7 +43,7 @@ class ActivityType * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private ?int $id; + private ?int $id; /** * @ORM\Column(type="json_array") @@ -113,12 +113,12 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) */ - private int $thirdpartyVisible = self::FIELD_INVISIBLE; + private int $thirdPartiesVisible = self::FIELD_INVISIBLE; /** * @ORM\Column(type="string", nullable=false, options={"default"=""}) */ - private string $thirdpartyLabel = ''; + private string $thirdPartiesLabel = ''; /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) @@ -173,12 +173,12 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) */ - private int $documentVisible = self::FIELD_OPTIONAL; + private int $documentsVisible = self::FIELD_OPTIONAL; /** * @ORM\Column(type="string", nullable=false, options={"default"=""}) */ - private string $documentLabel = ''; + private string $documentsLabel = ''; /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) @@ -221,7 +221,7 @@ class ActivityType /** * Set name */ - public function setName(string $name): self + public function setName(array $name): self { $this->name = $name; @@ -230,25 +230,10 @@ class ActivityType /** * Get name - * - * @return array | string */ - public function getName(?string $locale = null) + public function getName(): array { - if ($locale) { - if (isset($this->name[$locale])) { - return $this->name[$locale]; - } else { - foreach ($this->name as $name) { - if (!empty($name)) { - return $name; - } - } - } - return ''; - } else { - return $this->name; - } + return $this->name; } /** @@ -390,24 +375,24 @@ class ActivityType $this->personsLabel = $personsLabel; } - public function getThirdpartyVisible(): int + public function getThirdPartiesVisible(): int { - return $this->thirdpartyVisible; + return $this->thirdPartiesVisible; } - public function setThirdpartyVisible(int $thirdpartyVisible): void + public function setThirdPartiesVisible(int $thirdPartiesVisible): void { - $this->thirdpartyVisible = $thirdpartyVisible; + $this->thirdPartiesVisible = $thirdPartiesVisible; } - public function getThirdpartyLabel(): string + public function getThirdPartiesLabel(): string { - return $this->thirdpartyLabel; + return $this->thirdPartiesLabel; } - public function setThirdpartyLabel(string $thirdpartyLabel): void + public function setThirdPartiesLabel(string $thirdPartiesLabel): void { - $this->thirdpartyLabel = $thirdpartyLabel; + $this->thirdPartiesLabel = $thirdPartiesLabel; } public function getDurationTimeVisible(): int @@ -510,24 +495,24 @@ class ActivityType $this->sentReceivedLabel = $sentReceivedLabel; } - public function getDocumentVisible(): int + public function getDocumentsVisible(): int { - return $this->documentVisible; + return $this->documentsVisible; } - public function setDocumentVisible(int $documentVisible): void + public function setDocumentsVisible(int $documentsVisible): void { - $this->documentVisible = $documentVisible; + $this->documentsVisible = $documentsVisible; } - public function getDocumentLabel(): string + public function getDocumentsLabel(): string { - return $this->documentLabel; + return $this->documentsLabel; } - public function setDocumentLabel(string $documentLabel): void + public function setDocumentsLabel(string $documentsLabel): void { - $this->documentLabel = $documentLabel; + $this->documentsLabel = $documentsLabel; } public function getEmergencyVisible(): int diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index bf587c5d8..028cbc307 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -22,10 +22,6 @@ class ActivityTypeType extends AbstractType $this->translatableStringHelper = $translatableStringHelper; } - /** - * @param FormBuilderInterface $builder - * @param array $options - */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder @@ -46,12 +42,11 @@ class ActivityTypeType extends AbstractType ; $fields = [ - 'person', 'user', 'date', 'place', 'persons', - 'thirdparty', 'durationTime', 'attendee', - 'reasons', 'comment', 'sentReceived', 'document', + 'persons', 'user', 'date', 'place', 'persons', + 'thirdParties', 'durationTime', 'attendee', + 'reasons', 'comment', 'sentReceived', 'documents', 'emergency', 'accompanyingPeriod', 'socialData' ]; - foreach ($fields as $field) { $builder ->add($field.'Visible', ActivityFieldPresence::class) @@ -62,9 +57,6 @@ class ActivityTypeType extends AbstractType } } - /** - * @param OptionsResolverInterface $resolver - */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210415113216.php b/src/Bundle/ChillActivityBundle/migrations/Version20210415113216.php new file mode 100644 index 000000000..6cf9c2923 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210415113216.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE activitytype ADD thirdPartiesVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD thirdPartiesLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentsVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentsLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype DROP thirdpartyvisible'); + $this->addSql('ALTER TABLE activitytype DROP thirdpartylabel'); + $this->addSql('ALTER TABLE activitytype DROP documentvisible'); + $this->addSql('ALTER TABLE activitytype DROP documentlabel'); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activitytype ADD thirdpartyvisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD thirdpartylabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentvisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD documentlabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype DROP thirdPartiesVisible'); + $this->addSql('ALTER TABLE activitytype DROP thirdPartiesLabel'); + $this->addSql('ALTER TABLE activitytype DROP documentsVisible'); + $this->addSql('ALTER TABLE activitytype DROP documentsLabel'); + } +} From 8acd8520707c9ca38e912047e21f65dbc0a63be5 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 15 Apr 2021 14:45:52 +0200 Subject: [PATCH 007/116] Fix uls --- .../DependencyInjection/ChillActivityExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 3107c9705..3fdf4a726 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -99,7 +99,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf [ 'class' => \Chill\ActivityBundle\Entity\ActivityType::class, 'name' => 'activity_type', - 'base_path' => '/admin/activity_type', + 'base_path' => '/admin/activity/type', 'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class, 'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class, 'actions' => [ @@ -120,7 +120,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf [ 'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class, 'name' => 'activity_type_category', - 'base_path' => '/admin/activity_type_category', + 'base_path' => '/admin/activity/type_category', 'form_class' => \Chill\ActivityBundle\Form\ActivityTypeCategoryType::class, 'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeCategoryController::class, 'actions' => [ From c233c481b6cfd9e82ce1549b2cabb76a399e3d78 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 15 Apr 2021 17:33:41 +0200 Subject: [PATCH 008/116] WIP Activity Model --- .../AdminActivityPresenceController.php | 23 ++ .../ChillActivityExtension.php | 23 +- .../ChillActivityBundle/Entity/Activity.php | 245 +++++++++++------- .../Entity/ActivityPresence.php | 103 ++++++++ .../Entity/ActivityType.php | 2 - .../Entity/ActivityTypeCategory.php | 19 +- .../Form/ActivityPresenceType.php | 33 +++ .../views/ActivityPresence/edit.html.twig | 12 + .../views/ActivityPresence/index.html.twig | 44 ++++ .../views/ActivityPresence/new.html.twig | 11 + .../ChillActivityBundle/config/routes.yaml | 9 + 11 files changed, 407 insertions(+), 117 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php create mode 100644 src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php create mode 100644 src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/edit.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/index.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/new.html.twig diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php new file mode 100644 index 000000000..a100c3f5d --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php @@ -0,0 +1,23 @@ +orderBy('e.id', 'ASC'); + } +} diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 3fdf4a726..d459da0e3 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -137,7 +137,28 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf 'template' => '@ChillActivity/ActivityTypeCategory/edit.html.twig', ] ] - ] + ], + [ + 'class' => \Chill\ActivityBundle\Entity\ActivityPresence::class, + 'name' => 'activity_presence', + 'base_path' => '/admin/activity/presence', + 'form_class' => \Chill\ActivityBundle\Form\ActivityPresenceType::class, + 'controller' => \Chill\ActivityBundle\Controller\AdminActivityPresenceController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillActivity/ActivityPresence/index.html.twig', + 'role' => 'ROLE_ADMIN' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityPresence/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityPresence/edit.html.twig', + ] + ] + ], ] ]); } diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index e96db03db..e1341787f 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -20,13 +20,13 @@ namespace Chill\ActivityBundle\Entity; +use Chill\DocStoreBundle\Entity\Document; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; +use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Center; -use Chill\ActivityBundle\Entity\ActivityReason; -use Chill\ActivityBundle\Entity\ActivityType; use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; @@ -49,93 +49,98 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; class Activity implements HasCenterInterface, HasScopeInterface { /** - * @var integer - * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id; /** - * @var User * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ - private $user; + private User $user; /** - * @var \DateTime * @ORM\Column(type="datetime") */ - private $date; + private \DateTime $date; /** - * @var \DateTime * @ORM\Column(type="time") */ - private $durationTime; + private \DateTime $durationTime; /** - * @var boolean * @ORM\Column(type="boolean") */ - private $attendee; + private bool $attendee; /** - * @var ActivityReason * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") */ - private $reasons; + private Collection $reasons; /** - * @var ActivityType * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") */ - private $type; + private ActivityType $type; /** - * @var Scope * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ - private $scope; + private Scope $scope; /** - * @var Person * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ - private $person; + private Person $person; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") */ - private $comment; + private CommentEmbeddable $comment; /** - * Activity constructor. + * @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\Person", mappedBy="person") */ + private ArrayCollection $persons; + + /** + * @ORM\OneToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", mappedBy="thirdParty") + */ + private ArrayCollection $thirdParties; + + /** + * @ORM\OneToMany(targetEntity="Chill\DocStoreBundle\Entity\Document", mappedBy="document") + */ + private ArrayCollection $documents; + + /** + * @ORM\Column(type="boolean") + */ + private bool $emergency = false; + public function __construct() { $this->reasons = new ArrayCollection(); $this->comment = new CommentEmbeddable(); + $this->persons = new ArrayCollection(); + $this->thirdParties = new ArrayCollection(); + $this->documents = new ArrayCollection(); } /** * Get id - * - * @return integer */ - public function getId() + public function getId(): int { return $this->id; } /** * Set user - * - * @param User $user - * @return Activity */ - public function setUser(User $user) + public function setUser(User $user): self { $this->user = $user; @@ -144,21 +149,16 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get user - * - * @return User */ - public function getUser() + public function getUser(): User { return $this->user; } /** * Set date - * - * @param \DateTime $date - * @return Activity */ - public function setDate($date) + public function setDate(\DateTime $date): self { $this->date = $date; @@ -167,21 +167,16 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get date - * - * @return \DateTime */ - public function getDate() + public function getDate(): \DateTime { return $this->date; } /** * Set durationTime - * - * @param \DateTime $durationTime - * @return Activity */ - public function setDurationTime($durationTime) + public function setDurationTime(\DateTime $durationTime): self { $this->durationTime = $durationTime; @@ -190,21 +185,16 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get durationTime - * - * @return \DateTime */ - public function getDurationTime() + public function getDurationTime(): \DateTime { return $this->durationTime; } /** * Set attendee - * - * @param boolean $attendee - * @return Activity */ - public function setAttendee($attendee) + public function setAttendee(bool $attendee): self { $this->attendee = $attendee; @@ -213,52 +203,39 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get attendee - * - * @return boolean */ - public function getAttendee() + public function getAttendee(): bool { return $this->attendee; } /** * Add a reason - * - * @param ActivityReason $reason - * @return Activity */ - public function addReason(ActivityReason $reason) + public function addReason(ActivityReason $reason): self { $this->reasons[] = $reason; return $this; } - /** - * @param ActivityReason $reason - */ - public function removeReason(ActivityReason $reason) + public function removeReason(ActivityReason $reason): void { $this->reasons->removeElement($reason); } /** * Get reasons - * - * @return Collection */ - public function getReasons() + public function getReasons(): ArrayCollection { return $this->reasons; } /** * Set type - * - * @param ActivityType $type - * @return Activity */ - public function setType(ActivityType $type) + public function setType(ActivityType $type): self { $this->type = $type; @@ -267,21 +244,16 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get type - * - * @return ActivityType */ - public function getType() + public function getType(): ActivityType { return $this->type; } /** * Set scope - * - * @param Scope $scope - * @return Activity */ - public function setScope(Scope $scope) + public function setScope(Scope $scope): self { $this->scope = $scope; @@ -290,21 +262,16 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get scope - * - * @return Scope */ - public function getScope() + public function getScope(): Scope { return $this->scope; } /** * Set person - * - * @param Person $person - * @return Activity */ - public function setPerson(Person $person) + public function setPerson(Person $person): self { $this->person = $person; @@ -313,10 +280,8 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get person - * - * @return Person */ - public function getPerson() + public function getPerson(): Person { return $this->person; } @@ -324,28 +289,114 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * get the center * center is extracted from person - * - * @return Center */ - public function getCenter() + public function getCenter(): Center { return $this->person->getCenter(); } - /** - * @return \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable - */ - public function getComment() + public function getComment(): CommentEmbeddable { return $this->comment; } - /** - * @param \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable $comment - */ - public function setComment($comment) + public function setComment(CommentEmbeddable $comment): self { $this->comment = $comment; + + return $this; + } + + /** + * Add a person to the person list + */ + public function addPerson(Person $person): self + { + $this->persons[] = $person; + + return $this; + } + + public function removePerson(Person $person): void + { + $this->persons->removeElement($person); + } + + public function getPersons(): ArrayCollection + { + return $this->persons; + } + + public function setPersons(ArrayCollection $persons): self + { + $this->persons = $persons; + + return $this; + } + + public function addThirdParty(ThirdParty $thirdParty): self + { + $this->thirdParties[] = $thirdParty; + + return $this; + } + + public function removeThirdParty(ThirdParty $thirdParty): void + { + $this->thirdParties->removeElement($thirdParty); + } + + public function getThirdParties(): ArrayCollection + { + return $this->thirdParties; + } + + public function setThirdParties(ArrayCollection $thirdParties): self + { + $this->thirdParties = $thirdParties; + + return $this; + } + + public function addDocument(Document $document): self + { + $this->documents[] = $document; + + return $this; + } + + public function removeDocument(Document $document): void + { + $this->documents->removeElement($document); + } + + public function getDocuments(): ArrayCollection + { + return $this->documents; + } + + public function setDocuments(ArrayCollection $documents): self + { + $this->documents = $documents; + + return $this; + } + + public function isEmergency(): bool + { + return $this->getEmergency(); + } + + public function getEmergency(): bool + { + return $this->emergency; + } + + public function setEmergency(bool $emergency): self + { + $this->emergency = $emergency; + + return $this; } } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php new file mode 100644 index 000000000..bfae78878 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -0,0 +1,103 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +use Doctrine\ORM\Mapping as ORM; + +/** + * Class ActivityPresence + * + * @package Chill\ActivityBundle\Entity + * @ORM\Entity() + * @ORM\Table(name="activitytpresence") + * @ORM\HasLifecycleCallbacks() + */ +class ActivityPresence +{ + /** + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") + */ + private ?int $id; + + /** + * @ORM\Column(type="json") + */ + private array $name = []; + + /** + * @ORM\Column(type="boolean") + */ + private bool $active = true; + + /** + * Get id + */ + public function getId(): int + { + return $this->id; + } + + /** + * Set name + */ + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + public function getName(): array + { + return $this->name; + } + + /** + * Get active + * return true if the category type is active. + */ + public function getActive(): bool + { + return $this->active; + } + + /** + * Is active + * return true if the category type is active + */ + public function isActive(): bool + { + return $this->getActive(); + } + + /** + * Set active + * set to true if the category type is active + */ + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } +} diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 7f909db3f..1d02f09a0 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -37,8 +37,6 @@ class ActivityType const FIELD_REQUIRED = 2; /** - * @var integer - * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index eaf347cb4..4ee84edba 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -69,25 +69,10 @@ class ActivityTypeCategory /** * Get name - * - * @return array | string */ - public function getName(?string $locale = null) + public function getName(): array { - if ($locale) { - if (isset($this->name[$locale])) { - return $this->name[$locale]; - } else { - foreach ($this->name as $name) { - if (!empty($name)) { - return $name; - } - } - } - return ''; - } else { - return $this->name; - } + return $this->name; } /** diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php b/src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php new file mode 100644 index 000000000..42894cc25 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php @@ -0,0 +1,33 @@ +add('name', TranslatableStringFormType::class) + ->add('active', ChoiceType::class, array( + 'choices' => array( + 'Yes' => true, + 'No' => false + ), + 'expanded' => true + )); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults(array( + 'data_class' => ActivityPresence::class + )); + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/edit.html.twig new file mode 100644 index 000000000..16cf893e8 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/edit.html.twig @@ -0,0 +1,12 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block title %} +{% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/index.html.twig new file mode 100644 index 000000000..04f0f5dec --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/index.html.twig @@ -0,0 +1,44 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block admin_content %} +

    {{ 'ActivityPresence list'|trans }}

    + + + + + + + + + + + {% for entity in entities %} + + + + + + {% endfor %} + +
    {{ 'Name'|trans }}{{ 'Active'|trans }}{{ 'Actions'|trans }}
    {{ entity.name|localize_translatable_string }} + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + +
      +
    • + +
    • +
    +
    + + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/new.html.twig new file mode 100644 index 000000000..c95711529 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityPresence/new.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} + +{% block title %} +{% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/config/routes.yaml b/src/Bundle/ChillActivityBundle/config/routes.yaml index 3e1766adf..5403529ae 100644 --- a/src/Bundle/ChillActivityBundle/config/routes.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes.yaml @@ -46,3 +46,12 @@ chill_activity_type_category_admin: admin_activity: order: 2999 label: 'Activity Types Categories' + +chill_activity_presence_admin: + path: /{_locale}/admin/activity/presence + controller: cscrud_activity_presence_controller:index + options: + menus: + admin_activity: + order: 2021 + label: 'Activity Presences' From 05ebdefd47d680ae263fc3f85bdffbbe8f1902f8 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 22 Apr 2021 14:47:00 +0200 Subject: [PATCH 009/116] Add missing fields & migrations --- .../ChillActivityBundle/Entity/Activity.php | 89 ++++++++++++++++--- .../Entity/ActivityPresence.php | 6 -- .../Entity/ActivityType.php | 60 +++++++++++++ .../Form/ActivityTypeType.php | 2 +- .../migrations/Version20210422073711.php | 52 +++++++++++ .../migrations/Version20210422123846.php | 65 ++++++++++++++ 6 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index e1341787f..6c4c03181 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -48,6 +48,9 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; */ class Activity implements HasCenterInterface, HasScopeInterface { + const SENTRECEIVED_SENT = 'sent'; + const SENTRECEIVED_RECEIVED = 'received'; + /** * @ORM\Id * @ORM\Column(name="id", type="integer") @@ -71,9 +74,14 @@ class Activity implements HasCenterInterface, HasScopeInterface private \DateTime $durationTime; /** - * @ORM\Column(type="boolean") + * @ORM\Column(type="time") */ - private bool $attendee; + private \DateTime $travelTime; + + /** + * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") + */ + private ActivityPresence $attendee; /** * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") @@ -101,25 +109,35 @@ class Activity implements HasCenterInterface, HasScopeInterface private CommentEmbeddable $comment; /** - * @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\Person", mappedBy="person") + * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") */ private ArrayCollection $persons; /** - * @ORM\OneToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", mappedBy="thirdParty") + * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") */ private ArrayCollection $thirdParties; /** - * @ORM\OneToMany(targetEntity="Chill\DocStoreBundle\Entity\Document", mappedBy="document") + * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\Document") */ private ArrayCollection $documents; /** - * @ORM\Column(type="boolean") + * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") + */ + private ArrayCollection $users; + + /** + * @ORM\Column(type="boolean", options={"default"=false}) */ private bool $emergency = false; + /** + * @ORM\Column(type="string", options={"default"=""}) + */ + private string $sentReceived = ''; + public function __construct() { $this->reasons = new ArrayCollection(); @@ -127,6 +145,7 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->persons = new ArrayCollection(); $this->thirdParties = new ArrayCollection(); $this->documents = new ArrayCollection(); + $this->users = new ArrayCollection(); } /** @@ -191,20 +210,26 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->durationTime; } - /** - * Set attendee - */ - public function setAttendee(bool $attendee): self + public function setTravelTime(\DateTime $travelTime): self + { + $this->travelTime = $travelTime; + + return $this; + } + + public function getTravelTime(): \DateTime + { + return $this->travelTime; + } + + public function setAttendee(ActivityPresence $attendee): self { $this->attendee = $attendee; return $this; } - /** - * Get attendee - */ - public function getAttendee(): bool + public function getAttendee(): ActivityPresence { return $this->attendee; } @@ -382,6 +407,30 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } + public function addUser(User $user): self + { + $this->users[] = $user; + + return $this; + } + + public function removeUser(User $user): void + { + $this->users->removeElement($user); + } + + public function getUsers(): ArrayCollection + { + return $this->users; + } + + public function setUsers(ArrayCollection $users): self + { + $this->users = $users; + + return $this; + } + public function isEmergency(): bool { return $this->getEmergency(); @@ -398,5 +447,17 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } + + public function getSentReceived(): string + { + return $this->sentReceived; + } + + public function setSentReceived(string $sentReceived): self + { + $this->sentReceived = $sentReceived; + + return $this; + } } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index bfae78878..ed9757549 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -49,17 +49,11 @@ class ActivityPresence */ private bool $active = true; - /** - * Get id - */ public function getId(): int { return $this->id; } - /** - * Set name - */ public function setName(array $name): self { $this->name = $name; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 1d02f09a0..fe5e87dec 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -128,6 +128,16 @@ class ActivityType */ private string $durationTimeLabel = ''; + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $travelTimeVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $travelTimeLabel = ''; + /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) */ @@ -178,6 +188,16 @@ class ActivityType */ private string $documentsLabel = ''; + /** + * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + */ + private int $usersVisible = self::FIELD_OPTIONAL; + + /** + * @ORM\Column(type="string", nullable=false, options={"default"=""}) + */ + private string $usersLabel = ''; + /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) */ @@ -413,6 +433,26 @@ class ActivityType $this->durationTimeLabel = $durationTimeLabel; } + public function getTravelTimeVisible(): int + { + return $this->travelTimeVisible; + } + + public function setTravelTimeVisible(int $TravelTimeVisible): void + { + $this->travelTimeVisible = $TravelTimeVisible; + } + + public function getTravelTimeLabel(): string + { + return $this->travelTimeLabel; + } + + public function setTravelTimeLabel(string $TravelTimeLabel): void + { + $this->travelTimeLabel = $TravelTimeLabel; + } + public function getAttendeeVisible(): int { return $this->attendeeVisible; @@ -513,6 +553,26 @@ class ActivityType $this->documentsLabel = $documentsLabel; } + public function getUsersVisible(): int + { + return $this->usersVisible; + } + + public function setUsersVisible(int $usersVisible): void + { + $this->usersVisible = $usersVisible; + } + + public function getUsersLabel(): string + { + return $this->usersLabel; + } + + public function setUsersLabel(string $usersLabel): void + { + $this->usersLabel = $usersLabel; + } + public function getEmergencyVisible(): int { return $this->emergencyVisible; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 028cbc307..96e50f690 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -43,7 +43,7 @@ class ActivityTypeType extends AbstractType $fields = [ 'persons', 'user', 'date', 'place', 'persons', - 'thirdParties', 'durationTime', 'attendee', + 'thirdParties', 'durationTime', 'travelTime', 'attendee', 'reasons', 'comment', 'sentReceived', 'documents', 'emergency', 'accompanyingPeriod', 'socialData' ]; diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php b/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php new file mode 100644 index 000000000..8d5dcfa84 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php @@ -0,0 +1,52 @@ +addSql('CREATE SEQUENCE activitytpresence_id_seq INCREMENT BY 1 MINVALUE 1 START 6'); + $this->addSql('CREATE TABLE activitytpresence (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))'); + + $list = [ + 'Usager pésent', "Absence de l''usager", + "Refus de visite ou d''entretien", 'Domicile non trouvé', + 'Domicile erronéee' + ]; + for ($i = 1; $i <= count($list); $i++) { + $this->addSql("INSERT INTO activitytpresence VALUES(".$i.", json_build_object('fr', '".$list[$i-1]."'), true)"); + } + + $this->addSql('ALTER TABLE activity ADD emergency BOOLEAN NOT NULL DEFAULT false'); + $this->addSql('ALTER TABLE activity ADD sentReceived VARCHAR(255) NOT NULL DEFAULT \'\' '); + $this->addSql('ALTER TABLE activity ALTER attendee TYPE INT USING CASE WHEN attendee is false THEN 2 WHEN attendee is true THEN 1 ELSE null END'); + $this->addSql('ALTER TABLE activity RENAME COLUMN attendee TO attendee_id'); + $this->addSql('ALTER TABLE activity ADD CONSTRAINT FK_AC74095ABCFD782A FOREIGN KEY (attendee_id) REFERENCES activitytpresence (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activity DROP emergency'); + $this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095ABCFD782A'); + $this->addSql('ALTER TABLE activity ADD attendee BOOLEAN DEFAULT NULL'); + $this->addSql('ALTER TABLE activity DROP attendee_id'); + $this->addSql('ALTER TABLE activity DROP sentReceived'); + + $this->addSql('DROP SEQUENCE activitytpresence_id_seq CASCADE'); + $this->addSql('DROP TABLE activitytpresence'); + } +} diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php new file mode 100644 index 000000000..a4b1c8f65 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php @@ -0,0 +1,65 @@ +addSql('CREATE TABLE activity_person (activity_id INT NOT NULL, person_id INT NOT NULL, PRIMARY KEY(activity_id, person_id))'); + $this->addSql('CREATE INDEX IDX_66AA317681C06096 ON activity_person (activity_id)'); + $this->addSql('CREATE INDEX IDX_66AA3176217BBB47 ON activity_person (person_id)'); + $this->addSql('CREATE TABLE activity_thirdparty (activity_id INT NOT NULL, thirdparty_id INT NOT NULL, PRIMARY KEY(activity_id, thirdparty_id))'); + $this->addSql('CREATE INDEX IDX_C6F0DE0381C06096 ON activity_thirdparty (activity_id)'); + $this->addSql('CREATE INDEX IDX_C6F0DE03C7D3A8E6 ON activity_thirdparty (thirdparty_id)'); + $this->addSql('CREATE TABLE activity_document (activity_id INT NOT NULL, document_id INT NOT NULL, PRIMARY KEY(activity_id, document_id))'); + $this->addSql('CREATE INDEX IDX_78633A7881C06096 ON activity_document (activity_id)'); + $this->addSql('CREATE INDEX IDX_78633A78C33F7837 ON activity_document (document_id)'); + $this->addSql('CREATE TABLE activity_user (activity_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(activity_id, user_id))'); + $this->addSql('CREATE INDEX IDX_8E570DDB81C06096 ON activity_user (activity_id)'); + $this->addSql('CREATE INDEX IDX_8E570DDBA76ED395 ON activity_user (user_id)'); + $this->addSql('ALTER TABLE activity_person ADD CONSTRAINT FK_66AA317681C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_person ADD CONSTRAINT FK_66AA3176217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE0381C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE03C7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A7881C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A78C33F7837 FOREIGN KEY (document_id) REFERENCES Document (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDB81C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('ALTER TABLE activity ADD travelTime TIME(0) WITHOUT TIME ZONE NOT NULL'); + + $this->addSql('ALTER TABLE activitytype ADD travelTimeVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD travelTimeLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD usersVisible SMALLINT DEFAULT 1 NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD usersLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + } + + public function down(Schema $schema) : void + { + $this->addSql('DROP TABLE activity_person'); + $this->addSql('DROP TABLE activity_thirdparty'); + $this->addSql('DROP TABLE activity_document'); + $this->addSql('DROP TABLE activity_user'); + + $this->addSql('ALTER TABLE activity DROP travelTime'); + + $this->addSql('ALTER TABLE activitytype DROP travelTimeVisible'); + $this->addSql('ALTER TABLE activitytype DROP travelTimeLabel'); + $this->addSql('ALTER TABLE activitytype DROP usersVisible'); + $this->addSql('ALTER TABLE activitytype DROP usersLabel'); + } +} From 31e8dea96537d6d21d434d03f632454a1e233f3c Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 22 Apr 2021 15:33:13 +0200 Subject: [PATCH 010/116] Add missing fields & migrations --- .../ChillActivityBundle/Entity/Activity.php | 30 +++++++++---------- .../Form/ActivityTypeType.php | 2 +- .../migrations/Version20210422123846.php | 6 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 6c4c03181..57a72e5a8 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -74,9 +74,9 @@ class Activity implements HasCenterInterface, HasScopeInterface private \DateTime $durationTime; /** - * @ORM\Column(type="time") + * @ORM\Column(type="time", nullable=true) */ - private \DateTime $travelTime; + private ?\DateTime $travelTime; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") @@ -111,22 +111,22 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") */ - private ArrayCollection $persons; + private Collection $persons; /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") */ - private ArrayCollection $thirdParties; + private Collection $thirdParties; /** * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\Document") */ - private ArrayCollection $documents; + private Collection $documents; /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") */ - private ArrayCollection $users; + private Collection $users; /** * @ORM\Column(type="boolean", options={"default"=false}) @@ -252,7 +252,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get reasons */ - public function getReasons(): ArrayCollection + public function getReasons(): Collection { return $this->reasons; } @@ -347,12 +347,12 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->persons->removeElement($person); } - public function getPersons(): ArrayCollection + public function getPersons(): Collection { return $this->persons; } - public function setPersons(ArrayCollection $persons): self + public function setPersons(Collection $persons): self { $this->persons = $persons; @@ -371,12 +371,12 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->thirdParties->removeElement($thirdParty); } - public function getThirdParties(): ArrayCollection + public function getThirdParties(): Collection { return $this->thirdParties; } - public function setThirdParties(ArrayCollection $thirdParties): self + public function setThirdParties(Collection $thirdParties): self { $this->thirdParties = $thirdParties; @@ -395,12 +395,12 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->documents->removeElement($document); } - public function getDocuments(): ArrayCollection + public function getDocuments(): Collection { return $this->documents; } - public function setDocuments(ArrayCollection $documents): self + public function setDocuments(Collection $documents): self { $this->documents = $documents; @@ -419,12 +419,12 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->users->removeElement($user); } - public function getUsers(): ArrayCollection + public function getUsers(): Collection { return $this->users; } - public function setUsers(ArrayCollection $users): self + public function setUsers(Collection $users): self { $this->users = $users; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 96e50f690..9a819ddf1 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -45,7 +45,7 @@ class ActivityTypeType extends AbstractType 'persons', 'user', 'date', 'place', 'persons', 'thirdParties', 'durationTime', 'travelTime', 'attendee', 'reasons', 'comment', 'sentReceived', 'documents', - 'emergency', 'accompanyingPeriod', 'socialData' + 'emergency', 'accompanyingPeriod', 'socialData', 'users' ]; foreach ($fields as $field) { $builder diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php index a4b1c8f65..0fde71257 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Application\Migrations; +namespace Chill\Migrations\Activity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; @@ -36,11 +36,11 @@ final class Version20210422123846 extends AbstractMigration $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE0381C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE03C7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A7881C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A78C33F7837 FOREIGN KEY (document_id) REFERENCES Document (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + #$this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A78C33F7837 FOREIGN KEY (document_id) REFERENCES Document (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDB81C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE activity ADD travelTime TIME(0) WITHOUT TIME ZONE NOT NULL'); + $this->addSql('ALTER TABLE activity ADD travelTime TIME(0) WITHOUT TIME ZONE DEFAULT NULL'); $this->addSql('ALTER TABLE activitytype ADD travelTimeVisible SMALLINT DEFAULT 1 NOT NULL'); $this->addSql('ALTER TABLE activitytype ADD travelTimeLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); From 82d8556f2451c955eb9816da2020c8f9beb86553 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 29 Apr 2021 16:35:39 +0200 Subject: [PATCH 011/116] Activity Form : display field according to the parameters --- .../Controller/ActivityController.php | 78 ++--- .../ChillActivityBundle/Entity/Activity.php | 8 +- .../Entity/ActivityType.php | 33 ++ .../Form/ActivitySelectTypeType.php | 19 - .../ChillActivityBundle/Form/ActivityType.php | 330 +++++++++++------- .../Resources/views/Activity/edit.html.twig | 40 ++- .../Resources/views/Activity/new.html.twig | 38 +- .../views/Activity/selectType.html.twig | 17 +- 8 files changed, 354 insertions(+), 209 deletions(-) delete mode 100644 src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 58d7e68ea..036646104 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -22,11 +22,12 @@ namespace Chill\ActivityBundle\Controller; -use Chill\ActivityBundle\Form\ActivitySelectTypeType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -69,7 +70,7 @@ class ActivityController extends AbstractController * Lists all Activity entities. * */ - public function listAction($person_id, Request $request) + public function listAction($person_id) { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -102,31 +103,21 @@ class ActivityController extends AbstractController )); } - public function selectTypeAction(int $person_id, Request $request): Response + public function selectTypeAction(int $person_id): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $person = $em->getRepository(Person::class)->find($person_id); if ($person === NULL) { throw $this->createNotFoundException('Person not found'); } - $form = $this->createForm(ActivitySelectTypeType::class); - - $form->handleRequest($request); - if ($form->isSubmitted() && $form->isValid()) { - $activityType = $form->get('type')->getData(); - if ($activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) { - return $this->redirectToRoute('chill_activity_activity_new', [ - 'person_id' => $person->getId(), - 'activityType_id' => $activityType->getId(), - ]); - } - } + $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) + ->findBy(['active' => true]); return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ - 'form' => $form->createView(), - 'person' => $person + 'person' => $person, + 'activityTypes' => $activityTypes, ]); } @@ -191,20 +182,17 @@ class ActivityController extends AbstractController * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Activity $entity) + private function createCreateForm(Activity $entity): FormInterface { - $form = $this->createForm(ActivityType::class, $entity, - array( - 'action' => $this->generateUrl('chill_activity_activity_create', [ - 'person_id' => $entity->getPerson()->getId(), - ]), - 'method' => 'POST', - 'center' => $entity->getCenter(), - 'role' => new Role('CHILL_ACTIVITY_CREATE') - ) - ); - - return $form; + return $this->createForm(ActivityType::class, $entity, [ + 'action' => $this->generateUrl('chill_activity_activity_create', [ + 'person_id' => $entity->getPerson()->getId(), + ]), + 'method' => 'POST', + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_ACTIVITY_CREATE'), + 'activityType' => $entity->getType(), + ]); } /** @@ -224,7 +212,8 @@ class ActivityController extends AbstractController $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) ->find($activityType_id); - if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) { + if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType || + !$activityType->isActive()) { return $this->redirectToRoute('chill_activity_activity_select_type', [ 'person_id' => $person->getId(), ]); @@ -240,7 +229,7 @@ class ActivityController extends AbstractController $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); - $form = $this->createCreateForm($entity); + $form = $this->createCreateForm($entity); return $this->render('ChillActivityBundle:Activity:new.html.twig', array( 'person' => $person, @@ -333,24 +322,21 @@ class ActivityController extends AbstractController * Creates a form to edit a Activity entity. * * @param Activity $entity The entity - * - * @return \Symfony\Component\Form\Form The form */ - private function createEditForm(Activity $entity) + private function createEditForm(Activity $entity): FormInterface { - $form = $this->createForm(ActivityType::class, $entity, array( - 'action' => $this->generateUrl('chill_activity_activity_update', - array( - 'id' => $entity->getId(), - 'person_id' => $entity->getPerson()->getId() - )), + return $this->createForm(ActivityType::class, $entity, [ + 'action' => $this->generateUrl('chill_activity_activity_update', [ + 'id' => $entity->getId(), + 'person_id' => $entity->getPerson()->getId() + ]), 'method' => 'PUT', 'center' => $entity->getCenter(), - 'role' => new Role('CHILL_ACTIVITY_UPDATE') - )); - - return $form; + 'role' => new Role('CHILL_ACTIVITY_UPDATE'), + 'activityType' => $entity->getType(), + ]); } + /** * Edits an existing Activity entity. * diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 57a72e5a8..005644670 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -76,7 +76,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\Column(type="time", nullable=true) */ - private ?\DateTime $travelTime; + private ?\DateTime $travelTime = null; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") @@ -96,7 +96,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ - private Scope $scope; + private ?Scope $scope = null; /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") @@ -217,7 +217,7 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - public function getTravelTime(): \DateTime + public function getTravelTime(): ?\DateTime { return $this->travelTime; } @@ -288,7 +288,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Get scope */ - public function getScope(): Scope + public function getScope(): ?Scope { return $this->scope; } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index fe5e87dec..65fc243d5 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -632,4 +632,37 @@ class ActivityType { $this->socialDataLabel = $socialDataLabel; } + + public function isVisible(string $field): bool + { + $property = $field.'Visible'; + + if (!property_exists($this, $property)) { + throw new \InvalidArgumentException('Field "'.$field.'" not found'); + } + + return self::FIELD_INVISIBLE !== $this->$property; + } + + public function isRequired(string $field): bool + { + $property = $field.'Visible'; + + if (!property_exists($this, $property)) { + throw new \InvalidArgumentException('Field "'.$field.'" not found'); + } + + return self::FIELD_REQUIRED === $this->$property; + } + + public function getLabel(string $field): ?string + { + $property = $field.'Label'; + + if (!property_exists($this, $property)) { + throw new \InvalidArgumentException('Field "'.$field.'" not found'); + } + + return $this->$property; + } } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php deleted file mode 100644 index c637e5bcc..000000000 --- a/src/Bundle/ChillActivityBundle/Form/ActivitySelectTypeType.php +++ /dev/null @@ -1,19 +0,0 @@ -add('type', TranslatableActivityType::class, array( - 'placeholder' => 'Choose a type', - 'active_only' => true, - 'mapped' => false, - )); - } -} diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index eb63b6beb..2378c6db5 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -2,8 +2,16 @@ namespace Chill\ActivityBundle\Form; +use Chill\ActivityBundle\Entity\Activity; +use Chill\ActivityBundle\Entity\ActivityPresence; +use Chill\ActivityBundle\Entity\ActivityReason; use Chill\MainBundle\Form\Type\CommentType; +use Chill\PersonBundle\Entity\Person; +use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Doctrine\ORM\EntityRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -15,51 +23,33 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Chill\ActivityBundle\Form\Type\TranslatableActivityType; -use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Form\Type\ChillDateType; class ActivityType extends AbstractType { - /** - * the user running this form - * - * @var User - */ - protected $user; + protected User $user; - /** - * - * @var AuthorizationHelper - */ protected AuthorizationHelper $authorizationHelper; - /** - * - * @var ObjectManager - */ - protected $om; + protected ObjectManager $om; - /** - * - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; + protected TranslatableStringHelper $translatableStringHelper; - protected $timeChoices; + protected array $timeChoices; - public function __construct( - TokenStorageInterface $tokenStorage, - AuthorizationHelper $authorizationHelper, ObjectManager $om, - TranslatableStringHelper $translatableStringHelper, - array $timeChoices - ) - { + public function __construct ( + TokenStorageInterface $tokenStorage, + AuthorizationHelper $authorizationHelper, + ObjectManager $om, + TranslatableStringHelper $translatableStringHelper, + array $timeChoices + ) { if (!$tokenStorage->getToken()->getUser() instanceof User) { throw new \RuntimeException("you should have a valid user"); } + $this->user = $tokenStorage->getToken()->getUser(); $this->authorizationHelper = $authorizationHelper; $this->om = $om; @@ -67,121 +57,219 @@ class ActivityType extends AbstractType $this->timeChoices = $timeChoices; } - /** - * @param FormBuilderInterface $builder - * @param array $options - */ - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { // handle times choices - $timeChoices = array(); + $timeChoices = []; foreach ($this->timeChoices as $e) { $timeChoices[$e['label']] = $e['seconds']; - }; + } $durationTimeTransformer = new DateTimeToTimestampTransformer('GMT', 'GMT'); - $durationTimeOptions = array( - 'choices' => $timeChoices, - 'placeholder' => 'Choose the duration', - ); + $durationTimeOptions = [ + 'choices' => $timeChoices, + 'placeholder' => 'Choose the duration', + ]; - $builder - ->add('date', ChillDateType::class, array( - 'required' => true - )) - ->add('durationTime', ChoiceType::class, $durationTimeOptions) - ->add('attendee', ChoiceType::class, array( - 'expanded' => true, - 'required' => false, - 'choices' => array( - 'present' => true, - 'not present' => false - ) - )) - ->add('user', UserPickerType::class, [ + /** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */ + $activityType = $options['activityType']; + + if (!$activityType->isActive()) { + throw new \InvalidArgumentException('Activity type must be active'); + } + + $builder->add('scope', ScopePickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]); + + if ($activityType->isVisible('date')) { + $builder->add('date', ChillDateType::class, [ + 'label' => $activityType->getLabel('date'), + 'required' => $activityType->isRequired('date'), + ]); + } + + if ($activityType->isVisible('durationTime')) { + $durationTimeOptions['label'] = $activityType->getLabel('durationTime'); + $durationTimeOptions['required'] = $activityType->isRequired('durationTime'); + + $builder->add('durationTime', ChoiceType::class, $durationTimeOptions); + } + + if ($activityType->isVisible('travelTime')) { + $durationTimeOptions['label'] = $activityType->getLabel('travelTime'); + $durationTimeOptions['required'] = $activityType->isRequired('travelTime'); + + $builder->add('travelTime', ChoiceType::class, $durationTimeOptions); + } + + if ($activityType->isVisible('travelTime')) { + $builder->add('attendee', EntityType::class, [ + 'label' => $activityType->getLabel('attendee'), + 'required' => $activityType->isRequired('attendee'), + 'class' => ActivityPresence::class, + 'choice_label' => function (ActivityPresence $activityPresence) { + return $this->translatableStringHelper->localize($activityPresence->getName()); + }, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('a') + ->where('a.active = true'); + }, + ]); + } + + if ($activityType->isVisible('user')) { + $builder->add('user', UserPickerType::class, [ + 'label' => $activityType->getLabel('user'), + 'required' => $activityType->isRequired('user'), 'center' => $options['center'], 'role' => $options['role'] - ]) - ->add('scope', ScopePickerType::class, [ - 'center' => $options['center'], - 'role' => $options['role'] - ]) - ->add('reasons', TranslatableActivityReason::class, array( + ]); + } + + if ($activityType->isVisible('reasons')) { + $builder->add('reasons', EntityType::class, [ + 'label' => $activityType->getLabel('reasons'), + 'required' => $activityType->isRequired('reasons'), + 'class' => ActivityReason::class, + 'choice_label' => function (ActivityReason $activityReason) { + return $this->translatableStringHelper->localize($activityReason->getName()); + }, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('a') + ->where('a.active = true'); + }, + ]); + } + + if ($activityType->isVisible('comment')) { + $builder->add('comment', CommentType::class, [ + 'label' => $activityType->getLabel('comment'), + 'required' => $activityType->isRequired('comment'), + ]); + } + + if ($activityType->isVisible('persons')) { + // TODO Faire évoluer le selecteur et la query + $builder->add('persons', EntityType::class, [ + 'label' => $activityType->getLabel('persons'), + 'required' => $activityType->isRequired('persons'), + 'class' => Person::class, 'multiple' => true, - 'required' => false, - )) - ->add('comment', CommentType::class, [ - 'required' => false, - ]) - ; + 'choice_label' => function (Person $person) { + return $person->getFullnameCanonical(); + }, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('a'); + }, + ]); + } + + if ($activityType->isVisible('thirdParties')) { + $builder->add('thirdParties', EntityType::class, [ + 'label' => $activityType->getLabel('thirdParties'), + 'required' => $activityType->isRequired('thirdParties'), + 'class' => ThirdParty::class, + 'choice_label' => function (ThirdParty $thirdParty) { + return $thirdParty->getName(); + }, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('a'); + }, + ]); + } + + // TODO : documents + //$documents + + if ($activityType->isVisible('users')) { + $builder->add('users', EntityType::class, [ + 'label' => $activityType->getLabel('users'), + 'required' => $activityType->isRequired('users'), + 'class' => User::class, + 'choice_label' => function (User $user) { + return $user->getUsername(); + }, + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('u'); + }, + ]); + } + + if ($activityType->isVisible('emergency')) { + $builder->add('emergency', CheckboxType::class, [ + 'label' => $activityType->getLabel('emergency'), + 'required' => $activityType->isRequired('emergency'), + ]); + } + + if ($activityType->isVisible('sentReceived')) { + $builder->add('sentReceived', ChoiceType::class, [ + 'label' => $activityType->getLabel('sentReceived'), + 'required' => $activityType->isRequired('sentReceived'), + 'choices' => [ + 'Sent' => Activity::SENTRECEIVED_SENT, + 'Received' => Activity::SENTRECEIVED_RECEIVED, + ], + ]); + } $builder->get('durationTime') - ->addModelTransformer($durationTimeTransformer); - + ->addModelTransformer($durationTimeTransformer); $builder->get('durationTime') - ->addEventListener( - FormEvents::PRE_SET_DATA, - function(FormEvent $formEvent) use ( - $timeChoices, - $builder, - $durationTimeTransformer, - $durationTimeOptions - ) - { - // set the timezone to GMT, and fix the difference between current and GMT - // the datetimetransformer will then handle timezone as GMT - $timezoneUTC = new \DateTimeZone('GMT'); - /* @var $data \DateTime */ - $data = $formEvent->getData() === NULL ? - \DateTime::createFromFormat('U', 300) : - $formEvent->getData(); - $seconds = $data->getTimezone()->getOffset($data); - $data->setTimeZone($timezoneUTC); - $data->add(new \DateInterval('PT'.$seconds.'S')); + ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use ( + $timeChoices, + $builder, + $durationTimeTransformer, + $durationTimeOptions + ) { + // set the timezone to GMT, and fix the difference between current and GMT + // the datetimetransformer will then handle timezone as GMT + $timezoneUTC = new \DateTimeZone('GMT'); + /* @var $data \DateTime */ + $data = $formEvent->getData() === NULL ? + \DateTime::createFromFormat('U', 300) : + $formEvent->getData(); + $seconds = $data->getTimezone()->getOffset($data); + $data->setTimeZone($timezoneUTC); + $data->add(new \DateInterval('PT'.$seconds.'S')); - // test if the timestamp is in the choices. - // If not, recreate the field with the new timestamp - if (!in_array($data->getTimestamp(), $timeChoices)) { - // the data are not in the possible values. add them - $timeChoices[$data->format('H:i')] = $data->getTimestamp(); - $form = $builder->create( - 'durationTime', - ChoiceType::class, - array_merge( - $durationTimeOptions, - array( - 'choices' => $timeChoices, - 'auto_initialize' => false - ) - )); - $form->addModelTransformer($durationTimeTransformer); - $formEvent->getForm()->getParent()->add($form->getForm()); - } - }); + // test if the timestamp is in the choices. + // If not, recreate the field with the new timestamp + if (!in_array($data->getTimestamp(), $timeChoices)) { + // the data are not in the possible values. add them + $timeChoices[$data->format('H:i')] = $data->getTimestamp(); + $form = $builder->create('durationTime', ChoiceType::class, array_merge( + $durationTimeOptions, + [ + 'choices' => $timeChoices, + 'auto_initialize' => false + ] + )); + $form->addModelTransformer($durationTimeTransformer); + $formEvent->getForm()->getParent()->add($form->getForm()); + } + }); } - /** - * @param OptionsResolverInterface $resolver - */ - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Chill\ActivityBundle\Entity\Activity' - )); + ]); $resolver - ->setRequired(array('center', 'role')) - ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') - ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') - ; + ->setRequired(['center', 'role', 'activityType']) + ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') + ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') + ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) + ; } - /** - * @return string - */ - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'chill_activitybundle_activity'; } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index 7a69a8eee..e4db4d943 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -29,12 +29,40 @@ {{ form_row(edit_form.scope) }}

    {{ 'Activity data'|trans }}

    - {{ form_row(edit_form.date) }} - {{ form_row(edit_form.durationTime) }} - {{ form_row(edit_form.type) }} - {{ form_row(edit_form.attendee) }} - {{ form_row(edit_form.reasons) }} - {{ form_row(edit_form.comment) }} + + {%- if form.date is defined -%} + {{ form_row(form.date) }} + {% endif %} + {%- if form.durationTime is defined -%} + {{ form_row(form.durationTime) }} + {% endif %} + {%- if form.travelTime is defined -%} + {{ form_row(form.travelTime) }} + {% endif %} + {%- if form.attendee is defined -%} + {{ form_row(form.attendee) }} + {% endif %} + {%- if form.comment is defined -%} + {{ form_row(form.comment) }} + {% endif %} + {%- if form.reasons is defined -%} + {{ form_row(form.reasons) }} + {% endif %} + {%- if form.persons is defined -%} + {{ form_row(form.persons) }} + {% endif %} + {%- if form.thirdParties is defined -%} + {{ form_row(form.thirdParties) }} + {% endif %} + {%- if form.users is defined -%} + {{ form_row(form.users) }} + {% endif %} + {%- if form.emergency is defined -%} + {{ form_row(form.emergency) }} + {% endif %} + {%- if form.sentReceived is defined -%} + {{ form_row(form.sentReceived) }} + {% endif %} {{ form_widget(edit_form) }}
      diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 24c659a56..11edc2c4c 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -30,11 +30,39 @@

      {{ 'Activity data'|trans }}

      - {{ form_row(form.date) }} - {{ form_row(form.durationTime) }} - {{ form_row(form.attendee) }} - {{ form_row(form.reasons) }} - {{ form_row(form.comment) }} + {%- if form.date is defined -%} + {{ form_row(form.date) }} + {% endif %} + {%- if form.durationTime is defined -%} + {{ form_row(form.durationTime) }} + {% endif %} + {%- if form.travelTime is defined -%} + {{ form_row(form.travelTime) }} + {% endif %} + {%- if form.attendee is defined -%} + {{ form_row(form.attendee) }} + {% endif %} + {%- if form.comment is defined -%} + {{ form_row(form.comment) }} + {% endif %} + {%- if form.reasons is defined -%} + {{ form_row(form.reasons) }} + {% endif %} + {%- if form.persons is defined -%} + {{ form_row(form.persons) }} + {% endif %} + {%- if form.thirdParties is defined -%} + {{ form_row(form.thirdParties) }} + {% endif %} + {%- if form.users is defined -%} + {{ form_row(form.users) }} + {% endif %} + {%- if form.emergency is defined -%} + {{ form_row(form.emergency) }} + {% endif %} + {%- if form.sentReceived is defined -%} + {{ form_row(form.sentReceived) }} + {% endif %}
      diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig index e6ab83482..9e3407337 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -7,13 +7,14 @@ {% block personcontent %}

      {{ "Activity creation"|trans }}

      - {{ form_start(form) }} - - {{ form_row(form.type) }} - -
      - + {# TODO: refaire l'html css des tuilles #} +
      + {% for activityType in activityTypes %} + +
      + {{ activityType.name|localize_translatable_string }} +
      +
      + {% endfor %}
      - - {{ form_end(form) }} {% endblock %} From 4d8afd53ad1d6661509319bb3f6caec880ec7f0a Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 09:36:03 +0200 Subject: [PATCH 012/116] Form & save into DB --- .../Controller/ActivityController.php | 128 ++++++++---------- .../ChillActivityBundle/Entity/Activity.php | 70 +++------- .../ChillActivityBundle/Form/ActivityType.php | 3 + .../Resources/views/Activity/new.html.twig | 1 + .../config/routes/activity.yaml | 1 + .../migrations/Version20210506071150.php | 30 ++++ .../ChillMarkdownRenderExtension.php | 10 +- 7 files changed, 109 insertions(+), 134 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210506071150.php diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 036646104..a30e23532 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -121,80 +121,6 @@ class ActivityController extends AbstractController ]); } - /** - * Creates a new Activity entity. - * - */ - public function createAction($person_id, Request $request) - { - $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - - if ($person === NULL) { - throw $this->createNotFoundException('person not found'); - } - - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - - $entity = new Activity(); - $entity->setPerson($person); - $form = $this->createCreateForm($entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity, - 'creation of this activity not allowed'); - - $em->persist($entity); - $em->flush(); - - $this->get('session') - ->getFlashBag() - ->add('success', - $this->get('translator') - ->trans('Success : activity created!') - ); - - return $this->redirect( - $this->generateUrl('chill_activity_activity_show', - array('id' => $entity->getId(), 'person_id' => $person_id))); - } - - $this->get('session') - ->getFlashBag()->add('danger', - $this->get('translator') - ->trans('The form is not valid. The activity has not been created !') - ); - - return $this->render('ChillActivityBundle:Activity:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - 'person' => $person - )); - } - - /** - * Creates a form to create a Activity entity. - * - * @param Activity $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(Activity $entity): FormInterface - { - return $this->createForm(ActivityType::class, $entity, [ - 'action' => $this->generateUrl('chill_activity_activity_create', [ - 'person_id' => $entity->getPerson()->getId(), - ]), - 'method' => 'POST', - 'center' => $entity->getCenter(), - 'role' => new Role('CHILL_ACTIVITY_CREATE'), - 'activityType' => $entity->getType(), - ]); - } - /** * Displays a form to create a new Activity entity. * @@ -229,7 +155,23 @@ class ActivityController extends AbstractController $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); - $form = $this->createCreateForm($entity); + $form = $this->createForm(ActivityType::class, $entity, [ + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_ACTIVITY_CREATE'), + 'activityType' => $entity->getType(), + ])->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em->persist($entity); + $em->flush(); + + $this->addFlash('success', $this->get('translator')->trans('Success : activity created!')); + + return $this->redirectToRoute('chill_activity_activity_show', [ + 'id' => $entity->getId(), + 'person_id' => $person_id + ]); + } return $this->render('ChillActivityBundle:Activity:new.html.twig', array( 'person' => $person, @@ -238,6 +180,42 @@ class ActivityController extends AbstractController )); } + + /** + * Creates a new Activity entity. + * + */ + public function createAction($person_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + + if ($person === NULL) { + throw $this->createNotFoundException('person not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + + $entity = new Activity(); + $entity->setPerson($person); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + + + $this->get('session') + ->getFlashBag()->add('danger', + $this->get('translator') + ->trans('The form is not valid. The activity has not been created !') + ); + + return $this->render('ChillActivityBundle:Activity:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + 'person' => $person + )); + } + /** * Finds and displays a Activity entity. * diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 005644670..cd00e503a 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -69,9 +69,9 @@ class Activity implements HasCenterInterface, HasScopeInterface private \DateTime $date; /** - * @ORM\Column(type="time") + * @ORM\Column(type="time", nullable=true) */ - private \DateTime $durationTime; + private ?\DateTime $durationTime = null; /** * @ORM\Column(type="time", nullable=true) @@ -81,7 +81,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") */ - private ActivityPresence $attendee; + private ?ActivityPresence $attendee = null; /** * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") @@ -148,17 +148,11 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->users = new ArrayCollection(); } - /** - * Get id - */ public function getId(): int { return $this->id; } - /** - * Set user - */ public function setUser(User $user): self { $this->user = $user; @@ -166,17 +160,11 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - /** - * Get user - */ public function getUser(): User { return $this->user; } - /** - * Set date - */ public function setDate(\DateTime $date): self { $this->date = $date; @@ -184,28 +172,19 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - /** - * Get date - */ public function getDate(): \DateTime { return $this->date; } - /** - * Set durationTime - */ - public function setDurationTime(\DateTime $durationTime): self + public function setDurationTime(?\DateTime $durationTime): self { $this->durationTime = $durationTime; return $this; } - /** - * Get durationTime - */ - public function getDurationTime(): \DateTime + public function getDurationTime(): ?\DateTime { return $this->durationTime; } @@ -229,17 +208,14 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - public function getAttendee(): ActivityPresence + public function getAttendee(): ?ActivityPresence { return $this->attendee; } - /** - * Add a reason - */ public function addReason(ActivityReason $reason): self { - $this->reasons[] = $reason; + $this->reasons->add($reason); return $this; } @@ -249,17 +225,18 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->reasons->removeElement($reason); } - /** - * Get reasons - */ public function getReasons(): Collection { return $this->reasons; } - /** - * Set type - */ + public function setReasons(?ArrayCollection $reasons): self + { + $this->reasons = $reasons; + + return $this; + } + public function setType(ActivityType $type): self { $this->type = $type; @@ -267,17 +244,11 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - /** - * Get type - */ public function getType(): ActivityType { return $this->type; } - /** - * Set scope - */ public function setScope(Scope $scope): self { $this->scope = $scope; @@ -285,17 +256,11 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - /** - * Get scope - */ public function getScope(): ?Scope { return $this->scope; } - /** - * Set person - */ public function setPerson(Person $person): self { $this->person = $person; @@ -303,9 +268,6 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } - /** - * Get person - */ public function getPerson(): Person { return $this->person; @@ -453,9 +415,9 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->sentReceived; } - public function setSentReceived(string $sentReceived): self + public function setSentReceived(?string $sentReceived): self { - $this->sentReceived = $sentReceived; + $this->sentReceived = (string) $sentReceived; return $this; } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 2378c6db5..16e768bb2 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -134,6 +134,7 @@ class ActivityType extends AbstractType 'label' => $activityType->getLabel('reasons'), 'required' => $activityType->isRequired('reasons'), 'class' => ActivityReason::class, + 'multiple' => true, 'choice_label' => function (ActivityReason $activityReason) { return $this->translatableStringHelper->localize($activityReason->getName()); }, @@ -172,6 +173,7 @@ class ActivityType extends AbstractType 'label' => $activityType->getLabel('thirdParties'), 'required' => $activityType->isRequired('thirdParties'), 'class' => ThirdParty::class, + 'multiple' => true, 'choice_label' => function (ThirdParty $thirdParty) { return $thirdParty->getName(); }, @@ -189,6 +191,7 @@ class ActivityType extends AbstractType 'label' => $activityType->getLabel('users'), 'required' => $activityType->isRequired('users'), 'class' => User::class, + 'multiple' => true, 'choice_label' => function (User $user) { return $user->getUsername(); }, diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 11edc2c4c..1c88f9494 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -24,6 +24,7 @@

      {{ "Activity creation"|trans }}

      {{ form_start(form) }} + {{ form_errors(form) }} {{ form_row(form.user) }} {{ form_row(form.scope) }} diff --git a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml index 342ccf7d3..7c7e2bb85 100644 --- a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml @@ -13,6 +13,7 @@ chill_activity_activity_select_type: chill_activity_activity_new: path: /{_locale}/person/{person_id}/activity/new controller: Chill\ActivityBundle\Controller\ActivityController::newAction + methods: [POST, GET] chill_activity_activity_create: path: /{_locale}/person/{person_id}/activity/create diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210506071150.php b/src/Bundle/ChillActivityBundle/migrations/Version20210506071150.php new file mode 100644 index 000000000..3a1a4e513 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210506071150.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE activity ALTER durationtime DROP NOT NULL'); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activity ALTER durationTime SET NOT NULL'); + } +} diff --git a/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php b/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php index 4db950e6c..29d189155 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php @@ -31,13 +31,13 @@ final class ChillMarkdownRenderExtension extends AbstractExtension * @var Parsedown */ protected $parsedown; - + public function __construct() { $this->parsedown = new Parsedown(); $this->parsedown->setSafeMode(true); } - + public function getFilters(): array { return [ @@ -46,9 +46,9 @@ final class ChillMarkdownRenderExtension extends AbstractExtension ]) ]; } - - public function renderMarkdownToHtml(string $var): string + + public function renderMarkdownToHtml(?string $var): string { - return $this->parsedown->parse($var); + return $this->parsedown->parse((string) $var); } } From 4fd13440c6d575164b2bf4e04316e5ce5a63ad03 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 10:03:49 +0200 Subject: [PATCH 013/116] Modernize ActivityController --- .../Controller/ActivityController.php | 155 +++--------------- .../config/routes/activity.yaml | 11 +- 2 files changed, 22 insertions(+), 144 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index a30e23532..37f32af28 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -49,13 +49,6 @@ class ActivityController extends AbstractController protected LoggerInterface $logger; - /** - * ActivityController constructor. - * - * @param EventDispatcherInterface $eventDispatcher - * @param AuthorizationHelper $authorizationHelper - * @param \Psr\Log\LoggerInterface $logger - */ public function __construct( EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper, @@ -68,9 +61,8 @@ class ActivityController extends AbstractController /** * Lists all Activity entities. - * */ - public function listAction($person_id) + public function listAction($person_id): Response { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -121,16 +113,12 @@ class ActivityController extends AbstractController ]); } - /** - * Displays a form to create a new Activity entity. - * - */ - public function newAction($person_id, Request $request) + public function newAction($person_id, Request $request): Response { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if ($person === NULL){ + if (null === $person) { throw $this->createNotFoundException('Person not found'); } @@ -180,47 +168,7 @@ class ActivityController extends AbstractController )); } - - /** - * Creates a new Activity entity. - * - */ - public function createAction($person_id, Request $request) - { - $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - - if ($person === NULL) { - throw $this->createNotFoundException('person not found'); - } - - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - - $entity = new Activity(); - $entity->setPerson($person); - $form = $this->createCreateForm($entity); - $form->handleRequest($request); - - - - $this->get('session') - ->getFlashBag()->add('danger', - $this->get('translator') - ->trans('The form is not valid. The activity has not been created !') - ); - - return $this->render('ChillActivityBundle:Activity:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - 'person' => $person - )); - } - - /** - * Finds and displays a Activity entity. - * - */ - public function showAction($person_id, $id) + public function showAction($person_id, $id): Response { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -259,7 +207,7 @@ class ActivityController extends AbstractController * Displays a form to edit an existing Activity entity. * */ - public function editAction($person_id, $id) + public function editAction($person_id, $id, Request $request): Response { $em = $this->getDoctrine()->getManager(); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); @@ -278,7 +226,21 @@ class ActivityController extends AbstractController $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); - $editForm = $this->createEditForm($entity); + $form = $this->createForm(ActivityType::class, $entity, [ + 'center' => $entity->getCenter(), + 'role' => new Role('CHILL_ACTIVITY_UPDATE'), + 'activityType' => $entity->getType(), + ])->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em->persist($entity); + $em->flush(); + + $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); + + return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); + } + $deleteForm = $this->createDeleteForm($id, $person); $event = new PrivacyEvent($person, array( @@ -290,87 +252,12 @@ class ActivityController extends AbstractController return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( 'entity' => $entity, - 'edit_form' => $editForm->createView(), + 'edit_form' => $form->createView(), 'delete_form' => $deleteForm->createView(), 'person' => $person )); } - /** - * Creates a form to edit a Activity entity. - * - * @param Activity $entity The entity - */ - private function createEditForm(Activity $entity): FormInterface - { - return $this->createForm(ActivityType::class, $entity, [ - 'action' => $this->generateUrl('chill_activity_activity_update', [ - 'id' => $entity->getId(), - 'person_id' => $entity->getPerson()->getId() - ]), - 'method' => 'PUT', - 'center' => $entity->getCenter(), - 'role' => new Role('CHILL_ACTIVITY_UPDATE'), - 'activityType' => $entity->getType(), - ]); - } - - /** - * Edits an existing Activity entity. - * - */ - public function updateAction(Request $request, $person_id, $id) - { - $em = $this->getDoctrine()->getManager(); - - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find Activity entity.'); - } - - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); - - $deleteForm = $this->createDeleteForm($id, $person); - $editForm = $this->createEditForm($entity); - $editForm->handleRequest($request); - - $event = new PrivacyEvent($person, array( - 'element_class' => Activity::class, - 'element_id' => $entity->getId(), - 'action' => 'update' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - if ($editForm->isValid()) { - $em->flush(); - - $this->get('session') - ->getFlashBag() - ->add('success', - $this->get('translator') - ->trans('Success : activity updated!') - ); - - return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); - } - - $this->get('session') - ->getFlashBag() - ->add('error', - $this->get('translator') - ->trans('This form contains errors') - ); - - return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( - 'person' => $entity->getPerson(), - 'entity' => $entity, - 'edit_form' => $editForm->createView(), - 'delete_form' => $deleteForm->createView(), - )); - } - /** * Deletes a Activity entity. * diff --git a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml index 7c7e2bb85..62459db5d 100644 --- a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml @@ -15,19 +15,10 @@ chill_activity_activity_new: controller: Chill\ActivityBundle\Controller\ActivityController::newAction methods: [POST, GET] -chill_activity_activity_create: - path: /{_locale}/person/{person_id}/activity/create - controller: Chill\ActivityBundle\Controller\ActivityController::createAction - methods: POST - chill_activity_activity_edit: path: /{_locale}/person/{person_id}/activity/{id}/edit controller: Chill\ActivityBundle\Controller\ActivityController::editAction - -chill_activity_activity_update: - path: /{_locale}/person/{person_id}/activity/{id}/update - controller: Chill\ActivityBundle\Controller\ActivityController::updateAction - methods: [POST, PUT] + methods: [GET, POST, PUT] chill_activity_activity_delete: path: /{_locale}/person/{person_id}/activity/{id}/delete From f836114d8480ef109daec85d5bd42140228d6907 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 10:51:17 +0200 Subject: [PATCH 014/116] Fix travelTime field --- .../ChillActivityBundle/Form/ActivityType.php | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 16e768bb2..05a3cac36 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -219,23 +219,25 @@ class ActivityType extends AbstractType ]); } - $builder->get('durationTime') - ->addModelTransformer($durationTimeTransformer); + foreach (['durationTime', 'travelTime'] as $fieldName) { + $builder->get($fieldName) + ->addModelTransformer($durationTimeTransformer); - $builder->get('durationTime') - ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use ( + $builder->get($fieldName) + ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use ( $timeChoices, $builder, $durationTimeTransformer, - $durationTimeOptions + $durationTimeOptions, + $fieldName ) { // set the timezone to GMT, and fix the difference between current and GMT // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new \DateTimeZone('GMT'); /* @var $data \DateTime */ $data = $formEvent->getData() === NULL ? - \DateTime::createFromFormat('U', 300) : - $formEvent->getData(); + \DateTime::createFromFormat('U', 300) : + $formEvent->getData(); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new \DateInterval('PT'.$seconds.'S')); @@ -245,9 +247,8 @@ class ActivityType extends AbstractType if (!in_array($data->getTimestamp(), $timeChoices)) { // the data are not in the possible values. add them $timeChoices[$data->format('H:i')] = $data->getTimestamp(); - $form = $builder->create('durationTime', ChoiceType::class, array_merge( - $durationTimeOptions, - [ + $form = $builder->create($fieldName, ChoiceType::class, array_merge( + $durationTimeOptions, [ 'choices' => $timeChoices, 'auto_initialize' => false ] @@ -255,9 +256,12 @@ class ActivityType extends AbstractType $form->addModelTransformer($durationTimeTransformer); $formEvent->getForm()->getParent()->add($form->getForm()); } - }); + }); + } } + + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ From 1f1b9c594f06e72f9329a82ccf9ded8bffd0f963 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 11:53:07 +0200 Subject: [PATCH 015/116] add ordoring field & Display Activity type by Category --- .../Controller/ActivityController.php | 19 +++++++++--- .../AdminActivityTypeCategoryController.php | 2 +- .../AdminActivityTypeController.php | 2 +- .../Entity/ActivityType.php | 19 +++++++++++- .../Entity/ActivityTypeCategory.php | 17 ++++++++++ .../Form/ActivityTypeCategoryType.php | 8 ++++- .../Form/ActivityTypeType.php | 5 +++ .../views/Activity/selectType.html.twig | 22 +++++++------ .../migrations/Version20210506090417.php | 26 ++++++++++++++++ .../migrations/Version20210506094520.php | 31 +++++++++++++++++++ 10 files changed, 134 insertions(+), 17 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210506090417.php create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210506094520.php diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 37f32af28..94e4cc85f 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -27,7 +27,6 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -104,12 +103,24 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Person not found'); } - $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) - ->findBy(['active' => true]); + $data = []; + + $activityTypeCategories = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityTypeCategory::class) + ->findBy(['active' => true], ['ordering' => 'ASC']); + + foreach ($activityTypeCategories as $activityTypeCategory) { + $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) + ->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']); + + $data[] = [ + 'activityTypeCategory' => $activityTypeCategory, + 'activityTypes' => $activityTypes, + ]; + } return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ 'person' => $person, - 'activityTypes' => $activityTypes, + 'data' => $data, ]); } diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php index 149e83d28..1aef0c183 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php @@ -18,6 +18,6 @@ class AdminActivityTypeCategoryController extends CRUDController protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { /** @var \Doctrine\ORM\QueryBuilder $query */ - return $query->orderBy('e.id', 'ASC'); + return $query->orderBy('e.ordering', 'ASC'); } } diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php index c872bc0f4..8bf5da13d 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php @@ -18,6 +18,6 @@ class AdminActivityTypeController extends CRUDController protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { /** @var \Doctrine\ORM\QueryBuilder $query */ - return $query->orderBy('e.id', 'ASC'); + return $query->orderBy('e.ordering', 'ASC'); } } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 65fc243d5..50cd7082e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -54,7 +54,7 @@ class ActivityType private bool $active = true; /** - * ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityTypeCategory") + * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityTypeCategory") */ private ?ActivityTypeCategory $category = null; @@ -228,6 +228,11 @@ class ActivityType */ private string $socialDataLabel = ''; + /** + * @ORM\Column(type="float", options={"default"="0.0"}) + */ + private float $ordering = 0.0; + /** * Get id */ @@ -665,4 +670,16 @@ class ActivityType return $this->$property; } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): self + { + $this->ordering = $ordering; + + return $this; + } } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index 4ee84edba..2da799980 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -49,6 +49,11 @@ class ActivityTypeCategory */ private bool $active = true; + /** + * @ORM\Column(type="float", options={"default"="0.0"}) + */ + private float $ordering = 0.0; + /** * Get id */ @@ -103,4 +108,16 @@ class ActivityTypeCategory return $this; } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): self + { + $this->ordering = $ordering; + + return $this; + } } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php index 8cc90b061..0c592f519 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeCategoryType.php @@ -4,6 +4,7 @@ namespace Chill\ActivityBundle\Form; use Chill\ActivityBundle\Entity\ActivityTypeCategory; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -21,7 +22,12 @@ class ActivityTypeCategoryType extends AbstractType 'No' => false ), 'expanded' => true - )); + )) + ->add('ordering', NumberType::class, [ + 'required' => true, + 'scale' => 5 + ]) + ; } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 9a819ddf1..d1a46b109 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -7,6 +7,7 @@ use Chill\ActivityBundle\Form\Type\ActivityFieldPresence; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,6 +40,10 @@ class ActivityTypeType extends AbstractType return $this->translatableStringHelper->localize($activityTypeCategory->getName()); }, ]) + ->add('ordering', NumberType::class, [ + 'required' => true, + 'scale' => 5 + ]) ; $fields = [ diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig index 9e3407337..dfd26bad1 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -8,13 +8,17 @@

      {{ "Activity creation"|trans }}

      {# TODO: refaire l'html css des tuilles #} -
      - {% for activityType in activityTypes %} - -
      - {{ activityType.name|localize_translatable_string }} -
      -
      - {% endfor %} -
      + + {% for row in data %} +

      {{ row.activityTypeCategory.name|localize_translatable_string }}

      +
      + {% for activityType in row.activityTypes %} + +
      + {{ activityType.name|localize_translatable_string }} +
      +
      + {% endfor %} +
      + {% endfor %} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210506090417.php b/src/Bundle/ChillActivityBundle/migrations/Version20210506090417.php new file mode 100644 index 000000000..b1e4e43fc --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210506090417.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE activitytype ADD ordering DOUBLE PRECISION DEFAULT \'0.0\' NOT NULL'); + $this->addSql('ALTER TABLE activitytypecategory ADD ordering DOUBLE PRECISION DEFAULT \'0.0\' NOT NULL'); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activitytypecategory DROP ordering'); + $this->addSql('ALTER TABLE activitytype DROP ordering'); + } +} diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210506094520.php b/src/Bundle/ChillActivityBundle/migrations/Version20210506094520.php new file mode 100644 index 000000000..a31d23ae4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210506094520.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE activitytype ADD category_id INT DEFAULT 1'); + $this->addSql('ALTER TABLE activitytype ADD CONSTRAINT FK_B38CD05112469DE2 FOREIGN KEY (category_id) REFERENCES activitytypecategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE activitytype DROP CONSTRAINT FK_B38CD05112469DE2');; + $this->addSql('ALTER TABLE activitytype DROP category_id'); + } +} From fc172fdb1f4dfca6b1cda5dc6c03411a89fa45b3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 13:40:25 +0200 Subject: [PATCH 016/116] Add documents to Activity Form --- .../ChillActivityBundle/Entity/Activity.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 13 +++++- .../Resources/views/Activity/edit.html.twig | 14 +++++-- .../Resources/views/Activity/new.html.twig | 15 +++++-- .../migrations/Version20210506112500.php | 42 +++++++++++++++++++ 5 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210506112500.php diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index cd00e503a..d66737ff6 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -119,7 +119,7 @@ class Activity implements HasCenterInterface, HasScopeInterface private Collection $thirdParties; /** - * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\Document") + * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject") */ private Collection $documents; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 05a3cac36..c4f918396 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -5,6 +5,8 @@ namespace Chill\ActivityBundle\Form; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityPresence; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\DocStoreBundle\Form\StoredObjectType; +use Chill\MainBundle\Form\Type\ChillCollectionType; use Chill\MainBundle\Form\Type\CommentType; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; @@ -12,6 +14,7 @@ use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -183,8 +186,14 @@ class ActivityType extends AbstractType ]); } - // TODO : documents - //$documents + if ($activityType->isVisible('documents')) { + $builder->add('documents', ChillCollectionType::class, [ + 'entry_type' => StoredObjectType::class, + 'label' => $activityType->getLabel('documents'), + 'required' => $activityType->isRequired('documents'), + 'allow_add' => true, + ]); + } if ($activityType->isVisible('users')) { $builder->add('users', EntityType::class, [ diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index e4db4d943..fb84ae725 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -63,6 +63,9 @@ {%- if form.sentReceived is defined -%} {{ form_row(form.sentReceived) }} {% endif %} + {%- if form.documents is defined -%} + {{ form_row(form.documents) }} + {% endif %} {{ form_widget(edit_form) }}
        @@ -81,7 +84,12 @@ {% endblock %} {% block js %} - + + +{% endblock %} + +{% block css %} + {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 1c88f9494..5323815fd 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -65,6 +65,10 @@ {{ form_row(form.sentReceived) }} {% endif %} + {%- if form.documents is defined -%} + {{ form_row(form.documents) }} + {% endif %} +
        @@ -72,7 +76,12 @@ {% endblock %} {% block js %} - + + +{% endblock %} + +{% block css %} + {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210506112500.php b/src/Bundle/ChillActivityBundle/migrations/Version20210506112500.php new file mode 100644 index 000000000..ca80d7720 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210506112500.php @@ -0,0 +1,42 @@ +addSql('CREATE TABLE activity_storedobject (activity_id INT NOT NULL, storedobject_id INT NOT NULL, PRIMARY KEY(activity_id, storedobject_id))'); + $this->addSql('CREATE INDEX IDX_6F660E9381C06096 ON activity_storedobject (activity_id)'); + $this->addSql('CREATE INDEX IDX_6F660E93EE684399 ON activity_storedobject (storedobject_id)'); + $this->addSql('ALTER TABLE activity_storedobject ADD CONSTRAINT FK_6F660E9381C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE activity_storedobject ADD CONSTRAINT FK_6F660E93EE684399 FOREIGN KEY (storedobject_id) REFERENCES chill_doc.stored_object (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('DROP TABLE activity_document'); + + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('CREATE TABLE activity_document (activity_id INT NOT NULL, document_id INT NOT NULL, PRIMARY KEY(activity_id, document_id))'); + $this->addSql('CREATE INDEX idx_78633a78c33f7837 ON activity_document (document_id)'); + $this->addSql('CREATE INDEX idx_78633a7881c06096 ON activity_document (activity_id)'); + $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT fk_78633a7881c06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('DROP TABLE activity_storedobject'); + } +} From c6cd785262d85bb328e00de8d0c546d75ffd1776 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 15:09:38 +0200 Subject: [PATCH 017/116] add Translations --- .../translations/messages.fr.yml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index cc323f392..0693d4a22 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -5,6 +5,7 @@ Activity: Activité Duration time: Durée Duration Time: Durée durationTime: durée +Travel time: Durée de déplacement Reasons: Sujets Attendee: Présence de la personne attendee: présence de la personne @@ -32,6 +33,13 @@ Type: Type Invisible: Invisible Optional: Optionnel Required: Obligatoire +Persons: Personnes +Users: Utilisateurs +Emergency: Urgent +Sent received: Envoyer / Recevoir +Sent: Envoyer +Received: Recevoir + #forms Activity creation: Nouvelle activité @@ -113,6 +121,34 @@ ActivityReasonCategory is inactive and won't be proposed: La catégorie est inac # activity type type admin ActivityType list: Types d'activités Create a new activity type: Créer un nouveau type d'activité +Persons visible: Visibilté du champ Personnes +Persons label: Libellé du champ Personnes +User visible: Visibilté du champ Utilisateur +User label: Libellé du champ Utilisateur +Date visible: Visibilté du champ Date +Date label: Libellé du champ Date +Place visible: Visibilté du champ Lieu +Place label: Libellé du champ Lieu +Third parties visible: Visibilté du champ Tiers +Third parties label: Libellé du champ Tiers +Duration time visible: Visibilté du champ Durée +Duration time label: Libellé du champ Durée +Travel time visible: Visibilté du champ Durée de déplacement +Travel time label: Libellé du champ Durée de déplacement +Attendee visible: Visibilté du champ Présence de l'usager +Attendee label: Libellé du champ Présence de l'usager +Reasons visible: Visibilté du champ Sujet +Reasons label: Libellé du champ Sujet +Comment visible: Visibilté du champ Commentaire +Comment label: Libellé du champ Commentaire +Emergency visible: Visibilté du champ Urgent +Emergency label: Libellé du champ Urgent +Accompanying period visible: Visibilté du champ Période d'accompagnement +Accompanying period label: Libellé du champ Période d'accompagnement +Social data visible: Visibilté du champ Données sociales +Social data label: Libellé du champ Données sociales +Users visible: Visibilté du champ Utilisateurs +Users label: Libellé du champ Utilisateurs # activity type category admin ActivityTypeCategory list: Liste des catégories des types d'activité From 1f838d9c5a8935cd96eac3f239f34bed63aa229a Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 6 May 2021 16:23:34 +0200 Subject: [PATCH 018/116] Fix Activity fixtures --- .../ChillActivityBundle/DataFixtures/ORM/LoadActivity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index dd24cfcd2..de1ea97c2 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -116,9 +116,10 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C ->setDurationTime($this->faker->dateTime(36000)) ->setType($this->getRandomActivityType()) ->setScope($this->getRandomScope()) - ->setAttendee($this->faker->boolean()) ; + // ->setAttendee($this->faker->boolean()) + $usedId = array(); for ($i = 0; $i < rand(0, 4); $i++) { $reason = $this->getRandomActivityReason($usedId); From 8fe00b4c2b3b2125e4376b4e531804a6039aadb0 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 20 May 2021 15:56:34 +0200 Subject: [PATCH 019/116] Add / Edit / Delete activity from Accompanying Course --- .../Controller/ActivityController.php | 289 ++++++++++++------ .../ChillActivityBundle/Entity/Activity.php | 38 ++- .../ChillActivityBundle/Form/ActivityType.php | 21 +- .../Menu/AccompanyingCourseMenuBuilder.php | 48 +++ ...confirm_deleteAccompanyingCourse.html.twig | 16 + ...ml.twig => confirm_deletePerson.html.twig} | 2 - .../Resources/views/Activity/edit.html.twig | 150 ++++----- .../Activity/editAccompanyingCourse.html.twig | 20 ++ .../views/Activity/editPerson.html.twig | 36 +++ .../Resources/views/Activity/list.html.twig | 156 +++++----- .../Activity/listAccompanyingCourse.html.twig | 9 + .../views/Activity/listPerson.html.twig | 25 ++ .../Resources/views/Activity/new.html.twig | 128 +++----- .../Activity/newAccompanyingCourse.html.twig | 20 ++ .../views/Activity/newPerson.html.twig | 20 ++ .../views/Activity/selectType.html.twig | 42 +-- .../selectTypeAccompanyingCourse.html.twig | 9 + .../views/Activity/selectTypePerson.html.twig | 9 + .../Resources/views/Activity/show.html.twig | 117 +++---- .../Activity/showAccompanyingCourse.html.twig | 11 + .../views/Activity/showPerson.html.twig | 11 + .../config/routes/activity.yaml | 12 +- .../config/services/menu.yaml | 8 + .../migrations/Version20210520095626.php | 31 ++ 24 files changed, 795 insertions(+), 433 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig rename src/Bundle/ChillActivityBundle/Resources/views/Activity/{confirm_delete.html.twig => confirm_deletePerson.html.twig} (99%) create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 94e4cc85f..4ae8fe7d0 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -23,10 +23,12 @@ namespace Chill\ActivityBundle\Controller; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Form; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -61,46 +63,57 @@ class ActivityController extends AbstractController /** * Lists all Activity entities. */ - public function listAction($person_id): Response + public function listAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $view = null; - if ($person === NULL) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($person instanceof Person) { + $reachableScopes = $this->authorizationHelper + ->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), + $person->getCenter()); + + $activities = $em->getRepository('ChillActivityBundle:Activity')->findBy( + ['person' => $person, 'scope' => $reachableScopes], + ['date' => 'DESC'], + ); + + $event = new PrivacyEvent($person, array( + 'element_class' => Activity::class, + 'action' => 'list' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + $view = 'ChillActivityBundle:Activity:listPerson.html.twig'; + } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { + $activities = $em->getRepository('ChillActivityBundle:Activity')->findBy( + ['accompanyingPeriod' => $accompanyingPeriod], + ['date' => 'DESC'], + ); + + $view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - - $reachableScopes = $this->authorizationHelper - ->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), - $person->getCenter()); - - $activities = $em->getRepository('ChillActivityBundle:Activity') - ->findBy( - array('person' => $person, 'scope' => $reachableScopes), - array('date' => 'DESC') - ); - - $event = new PrivacyEvent($person, array( - 'element_class' => Activity::class, - 'action' => 'list' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->render('ChillActivityBundle:Activity:list.html.twig', array( + return $this->render($view, array( 'activities' => $activities, - 'person' => $person + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); } - public function selectTypeAction(int $person_id): Response + public function selectTypeAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository(Person::class)->find($person_id); + $view = null; - if ($person === NULL) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:selectTypeAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:selectTypePerson.html.twig'; } $data = []; @@ -118,19 +131,27 @@ class ActivityController extends AbstractController ]; } - return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ - 'person' => $person, + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, [ + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'data' => $data, ]); } - public function newAction($person_id, Request $request): Response + public function newAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (null === $person) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:newAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:newPerson.html.twig'; } $activityType_id = $request->get('activityType_id', 0); @@ -139,20 +160,27 @@ class ActivityController extends AbstractController if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType || !$activityType->isActive()) { - return $this->redirectToRoute('chill_activity_activity_select_type', [ - 'person_id' => $person->getId(), - ]); - } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + return $this->redirectToRoute('chill_activity_activity_select_type', $params); + } $entity = new Activity(); $entity->setUser($this->getUser()); - $entity->setPerson($person); + + if ($person instanceof Person) { + $entity->setPerson($person); + } + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $entity->setAccompanyingPeriod($accompanyingPeriod); + } + $entity->setType($activityType); $entity->setDate(new \DateTime('now')); - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); + // TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); $form = $this->createForm(ActivityType::class, $entity, [ 'center' => $entity->getCenter(), @@ -166,49 +194,64 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : activity created!')); - return $this->redirectToRoute('chill_activity_activity_show', [ - 'id' => $entity->getId(), - 'person_id' => $person_id - ]); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $entity->getId(); + + return $this->redirectToRoute('chill_activity_activity_show', $params); } - return $this->render('ChillActivityBundle:Activity:new.html.twig', array( + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, [ 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, - 'form' => $form->createView(), - )); + 'form' => $form->createView(), + ]); } - public function showAction($person_id, $id): Response + public function showAction(Request $request, $id): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (!$person) { - throw $this->createNotFoundException('person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:showAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:showPerson.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity); + // TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity); - $deleteForm = $this->createDeleteForm($id, $person); + $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod); + // TODO + /* $event = new PrivacyEvent($person, array( 'element_class' => Activity::class, 'element_id' => $entity->getId(), 'action' => 'show' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + */ - return $this->render('ChillActivityBundle:Activity:show.html.twig', array( + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, array( 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, 'delete_form' => $deleteForm->createView(), )); @@ -218,24 +261,26 @@ class ActivityController extends AbstractController * Displays a form to edit an existing Activity entity. * */ - public function editAction($person_id, $id, Request $request): Response + public function editAction($id, Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (!$person) { - throw $this->createNotFoundException('person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:editPerson.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); + // TODO + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); $form = $this->createForm(ActivityType::class, $entity, [ 'center' => $entity->getCenter(), @@ -249,23 +294,29 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); - return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $id; + return $this->redirectToRoute('chill_activity_activity_show', $params); } - $deleteForm = $this->createDeleteForm($id, $person); + $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod); + /* + * TODO $event = new PrivacyEvent($person, array( 'element_class' => Activity::class, 'element_id' => $entity->getId(), 'action' => 'edit' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + */ - return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), 'delete_form' => $deleteForm->createView(), - 'person' => $person + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); } @@ -273,22 +324,29 @@ class ActivityController extends AbstractController * Deletes a Activity entity. * */ - public function deleteAction(Request $request, $id, $person_id) + public function deleteAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig'; + } + /* @var $activity Activity */ - $activity = $em->getRepository('ChillActivityBundle:Activity') - ->find($id); - $person = $activity->getPerson(); + $activity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$activity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity); + // TODO + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity); - $form = $this->createDeleteForm($id, $person); + $form = $this->createDeleteForm($id, $person, $accompanyingPeriod); if ($request->getMethod() === Request::METHOD_DELETE) { $form->handleRequest($request); @@ -298,14 +356,14 @@ class ActivityController extends AbstractController $this->logger->notice("An activity has been removed", array( 'by_user' => $this->getUser()->getUsername(), 'activity_id' => $activity->getId(), - 'person_id' => $activity->getPerson()->getId(), + 'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null, 'comment' => $activity->getComment()->getComment(), - 'scope_id' => $activity->getScope()->getId(), + 'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null, 'reasons_ids' => $activity->getReasons() ->map(function ($ar) { return $ar->getId(); }) ->toArray(), 'type_id' => $activity->getType()->getId(), - 'duration' => $activity->getDurationTime()->format('U'), + 'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null, 'date' => $activity->getDate()->format('Y-m-d'), 'attendee' => $activity->getAttendee() )); @@ -316,37 +374,82 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator') ->trans("The activity has been successfully removed.")); - return $this->redirect($this->generateUrl( - 'chill_activity_activity_list', array( - 'person_id' => $person_id - ))); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + return $this->redirectToRoute('chill_activity_activity_list', $params); } } - return $this->render('ChillActivityBundle:Activity:confirm_delete.html.twig', array( + return $this->render($view, array( 'activity' => $activity, - 'delete_form' => $form->createView() + 'delete_form' => $form->createView(), + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); - - } /** * Creates a form to delete a Activity entity by id. - * - * @param mixed $id The entity id - * - * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id, $person) + private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): Form { + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $id; + return $this->createFormBuilder() - ->setAction($this->generateUrl( - 'chill_activity_activity_delete', - array('id' => $id, 'person_id' => $person->getId()))) + ->setAction($this->generateUrl('chill_activity_activity_delete', $params)) ->setMethod('DELETE') ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() ; } + + private function getEntity(Request $request): array + { + $em = $this->getDoctrine()->getManager(); + $person = $accompanyingPeriod = null; + + if ($request->query->has('person_id')) { + $person_id = $request->get('person_id'); + $person = $em->getRepository(Person::class)->find($person_id); + + if ($person === null) { + throw $this->createNotFoundException('Person not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + } elseif ($request->query->has('accompanying_period_id')) { + $accompanying_period_id = $request->get('accompanying_period_id'); + $accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id); + + if ($accompanyingPeriod === null) { + throw $this->createNotFoundException('Accompanying Period not found'); + } + + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + } else { + throw $this->createNotFoundException("Person or Accompanying Period not found"); + } + + return [ + $person, $accompanyingPeriod + ]; + } + + private function buildParamsToUrl( + ?Person $person, + ?AccompanyingPeriod $accompanyingPeriod + ): array { + $params = []; + + if ($person) { + $params['person_id'] = $person->getId(); + } + + if ($accompanyingPeriod) { + $params['accompanying_period_id'] = $accompanyingPeriod->getId(); + } + + return $params; + } } diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index d66737ff6..0b35d961e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -22,6 +22,7 @@ namespace Chill\ActivityBundle\Entity; use Chill\DocStoreBundle\Entity\Document; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\Scope; @@ -41,11 +42,16 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; * @ORM\Entity() * @ORM\Table(name="activity") * @ORM\HasLifecycleCallbacks() + */ + +/* + * TODO : revoir * @UserCircleConsistency( * "CHILL_ACTIVITY_SEE_DETAILS", * getUserFunction="getUser", * path="scope") */ + class Activity implements HasCenterInterface, HasScopeInterface { const SENTRECEIVED_SENT = 'sent'; @@ -101,7 +107,12 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ - private Person $person; + private ?Person $person = null; + + /** + * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") + */ + private ?AccompanyingPeriod $accompanyingPeriod = null; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") @@ -261,25 +272,41 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->scope; } - public function setPerson(Person $person): self + public function setPerson(?Person $person): self { $this->person = $person; return $this; } - public function getPerson(): Person + public function getPerson(): ?Person { return $this->person; } + public function getAccompanyingPeriod(): ?AccompanyingPeriod + { + return $this->accompanyingPeriod; + } + + public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self + { + $this->accompanyingPeriod = $accompanyingPeriod; + + return $this; + } + /** * get the center * center is extracted from person */ - public function getCenter(): Center + public function getCenter(): ?Center { - return $this->person->getCenter(); + if ($this->person instanceof Person) { + return $this->person->getCenter(); + } + + return null; } public function getComment(): CommentEmbeddable @@ -422,4 +449,3 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } } - diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index c4f918396..99279b099 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -82,10 +82,13 @@ class ActivityType extends AbstractType throw new \InvalidArgumentException('Activity type must be active'); } - $builder->add('scope', ScopePickerType::class, [ - 'center' => $options['center'], - 'role' => $options['role'] - ]); + // TODO revoir la gestion des center au niveau du form des activité. + if ($options['center']) { + $builder->add('scope', ScopePickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]); + } if ($activityType->isVisible('date')) { $builder->add('date', ChillDateType::class, [ @@ -108,7 +111,7 @@ class ActivityType extends AbstractType $builder->add('travelTime', ChoiceType::class, $durationTimeOptions); } - if ($activityType->isVisible('travelTime')) { + if ($activityType->isVisible('attendee')) { $builder->add('attendee', EntityType::class, [ 'label' => $activityType->getLabel('attendee'), 'required' => $activityType->isRequired('attendee'), @@ -123,7 +126,7 @@ class ActivityType extends AbstractType ]); } - if ($activityType->isVisible('user')) { + if ($activityType->isVisible('user') && $options['center']) { $builder->add('user', UserPickerType::class, [ 'label' => $activityType->getLabel('user'), 'required' => $activityType->isRequired('user'), @@ -229,6 +232,10 @@ class ActivityType extends AbstractType } foreach (['durationTime', 'travelTime'] as $fieldName) { + if (!$activityType->isVisible($fieldName)) { + continue; + } + $builder->get($fieldName) ->addModelTransformer($durationTimeTransformer); @@ -279,7 +286,7 @@ class ActivityType extends AbstractType $resolver ->setRequired(['center', 'role', 'activityType']) - ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') + ->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center']) ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) ; diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php new file mode 100644 index 000000000..ba0672bb0 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -0,0 +1,48 @@ +translator = $translator; + $this->authorizationHelper = $authorizationHelper; + $this->tokenStorage = $tokenStorage; + } + public static function getMenuIds(): array + { + return ['accompanyingCourse']; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + $period = $parameters['accompanyingCourse']; + + $menu->addChild($this->translator->trans('Add a new activity'), [ + 'route' => 'chill_activity_activity_select_type', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId() + ]]) + ->setExtras(['order' => 40]); + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig new file mode 100644 index 000000000..fbdf45c23 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Remove activity'|trans %} + +{% block content %} + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove activity'|trans, + 'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ), + 'cancel_route' : 'chill_activity_activity_list', + 'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : activity.id }, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig similarity index 99% rename from src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig rename to src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig index 5cd8f15a0..2d8e2affc 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig @@ -6,7 +6,6 @@ {% block title 'Remove activity'|trans %} {% block personcontent %} - {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove activity'|trans, @@ -15,5 +14,4 @@ 'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id }, 'form' : delete_form } ) }} - {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index fb84ae725..0625174ac 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -1,95 +1,75 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +

        {{ "Update activity"|trans }}

        -{% set activeRouteKey = 'chill_activity_activity_list' %} - -{% block title 'Update activity'|trans %} - -{% block personcontent %} -

        {{ "Update activity"|trans }}

        - - {{ form_start(edit_form) }} +{{ form_start(edit_form) }} +{%- if edit_form.user is defined -%} {{ form_row(edit_form.user) }} +{% endif %} + +{%- if edit_form.scope is defined -%} {{ form_row(edit_form.scope) }} +{% endif %} -

        {{ 'Activity data'|trans }}

        +

        {{ 'Activity data'|trans }}

        - {%- if form.date is defined -%} - {{ form_row(form.date) }} - {% endif %} - {%- if form.durationTime is defined -%} - {{ form_row(form.durationTime) }} - {% endif %} - {%- if form.travelTime is defined -%} - {{ form_row(form.travelTime) }} - {% endif %} - {%- if form.attendee is defined -%} - {{ form_row(form.attendee) }} - {% endif %} - {%- if form.comment is defined -%} - {{ form_row(form.comment) }} - {% endif %} - {%- if form.reasons is defined -%} - {{ form_row(form.reasons) }} - {% endif %} - {%- if form.persons is defined -%} - {{ form_row(form.persons) }} - {% endif %} - {%- if form.thirdParties is defined -%} - {{ form_row(form.thirdParties) }} - {% endif %} - {%- if form.users is defined -%} - {{ form_row(form.users) }} - {% endif %} - {%- if form.emergency is defined -%} - {{ form_row(form.emergency) }} - {% endif %} - {%- if form.sentReceived is defined -%} - {{ form_row(form.sentReceived) }} - {% endif %} - {%- if form.documents is defined -%} - {{ form_row(form.documents) }} - {% endif %} +{%- if form.date is defined -%} + {{ form_row(form.date) }} +{% endif %} +{%- if form.durationTime is defined -%} + {{ form_row(form.durationTime) }} +{% endif %} +{%- if form.travelTime is defined -%} + {{ form_row(form.travelTime) }} +{% endif %} +{%- if form.attendee is defined -%} + {{ form_row(form.attendee) }} +{% endif %} +{%- if form.comment is defined -%} + {{ form_row(form.comment) }} +{% endif %} +{%- if form.reasons is defined -%} + {{ form_row(form.reasons) }} +{% endif %} +{%- if form.persons is defined -%} + {{ form_row(form.persons) }} +{% endif %} +{%- if form.thirdParties is defined -%} + {{ form_row(form.thirdParties) }} +{% endif %} +{%- if form.users is defined -%} + {{ form_row(form.users) }} +{% endif %} +{%- if form.emergency is defined -%} + {{ form_row(form.emergency) }} +{% endif %} +{%- if form.sentReceived is defined -%} + {{ form_row(form.sentReceived) }} +{% endif %} +{%- if form.documents is defined -%} + {{ form_row(form.documents) }} +{% endif %} - {{ form_widget(edit_form) }} - - {{ form_end(edit_form) }} +{% set person_id = null %} +{% if entity.person %} + {% set person_id = entity.person.id %} +{% endif %} - {# {{ form(delete_form) }} #} -{% endblock %} +{% set accompanying_course_id = null %} +{% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} +{% endif %} -{% block js %} - - -{% endblock %} +{{ form_widget(edit_form) }} + +{{ form_end(edit_form) }} -{% block css %} - -{% endblock %} +{# {{ form(delete_form) }} #} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig new file mode 100644 index 000000000..b9a812b09 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Update activity'|trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:edit.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig new file mode 100644 index 000000000..fc32dab49 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -0,0 +1,36 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Update activity'|trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:edit.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 94a9d9a82..de30d5366 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -1,87 +1,79 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +{% set person_id = null %} +{% if person %} + {% set person_id = person.id %} +{% endif %} -{% set activeRouteKey = 'chill_activity_activity_list' %} +{% set accompanying_course_id = null %} +{% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} +{% endif %} -{% block title %}{{ 'Activity list' |trans }}{% endblock title %} +

        {{ 'Activity list' |trans }}

        -{% block personcontent %} -

        {{ 'Activity list' |trans }}

        - - {% if activities|length == 0 %} -

        - {{ "There isn't any activities."|trans }} - -

        - {% else %} - - - - - - - - - - - - {% for activity in activities %} - - - - + + {% endfor %} + +
        {{'Date' | trans }}{{'Duration Time' | trans }}{{'Reasons' | trans}}{{'Type' | trans}} 
        {% if activity.date %}{{ activity.date|format_date('long') }}{% endif %}{{ activity.durationTime|date('H:i') }} - {% if activity.comment.comment is not empty %} - {{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} +{% if activities|length == 0 %} +

        + {{ "There isn't any activities."|trans }} + +

        +{% else %} + + + + + + + + + + + + {% for activity in activities %} + + + + + + - - - - {% endfor %} - -
        {{'Date' | trans }}{{'Duration Time' | trans }}{{'Reasons' | trans}}{{'Type' | trans}} 
        {% if activity.date %}{{ activity.date|format_date('long') }}{% endif %}{{ activity.durationTime|date('H:i') }} + {% if activity.comment.comment is not empty %} + {{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} + {% endif %} + {%- if activity.reasons is empty -%} + {{ 'No reason associated'|trans }} + {%- else -%} + {% for r in activity.reasons %}{{ r|chill_entity_render_box }} {% endfor %} + {%- endif -%} + {{ activity.type.name | localize_translatable_string }} +
          +
        • + +
        • + {# TOOD + {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} + #} +
        • + +
        • + {# TOOD {% endif %} - {%- if activity.reasons is empty -%} - {{ 'No reason associated'|trans }} - {%- else -%} - {% for r in activity.reasons %}{{ r|chill_entity_render_box }} {% endfor %} - {%- endif -%} -
        {{ activity.type.name | localize_translatable_string }} -
          -
        • - -
        • - {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} -
        • - -
        • - {% endif %} - {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} -
        • - -
        • - {% endif %} -
        - {% endif %} + {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} + #} +
      • + +
      • + {# + {% endif %} + #} +
        +{% endif %} - -{% endblock %} + diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig new file mode 100644 index 000000000..7607ac79a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity list' |trans }}{% endblock title %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:list.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig new file mode 100644 index 000000000..db441ee69 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig @@ -0,0 +1,25 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity list' |trans }}{% endblock title %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:list.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 5323815fd..b166a4a9e 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -1,87 +1,57 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +

        {{ "Activity creation"|trans }}

        -{% set activeRouteKey = 'chill_activity_activity_new' %} - -{% block title 'Activity creation' |trans %} - -{% block personcontent %} -

        {{ "Activity creation"|trans }}

        - - {{ form_start(form) }} - {{ form_errors(form) }} +{{ form_start(form) }} +{{ form_errors(form) }} +{%- if form.user is defined -%} {{ form_row(form.user) }} +{% endif %} + +{%- if form.scope is defined -%} {{ form_row(form.scope) }} +{% endif %} -

        {{ 'Activity data'|trans }}

        +

        {{ 'Activity data'|trans }}

        - {%- if form.date is defined -%} - {{ form_row(form.date) }} - {% endif %} - {%- if form.durationTime is defined -%} - {{ form_row(form.durationTime) }} - {% endif %} - {%- if form.travelTime is defined -%} - {{ form_row(form.travelTime) }} - {% endif %} - {%- if form.attendee is defined -%} - {{ form_row(form.attendee) }} - {% endif %} - {%- if form.comment is defined -%} - {{ form_row(form.comment) }} - {% endif %} - {%- if form.reasons is defined -%} - {{ form_row(form.reasons) }} - {% endif %} - {%- if form.persons is defined -%} - {{ form_row(form.persons) }} - {% endif %} - {%- if form.thirdParties is defined -%} - {{ form_row(form.thirdParties) }} - {% endif %} - {%- if form.users is defined -%} - {{ form_row(form.users) }} - {% endif %} - {%- if form.emergency is defined -%} - {{ form_row(form.emergency) }} - {% endif %} - {%- if form.sentReceived is defined -%} - {{ form_row(form.sentReceived) }} - {% endif %} +{%- if form.date is defined -%} + {{ form_row(form.date) }} +{% endif %} +{%- if form.durationTime is defined -%} + {{ form_row(form.durationTime) }} +{% endif %} +{%- if form.travelTime is defined -%} + {{ form_row(form.travelTime) }} +{% endif %} +{%- if form.attendee is defined -%} + {{ form_row(form.attendee) }} +{% endif %} +{%- if form.comment is defined -%} + {{ form_row(form.comment) }} +{% endif %} +{%- if form.reasons is defined -%} + {{ form_row(form.reasons) }} +{% endif %} +{%- if form.persons is defined -%} + {{ form_row(form.persons) }} +{% endif %} +{%- if form.thirdParties is defined -%} + {{ form_row(form.thirdParties) }} +{% endif %} +{%- if form.users is defined -%} + {{ form_row(form.users) }} +{% endif %} +{%- if form.emergency is defined -%} + {{ form_row(form.emergency) }} +{% endif %} +{%- if form.sentReceived is defined -%} + {{ form_row(form.sentReceived) }} +{% endif %} - {%- if form.documents is defined -%} - {{ form_row(form.documents) }} - {% endif %} +{%- if form.documents is defined -%} + {{ form_row(form.documents) }} +{% endif %} -
        - -
        - {{ form_end(form) }} -{% endblock %} - -{% block js %} - - -{% endblock %} - -{% block css %} - -{% endblock %} +
        + +
        +{{ form_end(form) }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig new file mode 100644 index 000000000..74152659f --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation' |trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:new.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig new file mode 100644 index 000000000..9cb89d917 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation' |trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:new.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig index dfd26bad1..76e3f25ad 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -1,24 +1,28 @@ -{% extends "@ChillPerson/layout.html.twig" %} +

        {{ "Activity creation"|trans }}

        -{% set activeRouteKey = 'chill_activity_activity_new' %} +{# TODO: refaire l'html css des tuilles #} -{% block title 'Activity creation'|trans %} +{% for row in data %} +

        {{ row.activityTypeCategory.name|localize_translatable_string }}

        +
        + {% for activityType in row.activityTypes %} -{% block personcontent %} -

        {{ "Activity creation"|trans }}

        + {% set person_id = null %} + {% if person %} + {% set person_id = person.id %} + {% endif %} - {# TODO: refaire l'html css des tuilles #} + {% set accompanying_course_id = null %} + {% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} + {% endif %} - {% for row in data %} -

        {{ row.activityTypeCategory.name|localize_translatable_string }}

        -
        - {% for activityType in row.activityTypes %} - -
        - {{ activityType.name|localize_translatable_string }} -
        -
        - {% endfor %} -
        - {% endfor %} -{% endblock %} + + +
        + {{ activityType.name|localize_translatable_string }} +
        +
        + {% endfor %} +
        +{% endfor %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig new file mode 100644 index 000000000..5e73db597 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation'|trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:selectType.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig new file mode 100644 index 000000000..cb31749fd --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation'|trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:selectType.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 73e91e8c5..f0cb5928b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -1,68 +1,77 @@ -{% extends "@ChillPerson/layout.html.twig" %} +

        {{ "Activity"|trans }}

        -{% set activeRouteKey = 'chill_activity_activity_list' %} +
        +
        {{ 'User'|trans }}
        +
        {{ entity.user }}
        -{% block title 'Activity'|trans %} - -{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} - -{% block personcontent -%} -

        {{ "Activity"|trans }}

        - -
        -
        {{ 'User'|trans }}
        -
        {{ entity.user }}
        + {%- if entity.scope -%}
        {{ 'Scope'|trans }}
        {{ entity.scope.name|localize_translatable_string }}
        + {% endif %} -

        {{ 'Activity data'|trans }}

        +

        {{ 'Activity data'|trans }}

        + + {%- if entity.person is defined -%}
        {{ 'Person'|trans }}
        {{ entity.person }}
        + {% endif %} -
        {{ 'Date'|trans }}
        -
        {{ entity.date|format_date('long') }}
        -
        {{ 'Duration Time'|trans }}
        -
        {{ entity.durationTime|date('H:i') }}
        -
        {{ 'Type'|trans }}
        -
        {{ entity.type.name | localize_translatable_string }}
        +
        {{ 'Date'|trans }}
        +
        {{ entity.date|format_date('long') }}
        +
        {{ 'Duration Time'|trans }}
        +
        {{ entity.durationTime|date('H:i') }}
        +
        {{ 'Type'|trans }}
        +
        {{ entity.type.name | localize_translatable_string }}
        -
        {{ 'Attendee'|trans }}
        -
        {% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}
        +
        {{ 'Attendee'|trans }}
        +
        {% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}
        -
        {{ 'Reasons'|trans }}
        - {%- if entity.reasons is empty -%} -
        {{ 'No reason associated'|trans }}
        - {%- else -%} -
        {% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}
        - {%- endif -%} +
        {{ 'Reasons'|trans }}
        + {%- if entity.reasons is empty -%} +
        {{ 'No reason associated'|trans }}
        + {%- else -%} +
        {% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}
        + {%- endif -%} -
        {{ 'Comment'|trans }}
        - {%- if entity.comment is empty -%} -
        {{ 'No comment associated'|trans }}
        - {%- else -%} -
        {{ entity.comment|chill_entity_render_box }}
        - {%- endif -%} +
        {{ 'Comment'|trans }}
        + {%- if entity.comment is empty -%} +
        {{ 'No comment associated'|trans }}
        + {%- else -%} +
        {{ entity.comment|chill_entity_render_box }}
        + {%- endif -%} -
        +
        - diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig new file mode 100644 index 000000000..a55b318a7 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Activity'|trans %} + +{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} + +{% block content -%} + {% include 'ChillActivityBundle:Activity:show.html.twig' %} +{% endblock content %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig new file mode 100644 index 000000000..f7d641b75 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Activity'|trans %} + +{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} + +{% block personcontent -%} + {% include 'ChillActivityBundle:Activity:show.html.twig' %} +{% endblock personcontent %} diff --git a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml index 62459db5d..179de905b 100644 --- a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml @@ -1,26 +1,26 @@ chill_activity_activity_list: - path: /{_locale}/person/{person_id}/activity/ + path: /{_locale}/activity/ controller: Chill\ActivityBundle\Controller\ActivityController::listAction chill_activity_activity_show: - path: /{_locale}/person/{person_id}/activity/{id}/show + path: /{_locale}/activity/{id}/show controller: Chill\ActivityBundle\Controller\ActivityController::showAction chill_activity_activity_select_type: - path: /{_locale}/person/{person_id}/activity/select-type + path: /{_locale}/activity/select-type controller: Chill\ActivityBundle\Controller\ActivityController::selectTypeAction chill_activity_activity_new: - path: /{_locale}/person/{person_id}/activity/new + path: /{_locale}/activity/new controller: Chill\ActivityBundle\Controller\ActivityController::newAction methods: [POST, GET] chill_activity_activity_edit: - path: /{_locale}/person/{person_id}/activity/{id}/edit + path: /{_locale}/activity/{id}/edit controller: Chill\ActivityBundle\Controller\ActivityController::editAction methods: [GET, POST, PUT] chill_activity_activity_delete: - path: /{_locale}/person/{person_id}/activity/{id}/delete + path: /{_locale}/activity/{id}/delete controller: Chill\ActivityBundle\Controller\ActivityController::deleteAction methods: [GET, POST, DELETE] diff --git a/src/Bundle/ChillActivityBundle/config/services/menu.yaml b/src/Bundle/ChillActivityBundle/config/services/menu.yaml index 2a0434996..8e60d3b2e 100644 --- a/src/Bundle/ChillActivityBundle/config/services/menu.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/menu.yaml @@ -6,3 +6,11 @@ services: $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: - { name: 'chill.menu_builder' } + + Chill\ActivityBundle\Menu\AccompanyingCourseMenuBuilder: + arguments: + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $translator: '@Symfony\Contracts\Translation\TranslatorInterface' + tags: + - { name: 'chill.menu_builder' } diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php b/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php new file mode 100644 index 000000000..f5a0abda6 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE activity ADD accompanyingPeriod_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE activity ADD CONSTRAINT FK_AC74095AD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095AD7FA8EF0'); + $this->addSql('ALTER TABLE activity DROP accompanyingPeriod_id'); + } +} From 2bae684df986fd0df8e0a60d680b9ea34ac9f049 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 20 May 2021 17:08:47 +0200 Subject: [PATCH 020/116] Add list of activities in AccompanyingCourse Menu --- .../Controller/ActivityController.php | 8 ++++++++ .../Menu/AccompanyingCourseMenuBuilder.php | 18 ++++++++++++------ .../config/services/menu.yaml | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 4ae8fe7d0..417c04909 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -311,6 +311,10 @@ class ActivityController extends AbstractController $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); */ + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), @@ -379,6 +383,10 @@ class ActivityController extends AbstractController } } + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + return $this->render($view, array( 'activity' => $activity, 'delete_form' => $form->createView(), diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php index ba0672bb0..402df733b 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -2,16 +2,12 @@ namespace Chill\ActivityBundle\Menu; -use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; - class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { protected TokenStorageInterface $tokenStorage; @@ -38,11 +34,21 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { $period = $parameters['accompanyingCourse']; + $menu->addChild($this->translator->trans('List of activities'), [ + 'route' => 'chill_activity_activity_list', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId(), + ]]) + ->setExtras(['order' => 40]); + $menu->addChild($this->translator->trans('Add a new activity'), [ 'route' => 'chill_activity_activity_select_type', 'routeParameters' => [ - 'accompanying_period_id' => $period->getId() + 'accompanying_period_id' => $period->getId(), ]]) - ->setExtras(['order' => 40]); + ->setExtras(['order' => 41]); + + + } } diff --git a/src/Bundle/ChillActivityBundle/config/services/menu.yaml b/src/Bundle/ChillActivityBundle/config/services/menu.yaml index 8e60d3b2e..1c7813799 100644 --- a/src/Bundle/ChillActivityBundle/config/services/menu.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/menu.yaml @@ -12,5 +12,6 @@ services: $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $translator: '@Symfony\Contracts\Translation\TranslatorInterface' + $entityManager: '@Doctrine\ORM\EntityManagerInterface' tags: - { name: 'chill.menu_builder' } From 52ee8c5a9ad6a061bbfeb62d7be9fe268d6b66dd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 13:27:40 +0200 Subject: [PATCH 021/116] activity: change fields order in form --- .../ChillActivityBundle/Form/ActivityType.php | 1 + .../Resources/views/Activity/new.html.twig | 60 ++++++++++++------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 99279b099..d762aedd4 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -115,6 +115,7 @@ class ActivityType extends AbstractType $builder->add('attendee', EntityType::class, [ 'label' => $activityType->getLabel('attendee'), 'required' => $activityType->isRequired('attendee'), + 'expanded' => true, 'class' => ActivityPresence::class, 'choice_label' => function (ActivityPresence $activityPresence) { return $this->translatableStringHelper->localize($activityPresence->getName()); diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index b166a4a9e..067192ad5 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -3,6 +3,15 @@ {{ form_start(form) }} {{ form_errors(form) }} + +{%- if form.emergency is defined -%} + {{ form_row(form.emergency) }} +{% endif %} + +{%- if form.sentReceived is defined -%} + {{ form_row(form.sentReceived) }} +{% endif %} + {%- if form.user is defined -%} {{ form_row(form.user) }} {% endif %} @@ -11,26 +20,14 @@ {{ form_row(form.scope) }} {% endif %} -

        {{ 'Activity data'|trans }}

        +type.. -{%- if form.date is defined -%} - {{ form_row(form.date) }} -{% endif %} -{%- if form.durationTime is defined -%} - {{ form_row(form.durationTime) }} -{% endif %} -{%- if form.travelTime is defined -%} - {{ form_row(form.travelTime) }} -{% endif %} -{%- if form.attendee is defined -%} - {{ form_row(form.attendee) }} -{% endif %} -{%- if form.comment is defined -%} - {{ form_row(form.comment) }} -{% endif %} -{%- if form.reasons is defined -%} +{%- if form.reasons is defined -%} {{ form_row(form.reasons) }} {% endif %} + +

        Parties concernées

        + {%- if form.persons is defined -%} {{ form_row(form.persons) }} {% endif %} @@ -40,17 +37,38 @@ {%- if form.users is defined -%} {{ form_row(form.users) }} {% endif %} -{%- if form.emergency is defined -%} - {{ form_row(form.emergency) }} + +

        {{ 'Activity data'|trans }}

        + +{%- if form.date is defined -%} + {{ form_row(form.date) }} {% endif %} -{%- if form.sentReceived is defined -%} - {{ form_row(form.sentReceived) }} + +.. location + +{%- if form.durationTime is defined -%} + {{ form_row(form.durationTime) }} +{% endif %} + +{%- if form.travelTime is defined -%} + {{ form_row(form.travelTime) }} +{% endif %} + +{%- if form.comment is defined -%} + .. public and private + {{ form_row(form.comment) }} {% endif %} {%- if form.documents is defined -%} {{ form_row(form.documents) }} {% endif %} +{%- if form.attendee is defined -%} + {{ form_row(form.attendee) }} +{% endif %} + +.. status +
        From 968e6914b27c0af55c3654e11eb0b2c0fc4033d1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 13:29:01 +0200 Subject: [PATCH 022/116] add new webpack vue entrypoint for activity + rename existing activity.scss + rename webpack vue accompanyingCourse entrypoint --- src/Bundle/ChillActivityBundle/Resources/public/index.js | 2 +- .../{activity/activity.scss => scss/chillactivity.scss} | 0 .../Resources/public/vuejs/Activity/index.js | 0 src/Bundle/ChillActivityBundle/chill.webpack.config.js | 6 ++++++ .../Resources/views/AccompanyingCourse/edit.html.twig | 2 +- .../Resources/views/AccompanyingCourse/layout.html.twig | 4 ++-- src/Bundle/ChillPersonBundle/chill.webpack.config.js | 2 +- 7 files changed, 11 insertions(+), 5 deletions(-) rename src/Bundle/ChillActivityBundle/Resources/public/{activity/activity.scss => scss/chillactivity.scss} (100%) create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js diff --git a/src/Bundle/ChillActivityBundle/Resources/public/index.js b/src/Bundle/ChillActivityBundle/Resources/public/index.js index 74b2a8646..e219e368b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/index.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/index.js @@ -1 +1 @@ -require('./activity/activity.scss'); +require('./scss/chillactivity.scss'); diff --git a/src/Bundle/ChillActivityBundle/Resources/public/activity/activity.scss b/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss similarity index 100% rename from src/Bundle/ChillActivityBundle/Resources/public/activity/activity.scss rename to src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillActivityBundle/chill.webpack.config.js b/src/Bundle/ChillActivityBundle/chill.webpack.config.js index 724184f63..d40ae2d4a 100644 --- a/src/Bundle/ChillActivityBundle/chill.webpack.config.js +++ b/src/Bundle/ChillActivityBundle/chill.webpack.config.js @@ -1,4 +1,10 @@ // this file loads all assets from the Chill person bundle module.exports = function(encore, entries) { entries.push(__dirname + '/Resources/public/index.js'); + + encore.addAliases({ + ChillActivityAssets: __dirname + '/Resources/public' + }); + + encore.addEntry('vue_activity', __dirname + '/Resources/public/vuejs/Activity/index.js'); }; diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig index 6aa978149..65edd5155 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig @@ -15,5 +15,5 @@ window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }}; window.vueRootComponent = 'app'; - {{ encore_entry_script_tags('accompanying_course') }} + {{ encore_entry_script_tags('vue_accourse') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig index 0bab5d893..58591a618 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig @@ -16,7 +16,7 @@ {% endblock %} {% block css %} - {{ encore_entry_link_tags('accompanying_course') }} + {{ encore_entry_link_tags('vue_accourse') }} {% endblock %} {% block js %} @@ -24,5 +24,5 @@ window.accompanyingCourseId = {{ accompanyingCourse.id|e('js') }}; window.vueRootComponent = 'banner'; - {{ encore_entry_script_tags('accompanying_course') }} + {{ encore_entry_script_tags('vue_accourse') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index 53aed5d91..f1fd189c7 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -8,5 +8,5 @@ module.exports = function(encore, entries) ChillPersonAssets: __dirname + '/Resources/public' }); - encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); + encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); }; From b89cffce68c1767dcfa6627f26fedbc25a4275b5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 16:13:22 +0200 Subject: [PATCH 023/116] add serializer to activityController --- .../Controller/ActivityController.php | 22 ++++++++++++++++++- .../public/vuejs/Activity}/parcours.html | 0 .../Activity/newAccompanyingCourse.html.twig | 12 ++++++++++ .../views/Activity/newPerson.html.twig | 3 +++ .../config/services/controller.yaml | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) rename src/Bundle/{ => ChillActivityBundle/Resources/public/vuejs/Activity}/parcours.html (100%) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 417c04909..09f6e0c80 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -36,6 +36,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Role\Role; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Form\ActivityType; +use Symfony\Component\Serializer\SerializerInterface; /** * Class ActivityController @@ -49,15 +50,19 @@ class ActivityController extends AbstractController protected AuthorizationHelper $authorizationHelper; protected LoggerInterface $logger; + + protected SerializerInterface $serializer; public function __construct( EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper, - LoggerInterface $logger + LoggerInterface $logger, + SerializerInterface $serializer ) { $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; $this->logger = $logger; + $this->serializer = $serializer; } /** @@ -204,11 +209,25 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Template not found'); } + //$activity_json = $this->serializer->serialize($entity, 'json', []); + // "A circular reference has been detected when serializing the object of class "Chill\PersonBundle\Entity\AccompanyingPeriod" (configured limit: 1)." + + $activity_json = null; + // activity_json doit retourner qqch comme : + // { + // "type": "activity", + // "persons": [ + // { type: person, id: xxx, ...} + // { ...} + // ], "" + // } + return $this->render($view, [ 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, 'form' => $form->createView(), + 'activity_json' => $activity_json ]); } @@ -321,6 +340,7 @@ class ActivityController extends AbstractController 'delete_form' => $deleteForm->createView(), 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, + 'activity_json' => null )); } diff --git a/src/Bundle/parcours.html b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html similarity index 100% rename from src/Bundle/parcours.html rename to src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index 74152659f..aa532b323 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -6,15 +6,27 @@ {% block content %} {% include 'ChillActivityBundle:Activity:new.html.twig' %} + {{ dump() }} {% endblock %} {% block js %} + {{ encore_entry_script_tags('vue_activity') }} {% endblock %} {% block css %} + {{ encore_entry_link_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index 9cb89d917..5155e9242 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -12,9 +12,12 @@ + {{ encore_entry_script_tags('vue_activity') }} {% endblock %} {% block css %} + {{ encore_entry_link_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/config/services/controller.yaml b/src/Bundle/ChillActivityBundle/config/services/controller.yaml index cf36e482d..106b2c6e4 100644 --- a/src/Bundle/ChillActivityBundle/config/services/controller.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/controller.yaml @@ -4,4 +4,5 @@ services: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $logger: '@chill.main.logger' + $serializer: '@Symfony\Component\Serializer\SerializerInterface' tags: ['controller.service_arguments'] From b1d7e543fc5a556c9d9b4ef8ea2bedd874654052 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 17:36:33 +0200 Subject: [PATCH 024/116] controller return json to vue via twig; init vue App --- .../Controller/ActivityController.php | 17 +---- .../Resources/public/vuejs/Activity/App.vue | 18 +++++ .../Resources/public/vuejs/Activity/i18n.js | 8 ++ .../Resources/public/vuejs/Activity/index.js | 16 ++++ .../Resources/public/vuejs/Activity/store.js | 31 ++++++++ .../Resources/views/Activity/edit.html.twig | 73 ++++++++++++------- .../Activity/editAccompanyingCourse.html.twig | 5 ++ .../views/Activity/editPerson.html.twig | 4 + .../Resources/views/Activity/new.html.twig | 4 +- .../Activity/newAccompanyingCourse.html.twig | 11 +-- .../views/Activity/newPerson.html.twig | 3 +- 11 files changed, 138 insertions(+), 52 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 09f6e0c80..c116c5d35 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -209,19 +209,8 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Template not found'); } - //$activity_json = $this->serializer->serialize($entity, 'json', []); - // "A circular reference has been detected when serializing the object of class "Chill\PersonBundle\Entity\AccompanyingPeriod" (configured limit: 1)." + $activity_json = $this->serializer->serialize($entity, 'json', ['groups' => 'read']); - $activity_json = null; - // activity_json doit retourner qqch comme : - // { - // "type": "activity", - // "persons": [ - // { type: person, id: xxx, ...} - // { ...} - // ], "" - // } - return $this->render($view, [ 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, @@ -334,13 +323,15 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Template not found'); } + $activity_json = $this->serializer->serialize($entity, 'json', ['groups' => ['read']]); + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), 'delete_form' => $deleteForm->createView(), 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, - 'activity_json' => null + 'activity_json' => $activity_json )); } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue new file mode 100644 index 000000000..74466733a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js new file mode 100644 index 000000000..b38767780 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js @@ -0,0 +1,8 @@ +const appMessages = { + fr: { + + } +} +export { + appMessages +}; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js index e69de29bb..bd850419e 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js @@ -0,0 +1,16 @@ +import { createApp } from 'vue'; +import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n' +import { appMessages } from './i18n' +import store from './store' + +import App from './App.vue'; + +const i18n = _createI18n(appMessages); + +const app = createApp({ + template: ``, +}) +.use(store) +.use(i18n) +.component('app', App) +.mount('#activity'); diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js new file mode 100644 index 000000000..769e87245 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -0,0 +1,31 @@ +import 'es6-promise/auto'; +import { createStore } from 'vuex'; + +const debug = process.env.NODE_ENV !== 'production'; +//console.log('window.activity', window.activity); + +const store = createStore({ + strict: debug, + state: { + activity: window.activity + }, + getters: { + + }, + mutations: { + addPerson(state, payload) { + + } + }, + actions: { + addPerson() { + //let el = document.getElementById('form['activity']['xxx']['xxxx']'); + //let option = document.createElement('option'); + //option.value = person.id; + //el.appendChild(option); + commit('addPerson', payload) + } + } +}); + +export default store; diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index 0625174ac..902278874 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -1,6 +1,15 @@

        {{ "Update activity"|trans }}

        {{ form_start(edit_form) }} +{{ form_errors(edit_form) }} + +{%- if edit_form.emergency is defined -%} + {{ form_row(edit_form.emergency) }} +{% endif %} + +{%- if edit_form.sentReceived is defined -%} + {{ form_row(edit_form.sentReceived) }} +{% endif %} {%- if edit_form.user is defined -%} {{ form_row(edit_form.user) }} @@ -10,45 +19,55 @@ {{ form_row(edit_form.scope) }} {% endif %} -

        {{ 'Activity data'|trans }}

        +.. type -{%- if form.date is defined -%} - {{ form_row(form.date) }} +{%- if edit_form.reasons is defined -%} + {{ form_row(edit_form.reasons) }} {% endif %} -{%- if form.durationTime is defined -%} - {{ form_row(form.durationTime) }} + +

        Parties concernées

        + +{%- if edit_form.persons is defined -%} + {{ form_row(edit_form.persons) }} {% endif %} -{%- if form.travelTime is defined -%} - {{ form_row(form.travelTime) }} +{%- if edit_form.thirdParties is defined -%} + {{ form_row(edit_form.thirdParties) }} {% endif %} -{%- if form.attendee is defined -%} - {{ form_row(form.attendee) }} +{%- if edit_form.users is defined -%} + {{ form_row(edit_form.users) }} {% endif %} -{%- if form.comment is defined -%} - {{ form_row(form.comment) }} + +

        {{ 'Activity data'|trans }}

        + +{%- if edit_form.date is defined -%} + {{ form_row(edit_form.date) }} {% endif %} -{%- if form.reasons is defined -%} - {{ form_row(form.reasons) }} + +.. location + +{%- if edit_form.durationTime is defined -%} + {{ form_row(edit_form.durationTime) }} {% endif %} -{%- if form.persons is defined -%} - {{ form_row(form.persons) }} + +{%- if edit_form.travelTime is defined -%} + {{ form_row(edit_form.travelTime) }} {% endif %} -{%- if form.thirdParties is defined -%} - {{ form_row(form.thirdParties) }} + +{%- if edit_form.comment is defined -%} + .. public and private + {{ form_row(edit_form.comment) }} {% endif %} -{%- if form.users is defined -%} - {{ form_row(form.users) }} + +{%- if edit_form.documents is defined -%} + {{ form_row(edit_form.documents) }} {% endif %} -{%- if form.emergency is defined -%} - {{ form_row(form.emergency) }} -{% endif %} -{%- if form.sentReceived is defined -%} - {{ form_row(form.sentReceived) }} -{% endif %} -{%- if form.documents is defined -%} - {{ form_row(form.documents) }} + +{%- if edit_form.attendee is defined -%} + {{ form_row(edit_form.attendee) }} {% endif %} +.. status + {% set person_id = null %} {% if entity.person %} {% set person_id = entity.person.id %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index b9a812b09..db4034fa7 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -5,16 +5,21 @@ {% block title 'Update activity'|trans %} {% block content %} +
        {# <=== vue component #} {% include 'ChillActivityBundle:Activity:edit.html.twig' %} + {{ dump() }} {% endblock %} {% block js %} + {{ encore_entry_script_tags('vue_activity') }} {% endblock %} {% block css %} + {{ encore_entry_link_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index fc32dab49..b0cfa13c2 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -22,15 +22,19 @@ {% block personcontent %} {% include 'ChillActivityBundle:Activity:edit.html.twig' %} +
        {# <=== vue component #} {% endblock %} {% block js %} + {{ encore_entry_script_tags('vue_activity') }} {% endblock %} {% block css %} + {{ encore_entry_link_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 067192ad5..83d8a6c58 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -1,4 +1,4 @@ -

        {{ "Activity creation"|trans }}

        +

        {{ "Activity creation"|trans }}

        {{ form_start(form) }} {{ form_errors(form) }} @@ -20,7 +20,7 @@ {{ form_row(form.scope) }} {% endif %} -type.. +.. type {%- if form.reasons is defined -%} {{ form_row(form.reasons) }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index aa532b323..163732e97 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -5,6 +5,7 @@ {% block title 'Activity creation' |trans %} {% block content %} +
        {# <=== vue component #} {% include 'ChillActivityBundle:Activity:new.html.twig' %} {{ dump() }} {% endblock %} @@ -13,15 +14,7 @@ {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index 5155e9242..335b986c7 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -6,13 +6,14 @@ {% block personcontent %} {% include 'ChillActivityBundle:Activity:new.html.twig' %} +
        {# <=== vue component #} {% endblock %} {% block js %} {{ encore_entry_script_tags('vue_activity') }} {% endblock %} From 65ac9a47b47c50d6f8c0e91eef81e2e24cfb5f1f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 17:53:14 +0200 Subject: [PATCH 025/116] add addPersons subcomponent --- .../Resources/public/vuejs/Activity/App.vue | 44 +++++++++++++++++-- .../Resources/public/vuejs/Activity/i18n.js | 9 +++- .../Resources/views/Activity/edit.html.twig | 2 + .../Resources/views/Activity/new.html.twig | 2 + 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue index 74466733a..b78483bc5 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -1,16 +1,54 @@ diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js index b38767780..91699e320 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js @@ -1,8 +1,15 @@ +import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n' + const appMessages = { fr: { - + activities: { + add_persons: "Ajouter des personnes" + } } } + +Object.assign(appMessages.fr, personMessages.fr); + export { appMessages }; diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index 902278874..068ae2db7 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -37,6 +37,8 @@ {{ form_row(edit_form.users) }} {% endif %} +
        +

        {{ 'Activity data'|trans }}

        {%- if edit_form.date is defined -%} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 83d8a6c58..44897a331 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -38,6 +38,8 @@ {{ form_row(form.users) }} {% endif %} +
        +

        {{ 'Activity data'|trans }}

        {%- if form.date is defined -%} From 9ec2a62fb6da3e523a6ddb14dfad1b10244f9fa0 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 18:41:22 +0200 Subject: [PATCH 026/116] controller return json to vue via twig, corrections --- .../ChillActivityBundle/Controller/ActivityController.php | 8 ++++---- src/Bundle/ChillActivityBundle/Entity/Activity.php | 5 +++++ .../Resources/views/Activity/editPerson.html.twig | 2 +- .../Resources/views/Activity/newPerson.html.twig | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index c116c5d35..1dae24464 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -209,14 +209,14 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Template not found'); } - $activity_json = $this->serializer->serialize($entity, 'json', ['groups' => 'read']); + $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); return $this->render($view, [ 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, 'form' => $form->createView(), - 'activity_json' => $activity_json + 'activity_json' => $activity_array ]); } @@ -323,7 +323,7 @@ class ActivityController extends AbstractController throw $this->createNotFoundException('Template not found'); } - $activity_json = $this->serializer->serialize($entity, 'json', ['groups' => ['read']]); + $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); return $this->render($view, array( 'entity' => $entity, @@ -331,7 +331,7 @@ class ActivityController extends AbstractController 'delete_form' => $deleteForm->createView(), 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, - 'activity_json' => $activity_json + 'activity_json' => $activity_array )); } diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0b35d961e..5834cd7cd 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -34,6 +34,7 @@ use Chill\MainBundle\Entity\HasScopeInterface; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; +use Symfony\Component\Serializer\Annotation\Groups; /** * Class Activity @@ -61,6 +62,7 @@ class Activity implements HasCenterInterface, HasScopeInterface * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") + * @Groups({"read"}) */ private ?int $id; @@ -121,11 +123,13 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") + * @Groups({"read"}) */ private Collection $persons; /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") + * @Groups({"read"}) */ private Collection $thirdParties; @@ -136,6 +140,7 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") + * @Groups({"read"}) */ private Collection $users; diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index b0cfa13c2..733912375 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -29,7 +29,7 @@ {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index 335b986c7..84f3f5ac3 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -13,7 +13,7 @@ {{ encore_entry_script_tags('vue_activity') }} {% endblock %} From 549f3a4c78f2e726a4a840bf941f2b7435fc991d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 27 May 2021 22:53:35 +0200 Subject: [PATCH 027/116] AddPersons in activity * modal button dont submit all form * addNewPersons action mutation loop ready --- .../Resources/public/vuejs/Activity/App.vue | 4 +- .../Resources/public/vuejs/Activity/i18n.js | 2 +- .../public/vuejs/Activity/parcours.html | 72 ------------------- .../Resources/public/vuejs/Activity/store.js | 9 +-- .../Activity/editAccompanyingCourse.html.twig | 3 +- .../views/Activity/editPerson.html.twig | 3 +- .../Activity/newAccompanyingCourse.html.twig | 3 +- .../views/Activity/newPerson.html.twig | 3 +- .../translations/messages.fr.yml | 2 +- .../public/vuejs/_components/AddPersons.vue | 11 ++- 10 files changed, 25 insertions(+), 87 deletions(-) delete mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue index b78483bc5..aa2d32a16 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -7,7 +7,7 @@ v-bind:key="addPersons.key" v-bind:options="addPersons.options" @addNewPersons="addNewPersons" - ref="addPersons"> + ref="addPersons"> @@ -41,7 +41,7 @@ export default { addNewPersons({ selected, modal }) { console.log('@@@ CLICK button addNewPersons', selected); selected.forEach(function(item) { - //this.$store.dispatch('addResource', item); + this.$store.dispatch('addPersonsInvolved', item); console.log('item', item); }, this ); diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js index 91699e320..e74311d98 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/i18n.js @@ -3,7 +3,7 @@ import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n' const appMessages = { fr: { activities: { - add_persons: "Ajouter des personnes" + add_persons: "Ajouter des personnes concernées" } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html deleted file mode 100644 index 0a7dd3df4..000000000 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/parcours.html +++ /dev/null @@ -1,72 +0,0 @@ -Controleur: - -activity_json = $this->serializer->serialize($activity, 'json', []); - -return render('@ChillActivity/...', [ - 'activity' => $activity, - 'activity_json' => $activity_json -]) - - -{# template twig de activity #} - -{{ form(activity) }} - -{% block js %} - -{{ encore_entry_script_tags('activity_form') }} -{% endblock %} - - -{# ----- - dans le fichier app.js: #} - diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index 769e87245..0c5f21669 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -13,17 +13,18 @@ const store = createStore({ }, mutations: { - addPerson(state, payload) { - + addPersonsInvolved(state, payload) { + console.log('### mutation addPersonsInvolved', payload); } }, actions: { - addPerson() { + addPersonsInvolved({ commit }, payload) { + console.log('### action addPersonsInvolved', payload); //let el = document.getElementById('form['activity']['xxx']['xxxx']'); //let option = document.createElement('option'); //option.value = person.id; //el.appendChild(option); - commit('addPerson', payload) + commit('addPersonsInvolved', payload) } } }); diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index db4034fa7..f1af6e749 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -13,7 +13,8 @@ {% block js %} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index 733912375..93d2eb307 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -28,7 +28,8 @@ {% block js %} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index 163732e97..050dcd1e6 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -13,7 +13,8 @@ {% block js %} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index 84f3f5ac3..0cea144ff 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -12,7 +12,8 @@ {% block js %} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 0693d4a22..7c8a6b33d 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -20,7 +20,7 @@ present: présent not present: absent Delete: Supprimer Update: Mettre à jour -Update activity: Édition de l'activité +Update activity: Modifier l'activité Scope: Cercle Activity data: Données de l'activité No reason associated: Aucun sujet diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index a37f93e7e..fb06eedbb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -1,9 +1,9 @@ From 718d6c23757ae0e58a708d4fdf583b05149b91f3 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 31 May 2021 19:25:37 +0200 Subject: [PATCH 041/116] add basic on-the-fly sub-components, to show/edit/create person/thirdparty --- .../public/modules/bootstrap/bootstrap.scss | 2 +- .../public/vuejs/_components/OnTheFly.vue | 34 +++++++-- .../vuejs/_components/OnTheFly/Create.vue | 73 +++++++++++++++++++ .../vuejs/_components/OnTheFly/Person.vue | 22 ++++++ .../vuejs/_components/OnTheFly/ThirdParty.vue | 22 ++++++ .../Resources/public/vuejs/_js/i18n.js | 4 +- .../vuejs/AccompanyingCourse/js/i18n.js | 2 +- 7 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/bootstrap/bootstrap.scss b/src/Bundle/ChillMainBundle/Resources/public/modules/bootstrap/bootstrap.scss index 8a77ac48f..cc9c090e2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/modules/bootstrap/bootstrap.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/modules/bootstrap/bootstrap.scss @@ -23,7 +23,7 @@ // @import "bootstrap/scss/button-group"; // @import "bootstrap/scss/input-group"; // @import "bootstrap/scss/custom-forms"; -// @import "bootstrap/scss/nav"; +@import "bootstrap/scss/nav"; // @import "bootstrap/scss/navbar"; // @import "bootstrap/scss/card"; // @import "bootstrap/scss/breadcrumb"; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue index 3b7c67dc9..238b97851 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue @@ -15,11 +15,29 @@ - @@ -28,13 +29,15 @@ + v-bind:action="action" + ref="castThirdparty"> @@ -44,7 +47,10 @@ class="sc-button bt-update"> @@ -55,8 +61,8 @@ diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue deleted file mode 100644 index 78bf4fdf9..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 768954778..b8dced534 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -16,6 +16,7 @@ export default { name: "OnTheFlyThirdParty", props: ['id', 'type', 'action'] } +// TODO move in ChillThirdpartyAssets diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js index e92a81e62..0f019c26b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js @@ -15,7 +15,21 @@ const personMessages = { person: { firstname: "Prénom", lastname: "Nom", - born: "né le ", + born: "né{e} le ", + center_id: "Identifiant du centre", + center_type: "Type de centre", + center_name: "Territoire", // vendée + phonenumber: "Téléphone", + mobilenumber: "Mobile", + altnames: "Autres noms", + gender: { + title: "Genre", + placeholder: "Choisissez le genre de l'usager", + woman: "Femme", + man: "Homme", + neuter: "Neutre", + } + }, error_only_one_person: "Une seule personne peut être sélectionnée !" } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index 98f26987f..3fe5c56db 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -31,7 +31,7 @@ {% set gender = (p.person.gender == 'woman') ? 'fa-venus' : (p.person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %} {% set genderTitle = (p.person.gender == 'woman') ? 'femme' : - (p.person.gender == 'homme') ? 'fa-mars' : 'neutre' %} + (p.person.gender == 'man') ? 'homme' : 'neutre' %} {{ born ~ ' le ' ~ p.person.birthdate|format_date('short') }}

      From 32b3d74a1ba609dbec3041792062cba4cc69be4b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 3 Jun 2021 13:48:03 +0200 Subject: [PATCH 049/116] fix activity entity addPersons if person is null --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 6b69bdf8e..53fd679e5 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -400,9 +400,11 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * Add a person to the person list */ - public function addPerson(Person $person): self + public function addPerson(?Person $person): self { - $this->persons[] = $person; + if (null !== $person) { + $this->persons[] = $person; + } return $this; } From 937be1af3ac781bf74e1eab49f122fd8da55316b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 3 Jun 2021 14:34:52 +0200 Subject: [PATCH 050/116] fix html5 birthdate field on modal form OnTheFly --- .../public/vuejs/_components/OnTheFly.vue | 2 + .../Resources/public/vuejs/_api/OnTheFly.js | 16 +------ .../vuejs/_components/OnTheFly/Person.vue | 44 +++++++------------ 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue index ac5362ce7..8e1e2227a 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly.vue @@ -137,8 +137,10 @@ export default { } else if (this.type === 'thirdparty') { this.$refs.castThirdparty.postData(); } else { + // saveAction() ==cast=to==> child.castByType() ==cast=to==> grand-child.postData() this.$refs.castNew.castByType(); } + this.modal.showModal = false; } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 332f09e01..6adbc7028 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -11,20 +11,7 @@ const getPerson = (id) => { }; /* -* GET a thirdparty by id -* TODO move in ChillThirdpartyAssets !! -*/ -const getThirdparty = (id) => { - const url = `/api/1.0/thirdparty/thirdparty/${id}.json`; - return fetch(url) - .then(response => { - if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); - }); -}; - -/* -* POST a person +* POST a new person */ const postPerson = (body) => { const url = `/api/1.0/person/person.json`; @@ -43,6 +30,5 @@ const postPerson = (body) => { export { getPerson, - getThirdparty, postPerson }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 62fd20a2a..a3cf339e2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -53,7 +53,6 @@
      - {{ action }} @@ -68,18 +67,12 @@ - + /> @@ -91,9 +84,6 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue new file mode 100644 index 000000000..81aced606 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue @@ -0,0 +1,70 @@ + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/MemberDetails.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/MemberDetails.vue new file mode 100644 index 000000000..cfefa9654 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/MemberDetails.vue @@ -0,0 +1,51 @@ + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js index d297ba1d7..c7724daff 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js @@ -5,10 +5,18 @@ const appMessages = { fr: { household_members_editor: { concerned: { - title: "Personnes concernées", + title: "Usagers concernés", add_persons: "Ajouter d'autres usagers", search: "Rechercher des usagers", - } + move_to: "Déplacer vers", + }, + holder: "Titulaire du ménage", + remove_position: "Retirer des {position}", + remove_concerned: "Enlever du ménage", + household_part: "Ménage de destination", + new_household: "Nouveau ménage", + create_household: "Créer un ménage", + search_household: "Chercher un ménage", } } }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index 257a46e57..f5db83c66 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -6,7 +6,8 @@ const concerned = window.household_members_editor_data.persons.map(p => { return { person: p, position: null, - start_date: null + start_date: null, + allowRemove: false, }; }); @@ -16,17 +17,31 @@ const store = createStore({ concerned, household: window.household_members_editor_data.household, positions: window.household_members_editor_data.positions, + allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate, + allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch, + allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold, + forceLeaveWithoutHousehold: false }, getters: { + isHouseholdNew(state) { + console.log('isHouseholdNew', !Number.isInteger(state.household.id)); + console.log('household', state.household); + return !Number.isInteger(state.household.id); + }, + hasHousehold(state) { + return state.household !== null; + }, persons(state) { return state.concerned.map(conc => conc.person); }, - personsUnpositionned(state) { + concUnpositionned(state) { return state.concerned .filter(conc => conc.position === null) - .map(conc => conc.person) ; }, + positions(state) { + return state.positions; + }, personByPosition: (state) => (position_id) => { return state.concerned .filter(conc => @@ -35,14 +50,28 @@ const store = createStore({ .map(conc => conc.person) ; }, - positions(state) { - return state.positions; - } + concByPosition: (state) => (position_id) => { + return state.concerned + .filter(conc => + conc.position !== null ? conc.position.id === position_id : false + ) + ; + }, + concByPersonId: (state) => (person_id) => { + return state.concerned + .find(conc => conc.person.id === person_id) + ; + }, }, mutations: { addConcerned(state, person) { - console.log('from mutation addConcerned'); - state.concerned.push({ person, position: null, start_date: null }); + let persons = state.concerned.map(conc => conc.person.id); + if (!persons.includes(person.id)) { + state.concerned.push({ person, position: null, + start_date: null, allowRemove: true }); + } else { + console.err("person already included"); + } }, markPosition(state, { person_id, position_id}) { console.log('from mutation markPosition'); @@ -55,7 +84,27 @@ const store = createStore({ console.log(position); console.log(conc); conc.position = position; - } + }, + toggleHolder(state, conc) { + console.log('toggleHolder', conc); + conc.holder = !conc.holder; + }, + removePosition(state, conc) { + conc.holder = false; + conc.position = null; + }, + removeConcerned(state, conc) { + state.concerned = state.concerned.filter(c => + c.person.id !== conc.person.id + ) + }, + createHousehold(state) { + state.household = { type: 'household', members: [], address: null } + }, + forceLeaveWithoutHousehold(state) { + state.household = null; + state.forceLeaveWithoutHousehold = true; + }, }, actions: { addConcerned({ commit }, person) { @@ -67,7 +116,22 @@ const store = createStore({ console.log('person_id', person_id); console.log('position_id', position_id); commit('markPosition', { person_id, position_id }); - } + }, + toggleHolder({ commit }, conc) { + commit('toggleHolder', conc); + }, + removePosition({ commit }, conc) { + commit('removePosition', conc); + }, + removeConcerned({ commit }, conc) { + commit('removeConcerned', conc); + }, + createHousehold({ commit }) { + commit('createHousehold'); + }, + forceLeaveWithoutHousehold({ commit }) { + commit('forceLeaveWithoutHousehold'); + }, } }); From 987815471cb44cff4f8e9ed6405b82ccbdb4a9d3 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 3 Jun 2021 19:13:58 +0200 Subject: [PATCH 052/116] add concerned parties in show activity page (2 contexts) --- .../Resources/public/scss/chillactivity.scss | 24 ++++++++++++ .../vuejs/Activity/components/PersonBadge.vue | 6 ++- .../views/Activity/concernedGroups.html.twig | 37 +++++++++++++++++++ .../Resources/views/Activity/edit.html.twig | 2 +- .../Resources/views/Activity/new.html.twig | 2 +- .../Resources/views/Activity/show.html.twig | 9 +++-- .../Activity/showAccompanyingCourse.html.twig | 2 +- .../views/Activity/showPerson.html.twig | 2 +- .../translations/messages.fr.yml | 7 ++++ .../Resources/public/scss/chillmain.scss | 6 +++ .../public/sass/person_with_period.scss | 8 ---- .../Resources/views/Entity/person.html.twig | 4 +- .../Templating/Entity/PersonRender.php | 4 +- .../views/ThirdParty/_render.html.twig | 7 ++++ 14 files changed, 99 insertions(+), 21 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig diff --git a/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss b/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss index bef8788f8..b2159cb7a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss +++ b/src/Bundle/ChillActivityBundle/Resources/public/scss/chillactivity.scss @@ -8,3 +8,27 @@ .activity { color: $chill-green; } + +// exceptions for flex-bloc in concerned-groups +div.flex-bloc.concerned-groups { + margin-top: 1em; + div.item-bloc { + flex-grow: 0; flex-shrink: 0; flex-basis: 25%; //4 blocs + ul.list-content { + list-style-type: none; + padding-left: 0; + li { + a { + color: white; + cursor: pointer; + &:hover { + color: #ffffffab; + } + } + } + } + } + &.person div.item-bloc { + flex-basis: 33%; //3 blocs + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/PersonBadge.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/PersonBadge.vue index 03827f4a2..e27feb886 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/PersonBadge.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/PersonBadge.vue @@ -1,8 +1,10 @@