diff --git a/composer.json b/composer.json
index a2aa29a5a..747747290 100644
--- a/composer.json
+++ b/composer.json
@@ -62,7 +62,8 @@
"symfony/web-profiler-bundle": "^5.0"
},
"config": {
- "bin-dir": "bin"
+ "bin-dir": "bin",
+ "vendor-dir": "tests/app/vendor"
},
"autoload": {
"psr-4": {
diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
index fe515918a..a454626b7 100644
--- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
+++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php
@@ -22,6 +22,9 @@
namespace Chill\ActivityBundle\Controller;
+use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
+use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
+use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
@@ -36,6 +39,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Form\ActivityType;
+use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Symfony\Component\Serializer\SerializerInterface;
/**
@@ -53,12 +57,16 @@ class ActivityController extends AbstractController
protected SerializerInterface $serializer;
+ protected ActivityACLAwareRepositoryInterface $activityACLAwareRepository;
+
public function __construct(
+ ActivityACLAwareRepositoryInterface $activityACLAwareRepository,
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
LoggerInterface $logger,
SerializerInterface $serializer
) {
+ $this->activityACLAwareRepository = $activityACLAwareRepository;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->logger = $logger;
@@ -77,13 +85,9 @@ class ActivityController extends AbstractController
[$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(Activity::class)
- ->findByPersonImplied($person, $reachableScopes)
- ;
+ $this->denyAccessUnlessGranted(ActivityVoter::SEE, $person);
+ $activities = $this->activityACLAwareRepository
+ ->findByPerson($person, ActivityVoter::SEE, 0, null);
$event = new PrivacyEvent($person, array(
'element_class' => Activity::class,
@@ -93,10 +97,10 @@ class ActivityController extends AbstractController
$view = 'ChillActivityBundle:Activity:listPerson.html.twig';
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
- $activities = $em->getRepository('ChillActivityBundle:Activity')->findBy(
- ['accompanyingPeriod' => $accompanyingPeriod],
- ['date' => 'DESC'],
- );
+ $this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod);
+
+ $activities = $this->activityACLAwareRepository
+ ->findByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE);
$view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig';
}
@@ -136,6 +140,12 @@ class ActivityController extends AbstractController
];
}
+ if ($request->query->has('activityData')) {
+ $activityData = $request->query->get('activityData');
+ } else {
+ $activityData = [];
+ }
+
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
@@ -144,6 +154,7 @@ class ActivityController extends AbstractController
'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
'data' => $data,
+ 'activityData' => $activityData
]);
}
@@ -163,10 +174,19 @@ class ActivityController extends AbstractController
$activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
->find($activityType_id);
+ $activityData = null;
+ if ($request->query->has('activityData')) {
+ $activityData = $request->query->get('activityData');
+ }
+
if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType ||
!$activityType->isActive()) {
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
+
+ if (null !== $activityData) {
+ $params['activityData'] = $activityData;
+ }
return $this->redirectToRoute('chill_activity_activity_select_type', $params);
}
@@ -184,6 +204,50 @@ class ActivityController extends AbstractController
$entity->setType($activityType);
$entity->setDate(new \DateTime('now'));
+ if ($request->query->has('activityData')) {
+ $activityData = $request->query->get('activityData');
+
+ if (array_key_exists('durationTime', $activityData)) {
+ $durationTimeInMinutes = $activityData['durationTime'];
+ $hours = floor($durationTimeInMinutes / 60);
+ $minutes = $durationTimeInMinutes % 60;
+ $duration = \DateTime::createFromFormat("H:i", $hours.':'.$minutes);
+ if ($duration) {
+ $entity->setDurationTime($duration);
+ }
+ }
+
+ if (array_key_exists('date', $activityData)) {
+ $date = \DateTime::createFromFormat('Y-m-d', $activityData['date']);
+ if ($date) {
+ $entity->setDate($date);
+ }
+ }
+
+ if (array_key_exists('personsId', $activityData)) {
+ foreach($activityData['personsId'] as $personId){
+ $concernedPerson = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($personId);
+ $entity->addPerson($concernedPerson);
+ }
+ }
+
+ if (array_key_exists('professionalsId', $activityData)) {
+ foreach($activityData['professionalsId'] as $professionalsId){
+ $professional = $em->getRepository(\Chill\ThirdPartyBundle\Entity\ThirdParty::class)->find($professionalsId);
+ $entity->addThirdParty($professional);
+ }
+ }
+
+ if (array_key_exists('comment', $activityData)) {
+ $comment = new CommentEmbeddable();
+ $comment->setComment($activityData['comment']);
+ $comment->setUserId($this->getUser()->getid());
+ $comment->setDate(new \DateTime('now'));
+ $entity->setComment($comment);
+ }
+
+ }
+
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
@@ -201,6 +265,7 @@ class ActivityController extends AbstractController
$this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
+
$params['id'] = $entity->getId();
return $this->redirectToRoute('chill_activity_activity_show', $params);
@@ -238,7 +303,7 @@ class ActivityController extends AbstractController
if (!$entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
-
+
if (null !== $accompanyingPeriod) {
$entity->personsAssociated = $entity->getPersonsAssociated();
$entity->personsNotAssociated = $entity->getPersonsNotAssociated();
diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
index b198875c5..b498a6090 100644
--- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
+++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
@@ -23,6 +23,8 @@
namespace Chill\ActivityBundle\Repository;
use Chill\ActivityBundle\Entity\Activity;
+use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
@@ -33,9 +35,10 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Doctrine\ORM\EntityManagerInterface;
+use Symfony\Component\Security\Core\Security;
-final class ActivityACLAwareRepository
+final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface
{
private AuthorizationHelper $authorizationHelper;
@@ -45,16 +48,63 @@ final class ActivityACLAwareRepository
private EntityManagerInterface $em;
+ private Security $security;
+
+ private CenterResolverDispatcher $centerResolverDispatcher;
+
public function __construct(
AuthorizationHelper $authorizationHelper,
+ CenterResolverDispatcher $centerResolverDispatcher,
TokenStorageInterface $tokenStorage,
ActivityRepository $repository,
- EntityManagerInterface $em
+ EntityManagerInterface $em,
+ Security $security
) {
$this->authorizationHelper = $authorizationHelper;
+ $this->centerResolverDispatcher = $centerResolverDispatcher;
$this->tokenStorage = $tokenStorage;
$this->repository = $repository;
$this->em = $em;
+ $this->security = $security;
+ }
+
+ /**
+ * @param Person $person
+ * @param string $role
+ * @param int|null $start
+ * @param int|null $limit
+ * @param array $orderBy
+ * @return array|Activity[]
+ */
+ public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array
+ {
+ $user = $this->security->getUser();
+ $center = $this->centerResolverDispatcher->resolveCenter($person);
+ if (0 === count($orderBy)) {
+ $orderBy = ['date' => 'DESC'];
+ }
+
+ $reachableScopes = $this->authorizationHelper
+ ->getReachableCircles($user, $role, $center);
+
+ return $this->em->getRepository(Activity::class)
+ ->findByPersonImplied($person, $reachableScopes, $orderBy, $limit, $start);
+ ;
+ }
+
+ public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array
+ {
+ $user = $this->security->getUser();
+ $center = $this->centerResolverDispatcher->resolveCenter($period);
+ if (0 === count($orderBy)) {
+ $orderBy = ['date' => 'DESC'];
+ }
+
+ $scopes = $this->authorizationHelper
+ ->getReachableCircles($user, $role, $center);
+
+ return $this->em->getRepository(Activity::class)
+ ->findByAccompanyingPeriod($period, $scopes, true, $limit, $start, $orderBy);
}
public function queryTimelineIndexer(string $context, array $args = []): array
@@ -81,7 +131,7 @@ final class ActivityACLAwareRepository
$metadataActivity = $this->em->getClassMetadata(Activity::class);
$metadataPerson = $this->em->getClassMetadata(Person::class);
$associationMapping = $metadataActivity->getAssociationMapping('person');
-
+
return $metadataActivity->getTableName().' JOIN '
.$metadataPerson->getTableName().' ON '
.$metadataPerson->getTableName().'.'.
@@ -95,7 +145,7 @@ final class ActivityACLAwareRepository
{
$where = '';
$parameters = [];
-
+
$metadataActivity = $this->em->getClassMetadata(Activity::class);
$metadataPerson = $this->em->getClassMetadata(Person::class);
$activityToPerson = $metadataActivity->getAssociationMapping('person')['joinColumns'][0]['name'];
@@ -105,20 +155,20 @@ final class ActivityACLAwareRepository
// acls:
$role = new Role(ActivityVoter::SEE);
- $reachableCenters = $this->authorizationHelper->getReachableCenters($this->tokenStorage->getToken()->getUser(),
+ $reachableCenters = $this->authorizationHelper->getReachableCenters($this->tokenStorage->getToken()->getUser(),
$role);
-
+
if (count($reachableCenters) === 0) {
// insert a dummy condition
return 'FALSE = TRUE';
}
- if ($context === 'person') {
- // we start with activities having the person_id linked to person
+ if ($context === 'person') {
+ // we start with activities having the person_id linked to person
$where .= sprintf('%s = ? AND ', $activityToPerson);
$parameters[] = $person->getId();
}
-
+
// we add acl (reachable center and scopes)
$where .= '('; // first loop for the for centers
$centersI = 0; // like centers#i
@@ -131,7 +181,7 @@ final class ActivityACLAwareRepository
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
// we get the ids for those scopes
$reachablesScopesId = array_map(
- function(Scope $scope) { return $scope->getId(); },
+ function(Scope $scope) { return $scope->getId(); },
$reachableScopes
);
@@ -162,7 +212,7 @@ final class ActivityACLAwareRepository
}
// close loop for centers
$where .= ')';
-
+
return [$where, $parameters];
}
diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php
new file mode 100644
index 000000000..0b646f7c5
--- /dev/null
+++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php
@@ -0,0 +1,19 @@
+ 'DESC'], $limit = 100, $offset = 0)
+ /**
+ * @param $person
+ * @param array $scopes
+ * @param string[] $orderBy
+ * @param int $limit
+ * @param int $offset
+ * @return array|Activity[]
+ */
+ public function findByPersonImplied(Person $person, array $scopes, ?array $orderBy = [ 'date' => 'DESC'], ?int $limit = 100, ?int $offset = 0): array
{
$qb = $this->createQueryBuilder('a');
$qb->select('a');
$qb
- // TODO add acl
- //->where($qb->expr()->in('a.scope', ':scopes'))
- //->setParameter('scopes', $scopes)
+ ->where($qb->expr()->in('a.scope', ':scopes'))
+ ->setParameter('scopes', $scopes)
->andWhere(
$qb->expr()->orX(
$qb->expr()->eq('a.person', ':person'),
@@ -61,7 +70,56 @@ class ActivityRepository extends ServiceEntityRepository
$qb->addOrderBy('a.'.$k, $dir);
}
+ $qb->setMaxResults($limit)->setFirstResult($offset);
+
return $qb->getQuery()
->getResult();
- }
+ }
+
+ /**
+ * @param AccompanyingPeriod $period
+ * @param array $scopes
+ * @param int|null $limit
+ * @param int|null $offset
+ * @param array|string[] $orderBy
+ * @return array|Activity[]
+ */
+ public function findByAccompanyingPeriod(AccompanyingPeriod $period, array $scopes, ?bool $allowNullScope = false, ?int $limit = 100, ?int $offset = 0, array $orderBy = ['date' => 'desc']): array
+ {
+ $qb = $this->createQueryBuilder('a');
+ $qb->select('a');
+
+ if (!$allowNullScope) {
+ $qb
+ ->where($qb->expr()->in('a.scope', ':scopes'))
+ ->setParameter('scopes', $scopes)
+ ;
+ } else {
+ $qb
+ ->where(
+ $qb->expr()->orX(
+ $qb->expr()->in('a.scope', ':scopes'),
+ $qb->expr()->isNull('a.scope')
+ )
+ )
+ ->setParameter('scopes', $scopes)
+ ;
+ }
+
+ $qb
+ ->andWhere(
+ $qb->expr()->eq('a.accompanyingPeriod', ':period')
+ )
+ ->setParameter('period', $period)
+ ;
+
+ foreach ($orderBy as $k => $dir) {
+ $qb->addOrderBy('a.'.$k, $dir);
+ }
+
+ $qb->setMaxResults($limit)->setFirstResult($offset);
+
+ return $qb->getQuery()
+ ->getResult();
+ }
}
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig
index 07b59c7e7..c227f5539 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig
@@ -19,7 +19,7 @@
{% endif %}
- {% if t.durationTimeVisible > 0 %}
+ {% if activity.durationTime and t.durationTimeVisible %}
{{ activity.durationTime|date('H:i') }}
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig
index 996d95b0f..4120d8285 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig
@@ -18,7 +18,12 @@
{% set accompanying_course_id = accompanyingCourse.id %}
{% endif %}
-
+
{{ activityType.name|localize_translatable_string }}
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
index 81ebddc05..1f54692d9 100644
--- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
+++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig
@@ -64,12 +64,22 @@
{% if t.durationTimeVisible %}
{{ 'Duration Time'|trans }}
-
{{ entity.durationTime|date('H:i') }}
+
{% if entity.durationTime is not null %}
+ {{ entity.durationTime|date('H:i') }}
+ {% else %}
+ {{ 'None'|trans|capitalize }}
+ {% endif %}
+
{% endif %}
{% if t.travelTimeVisible %}
{{ 'Travel Time'|trans }}
-
{{ entity.travelTime|date('H:i') }}
+
{% if entity.travelTime is not null %}
+ {{ entity.travelTime|date('H:i') }}
+ {% else %}
+ {{ 'None'|trans|capitalize }}
+ {% endif %}
+
{% endif %}
{% if t.commentVisible %}
diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php
index 79cb6d852..cc9cecf52 100644
--- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php
+++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php
@@ -19,6 +19,11 @@
namespace Chill\ActivityBundle\Security\Authorization;
+use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
+use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
+use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
+use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
@@ -28,11 +33,10 @@ use Chill\MainBundle\Entity\User;
use Chill\ActivityBundle\Entity\Activity;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role;
+use Symfony\Component\Security\Core\Security;
/**
- *
- *
- * @author Julien Fastré
+ * Voter for Activity class
*/
class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
@@ -41,30 +45,37 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
const SEE_DETAILS = 'CHILL_ACTIVITY_SEE_DETAILS';
const UPDATE = 'CHILL_ACTIVITY_UPDATE';
const DELETE = 'CHILL_ACTIVITY_DELETE';
+ const FULL = 'CHILL_ACTIVITY_FULL';
- /**
- *
- * @var AuthorizationHelper
- */
- protected $helper;
+ private const ALL = [
+ self::CREATE,
+ self::SEE,
+ self::UPDATE,
+ self::DELETE,
+ self::SEE_DETAILS,
+ self::FULL
+ ];
- public function __construct(AuthorizationHelper $helper)
- {
- $this->helper = $helper;
+ protected VoterHelperInterface $voterHelper;
+
+ protected Security $security;
+
+ public function __construct(
+ Security $security,
+ VoterHelperFactoryInterface $voterHelperFactory
+ ) {
+ $this->security = $security;
+ $this->voterHelper = $voterHelperFactory->generate(self::class)
+ ->addCheckFor(Person::class, [self::SEE, self::CREATE])
+ ->addCheckFor(AccompanyingPeriod::class, [self::SEE, self::CREATE])
+ ->addCheckFor(Activity::class, self::ALL)
+ ->build();
}
protected function supports($attribute, $subject)
{
- if ($subject instanceof Activity) {
- return \in_array($attribute, $this->getAttributes());
- } elseif ($subject instanceof Person) {
- return $attribute === self::SEE
- ||
- $attribute === self::CREATE;
- } else {
- return false;
- }
+ return $this->voterHelper->supports($attribute, $subject);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
@@ -72,32 +83,34 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
if (!$token->getUser() instanceof User) {
return false;
}
-
- if ($subject instanceof Person) {
- $centers = $this->helper->getReachableCenters($token->getUser(), new Role($attribute));
-
- return \in_array($subject->getCenter(), $centers);
+
+ if ($subject instanceof Activity) {
+ if ($subject->getPerson() instanceof Person) {
+ // the context is person: we must have the right to see the person
+ if (!$this->security->isGranted(PersonVoter::SEE, $subject->getPerson())) {
+ return false;
+ }
+ } elseif ($subject->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
+ if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject->getAccompanyingPeriod())) {
+ return false;
+ }
+ } else {
+ throw new \RuntimeException("could not determine context of activity");
+ }
}
-
- /* @var $subject Activity */
- return $this->helper->userHasAccess($token->getUser(), $subject, $attribute);
- }
-
- private function getAttributes()
- {
- return [ self::CREATE, self::SEE, self::UPDATE, self::DELETE,
- self::SEE_DETAILS ];
+
+ return $this->voterHelper->voteOnAttribute($attribute, $subject, $token);
}
public function getRoles()
{
- return $this->getAttributes();
+ return self::ALL;
}
public function getRolesWithoutScope()
{
- return array();
+ return [];
}
diff --git a/src/Bundle/ChillActivityBundle/config/services.yaml b/src/Bundle/ChillActivityBundle/config/services.yaml
index 86168101a..0a65e08c8 100644
--- a/src/Bundle/ChillActivityBundle/config/services.yaml
+++ b/src/Bundle/ChillActivityBundle/config/services.yaml
@@ -1,20 +1,4 @@
services:
- chill.activity.security.authorization.activity_voter:
- class: Chill\ActivityBundle\Security\Authorization\ActivityVoter
- arguments:
- - "@chill.main.security.authorization.helper"
- tags:
- - { name: security.voter }
- - { name: chill.role }
-
- chill.activity.security.authorization.activity_stats_voter:
- class: Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter
- arguments:
- - "@chill.main.security.authorization.helper"
- tags:
- - { name: security.voter }
- - { name: chill.role }
-
chill.activity.timeline:
class: Chill\ActivityBundle\Timeline\TimelineActivityProvider
@@ -38,3 +22,8 @@ services:
autowire: true
autoconfigure: true
resource: '../Notification'
+
+ Chill\ActivityBundle\Security\Authorization\:
+ resource: '../Security/Authorization/'
+ autowire: true
+ autoconfigure: true
diff --git a/src/Bundle/ChillActivityBundle/config/services/controller.yaml b/src/Bundle/ChillActivityBundle/config/services/controller.yaml
index 106b2c6e4..96ace0a64 100644
--- a/src/Bundle/ChillActivityBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillActivityBundle/config/services/controller.yaml
@@ -1,8 +1,4 @@
services:
Chill\ActivityBundle\Controller\ActivityController:
- arguments:
- $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
- $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
- $logger: '@chill.main.logger'
- $serializer: '@Symfony\Component\Serializer\SerializerInterface'
+ autowire: true
tags: ['controller.service_arguments']
diff --git a/src/Bundle/ChillActivityBundle/config/services/repositories.yaml b/src/Bundle/ChillActivityBundle/config/services/repositories.yaml
index 2f0a9b83c..26bc58ac9 100644
--- a/src/Bundle/ChillActivityBundle/config/services/repositories.yaml
+++ b/src/Bundle/ChillActivityBundle/config/services/repositories.yaml
@@ -24,9 +24,7 @@ services:
- '@Doctrine\Persistence\ManagerRegistry'
Chill\ActivityBundle\Repository\ActivityACLAwareRepository:
- arguments:
- $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
- $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
- $repository: '@Chill\ActivityBundle\Repository\ActivityRepository'
- $em: '@Doctrine\ORM\EntityManagerInterface'
+ autowire: true
+ autoconfigure: true
+ Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface: '@Chill\ActivityBundle\Repository\ActivityACLAwareRepository'
diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
index fff20940a..71e461464 100644
--- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
+++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php
@@ -36,7 +36,9 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\Role;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Form\CalendarType;
+use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Entity\User;
+use Chill\MainBundle\Pagination\PaginatorFactory;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Routing\Annotation\Route;
@@ -55,16 +57,24 @@ class CalendarController extends AbstractController
protected SerializerInterface $serializer;
+ protected PaginatorFactory $paginator;
+
+ private CalendarRepository $calendarRepository;
+
public function __construct(
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
LoggerInterface $logger,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
+ PaginatorFactory $paginator,
+ CalendarRepository $calendarRepository
) {
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->logger = $logger;
$this->serializer = $serializer;
+ $this->paginator = $paginator;
+ $this->calendarRepository = $calendarRepository;
}
/**
@@ -73,31 +83,40 @@ class CalendarController extends AbstractController
*/
public function listAction(Request $request): Response
{
- $em = $this->getDoctrine()->getManager();
$view = null;
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($user instanceof User) {
- $calendarItems = $em->getRepository(Calendar::class)
- ->findByUser($user)
- ;
+ $calendarItems = $this->calendarRepository->findByUser($user);
+
$view = '@ChillCalendar/Calendar/listByUser.html.twig';
+
+ return $this->render($view, [
+ 'calendarItems' => $calendarItems,
+ 'user' => $user
+ ]);
+
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
- $calendarItems = $em->getRepository(Calendar::class)->findBy(
+
+ $total = $this->calendarRepository->countByAccompanyingPeriod($accompanyingPeriod);
+ $paginator = $this->paginator->create($total);
+ $calendarItems = $this->calendarRepository->findBy(
['accompanyingPeriod' => $accompanyingPeriod],
- ['startDate' => 'DESC']
+ ['startDate' => 'DESC'],
+ $paginator->getItemsPerPage(),
+ $paginator->getCurrentPageFirstItemNumber()
);
$view = '@ChillCalendar/Calendar/listByAccompanyingCourse.html.twig';
- }
- return $this->render($view, [
- 'calendarItems' => $calendarItems,
- 'user' => $user,
- 'accompanyingCourse' => $accompanyingPeriod,
- ]);
+ return $this->render($view, [
+ 'calendarItems' => $calendarItems,
+ 'accompanyingCourse' => $accompanyingPeriod,
+ 'paginator' => $paginator
+ ]);
+ }
}
/**
@@ -111,7 +130,7 @@ class CalendarController extends AbstractController
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
- $view = '@ChillCalendar/Calendar/newAccompanyingCourse.html.twig';
+ $view = '@ChillCalendar/Calendar/newByAccompanyingCourse.html.twig';
}
// elseif ($user instanceof User) {
// $view = '@ChillCalendar/Calendar/newUser.html.twig';
@@ -196,10 +215,33 @@ class CalendarController extends AbstractController
throw $this->createNotFoundException('Template not found');
}
+ $personsId = [];
+ foreach ($entity->getPersons() as $p) {
+ array_push($personsId, $p->getId());
+ }
+
+ $professionalsId = [];
+ foreach ($entity->getProfessionals() as $p) {
+ array_push($professionalsId, $p->getId());
+ }
+
+ $durationTime = $entity->getEndDate()->diff($entity->getStartDate());
+ $durationTimeInMinutes = $durationTime->days*1440 + $durationTime->h*60 + $durationTime->i;
+
+ $activityData = [
+ 'calendarId' => $id,
+ 'personsId' => $personsId,
+ 'professionalsId' => $professionalsId,
+ 'date' => $entity->getStartDate()->format('Y-m-d'),
+ 'durationTime' => $durationTimeInMinutes,
+ 'comment' => $entity->getComment()->getComment(),
+ ];
+
return $this->render($view, [
'accompanyingCourse' => $accompanyingPeriod,
'entity' => $entity,
- 'user' => $user
+ 'user' => $user,
+ 'activityData' => $activityData
//'delete_form' => $deleteForm->createView(),
]);
}
diff --git a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php
index 8660fac52..eaa8a1416 100644
--- a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php
+++ b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php
@@ -29,6 +29,7 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
$loader->load('services/controller.yml');
$loader->load('services/fixtures.yml');
$loader->load('services/form.yml');
+ $loader->load('services/event.yml');
}
public function prepend(ContainerBuilder $container)
diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php
new file mode 100644
index 000000000..f3c4e7a59
--- /dev/null
+++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php
@@ -0,0 +1,45 @@
+requestStack = $requestStack;
+ }
+
+ public function postPersist(Activity $activity, LifecycleEventArgs $event): void
+ {
+ // Get the calendarId from the request
+ $request = $this->requestStack->getCurrentRequest();
+
+ if (null === $request) {
+ return;
+ }
+
+ if ($request->query->has('activityData')) {
+ $activityData = $request->query->get('activityData');
+ if (array_key_exists('calendarId', $activityData)) {
+ $calendarId = $activityData['calendarId'];
+ }
+ }
+
+ // Attach the activity to the calendar
+ $em = $event->getObjectManager();
+
+ $calendar = $em->getRepository(\Chill\CalendarBundle\Entity\Calendar::class)->find($calendarId);
+ $calendar->setActivity($activity);
+
+ $em->persist($calendar);
+ $em->flush();
+
+ }
+}
diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php
index edb51bb35..b87f4f525 100644
--- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php
+++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php
@@ -3,7 +3,9 @@
namespace Chill\CalendarBundle\Repository;
use Chill\CalendarBundle\Entity\Calendar;
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
@@ -14,9 +16,13 @@ use Doctrine\Persistence\ManagerRegistry;
*/
class CalendarRepository extends ServiceEntityRepository
{
+
+ // private EntityRepository $repository;
+
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Calendar::class);
+ // $this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
}
// /**
diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/event.yml b/src/Bundle/ChillCalendarBundle/Resources/config/services/event.yml
new file mode 100644
index 000000000..348677174
--- /dev/null
+++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/event.yml
@@ -0,0 +1,10 @@
+services:
+ Chill\CalendarBundle\Event\ListenToActivityCreate:
+ autowire: true
+ autoconfigure: true
+ tags:
+ -
+ name: 'doctrine.orm.entity_listener'
+ event: 'postPersist'
+ entity: 'Chill\ActivityBundle\Entity\Activity'
+
\ No newline at end of file
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/list.html.twig
deleted file mode 100644
index 44295e192..000000000
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/list.html.twig
+++ /dev/null
@@ -1,135 +0,0 @@
-{% set user_id = null %}
-{% if user %}
- {% set user_id = user.id %}
-{% endif %}
-
-{% set accompanying_course_id = null %}
-{% if accompanyingCourse %}
- {% set accompanying_course_id = accompanyingCourse.id %}
-{% endif %}
-
-{% if context == 'user' %}
- {{ 'My calendar list' |trans }}
-{% else %}
- {{ 'Calendar list' |trans }}
-{% endif %}
-
-{% if context == 'user' %}
-
-{% else %}
-
- {% if calendarItems|length == 0 %}
-
- {{ "There is no calendar items."|trans }}
-
-
- {% else %}
-
-
-
- {% for calendar in calendarItems %}
-
-
-
-
-
-
- {% if calendar.startDate and calendar.endDate %}
- {% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
-
{{ "From the day"|trans }} {{ calendar.startDate|format_datetime('medium', 'short') }}
-
{{ "to the day"|trans }} {{ calendar.endDate|format_datetime('medium', 'short') }}
- {% else %}
-
{{ calendar.startDate|format_date('full') }}
-
{{ calendar.startDate|format_datetime('none', 'short', locale='fr') }} - {{ calendar.endDate|format_datetime('none', 'short', locale='fr') }}
-
-
-
-
- {{ calendar.endDate.diff(calendar.startDate)|date("%H:%M")}}
-
-
- {% endif %}
-
- {% endif %}
-
-
-
-
-
- {% if calendar.user %}
- -
- {{ 'by'|trans }}{{ calendar.user.usernameCanonical }}
-
- {% endif %}
-
- {% if calendar.mainUser is not empty %}
- -
- {{ 'main user concerned'|trans }}: {{ calendar.mainUser.usernameCanonical }}
-
- {% endif %}
-
-
-
- -
-
-
- {# TOOD
- {% if is_granted('CHILL_ACTIVITY_UPDATE', calendar) %}
- #}
- -
-
-
- {# TOOD
- {% endif %}
- {% if is_granted('CHILL_ACTIVITY_DELETE', calendar) %}
- #}
- -
-
-
- {#
- {% endif %}
- #}
-
-
-
-
- {%
- if calendar.comment.comment is not empty
- or calendar.users|length > 0
- or calendar.thirdParties|length > 0
- or calendar.users|length > 0
- %}
-
-
-
- {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': calendar } %}
-
-
- {% if calendar.comment.comment is not empty %}
-
- {% endif %}
-
- {% endif %}
-
-
- {% endfor %}
-
- {% endif %}
-
- {% if context != 'user' %}
- {# TODO set this condition in configuration #}
-
- {% endif %}
-
-
-
-{% endif %}
-
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
index c0230344d..07aed8686 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
@@ -4,6 +4,123 @@
{% block title %}{{ 'Calendar list' |trans }}{% endblock title %}
+{% set user_id = null %}
+{% set accompanying_course_id = accompanyingCourse.id %}
+
{% block content %}
- {% include 'ChillCalendarBundle:Calendar:list.html.twig' with {'context': 'accompanyingCourse'} %}
-{% endblock %}
+
+{{ 'Calendar list' |trans }}
+
+{% if calendarItems|length == 0 %}
+
+ {{ "There is no calendar items."|trans }}
+
+
+{% else %}
+
+
+
+ {% for calendar in calendarItems %}
+
+
+
+
+
+ {% if calendar.startDate and calendar.endDate %}
+ {% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
+
{{ "From the day"|trans }} {{ calendar.startDate|format_datetime('medium', 'short') }}
+
{{ "to the day"|trans }} {{ calendar.endDate|format_datetime('medium', 'short') }}
+ {% else %}
+
{{ calendar.startDate|format_date('full') }}
+
{{ calendar.startDate|format_datetime('none', 'short', locale='fr') }} - {{ calendar.endDate|format_datetime('none', 'short', locale='fr') }}
+
+
+
+
+ {{ calendar.endDate.diff(calendar.startDate)|date("%H:%M")}}
+
+
+ {% endif %}
+
+ {% endif %}
+
+
+
+
+ {% if calendar.user %}
+ -
+ {{ 'by'|trans }}{{ calendar.user.usernameCanonical }}
+
+ {% endif %}
+
+ {% if calendar.mainUser is not empty %}
+ -
+ {{ 'main user concerned'|trans }}: {{ calendar.mainUser.usernameCanonical }}
+
+ {% endif %}
+
+
+
+ -
+
+
+ {# TOOD
+ {% if is_granted('CHILL_ACTIVITY_UPDATE', calendar) %}
+ #}
+ -
+
+
+ {# TOOD
+ {% endif %}
+ {% if is_granted('CHILL_ACTIVITY_DELETE', calendar) %}
+ #}
+ -
+
+
+ {#
+ {% endif %}
+ #}
+
+
+
+
+ {%
+ if calendar.comment.comment is not empty
+ or calendar.users|length > 0
+ or calendar.thirdParties|length > 0
+ or calendar.users|length > 0
+ %}
+
+
+
+ {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': accompanyingCourse, 'with_display': 'row', 'entity': calendar } %}
+
+
+ {% if calendar.comment.comment is not empty %}
+
+ {% endif %}
+
+ {% endif %}
+
+
+ {% endfor %}
+
+ {% if calendarItems|length < paginator.getTotalItems %}
+ {{ chill_pagination(paginator) }}
+ {% endif %}
+
+
+{% endif %}
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByUser.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByUser.html.twig
index 004000fc6..055d967a7 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByUser.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByUser.html.twig
@@ -5,7 +5,10 @@
{% block title %}{{ 'My calendar list' |trans }}{% endblock title %}
{% block content %}
- {% include 'ChillCalendarBundle:Calendar:list.html.twig' with {'context': 'user'} %}
+
+{{ 'My calendar list' |trans }}
+
+
{% endblock %}
{% block js %}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig
similarity index 100%
rename from src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newAccompanyingCourse.html.twig
rename to src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig
index 971abe67d..e8830a33d 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig
@@ -65,13 +65,21 @@
{% endif %}
+ WIP .. AccompanyingCourse Resume dashboard
+
+ {#
{{ 'Resume Accompanying Course'|trans }}
@@ -50,11 +53,13 @@
{% endif %}
{% endfor %}
+ #}
{% if 'DRAFT' != accompanyingCourse.step %}
{% if withoutHousehold|length > 0 %}
{% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %}
{% endif %}
{% endif %}
+ {#
@@ -75,12 +80,11 @@
{% endif %}
-
+ #}
{% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %}
{% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' with {} %}
{% endif %}
-
-
+ {#
@@ -128,6 +132,8 @@
{% endif %}
+ #}
+
{{ 'Social actions'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/_insert_vue_address.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/_insert_vue_address.html.twig
deleted file mode 100644
index e235aae15..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/views/Address/_insert_vue_address.html.twig
+++ /dev/null
@@ -1,75 +0,0 @@
-{#
- This Twig template include load vue_address component.
- It push all variables from context in Address/App.vue.
-
- OPTIONS
- * mode string ['edit*'|'new'|'create']
- * address_id integer
- * backUrl twig route: path('route', {parameters})
- * modalTitle twig translated chain
- * buttonText twig translated chain
- * buttonSize bootstrap class like 'btn-sm'
- * buttonDisplayText bool
- * binModalStep1 bool
- * binModalStep2 bool
-
-#}
-
-
-
-
-{{ encore_entry_script_tags('vue_address') }}
-{{ encore_entry_link_tags('vue_address') }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/edit.html.twig
index 50bc14171..e2e9167b3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Address/edit.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Address/edit.html.twig
@@ -27,10 +27,13 @@
{{ block('title') }}
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- binModalStep1: false,
- binModalStep2: false,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'person', id: person.id },
+ openPanesInModal: false,
} %}
+ {#
+ backUrl: path('chill_person_address_list', { 'person_id': person.id }),
+ #}
{% endblock %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/list.html.twig
index db136592f..622a8a348 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Address/list.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Address/list.html.twig
@@ -29,7 +29,9 @@
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'person', id: person.id },
+ backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'new',
buttonSize: 'btn-lg',
buttonText: 'Add an address',
@@ -64,28 +66,30 @@
{% if address.validTo is not empty and address.validTo < previousRowFrom %}
+ {# include vue_address component #}
{#
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- address_id: address.id,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'person', id: person.id },
+ backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'edit',
- binModalStep1: false,
- binModalStep2: false,
+ addressId: address.id,
+ openPanesInModal: false,
} %}
#}
+ {# include vue_address component #}
{#
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- address_id: address.id,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'person', id: person.id },
+ backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'edit',
- binModalStep1: false,
- binModalStep2: false,
+ addressId: address.id,
+ openPanesInModal: false,
} %}
#}
@@ -109,7 +113,6 @@
}) }}
- {# include vue_address component #}
@@ -160,7 +163,6 @@
- {# include vue_address component #}
{{ 'Add an address'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig
index 3abd650f5..c88959340 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig
@@ -27,10 +27,16 @@
{{ block('title') }}
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- binModalStep1: false,
- binModalStep2: false,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'person', id: person.id },
+ stickyActions: true,
+ useValidFrom: true,
} %}
+ {#
+ useValidTo: true,
+ backUrl: path('chill_person_address_list', { 'person_id': person.id }),
+ openPanesInModal: false,
+ #}
{% endblock %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
index f60b7dc9e..612a5609c 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig
@@ -146,10 +146,10 @@
{% endif %}
{% endif %}
- {% if options['addCenter'] %}
+ {% if options['addCenter'] and person|chill_resolve_center is not null %}
- {{ person.center }}
+ {{ person|chill_resolve_center.name }}
{% endif %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig
index 446cd769b..c909e62d3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig
@@ -7,9 +7,11 @@
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- binModalStep1: false,
- binModalStep2: false,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'household', id: household.id },
+ backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
+ stickyActions: true,
+ openPanesInModal: false,
} %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_move.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_move.html.twig
index b2da2097a..2015a8599 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_move.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_move.html.twig
@@ -7,9 +7,11 @@
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- binModalStep1: false,
- binModalStep2: false,
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'household', id: household.id },
+ backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
+ openPanesInModal: false,
+ stickyActions: true,
} %}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig
index 2acd68731..646463945 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig
@@ -15,13 +15,17 @@
{# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'household', id: household.id },
+ backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
mode: 'new',
- backUrl: chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }),
buttonSize: 'btn-lg',
buttonText: 'Move household',
modalTitle: 'Move household',
} %}
+ {#
+ useValidFrom: true,
+ #}
@@ -41,7 +45,6 @@
@@ -63,8 +66,6 @@
}) }}
-
-
- {# include vue_address component #}
@@ -91,7 +92,6 @@
-
- {# include vue_address component #}
{{ 'Move household'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig
index 9b553f0f0..ceb835d2e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig
@@ -16,37 +16,39 @@
{% set address = household.currentAddress %}
- {% if address is empty %}
-
{{ 'household.Household does not have any address currently'|trans }}
- {% else %}
-
+
+
+
{{ 'Address'|trans }}
-
+ {% if address is empty %}
+
{{ 'household.Household does not have any address currently'|trans }}
+ {% else %}
+ {{ address|chill_entity_render_box({'multiline': true, 'extended_infos': true }) }}
+ {% endif %}
-
{{ 'Address'|trans }}
-
- {{ address|chill_entity_render_box({'multiline': true}) }}
-
-
- -
- {# include vue_address component #}
- {% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
- mode: 'create',
- buttonSize: 'btn-sm',
- buttonText: 'Move household',
- modalTitle: 'Move household',
- buttonDisplayText: false
- } %}
-
- -
-
-
-
-
-
-
-
+
+ -
+ {# include vue_address component #}
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'household', id: household.id },
+ backUrl: path('chill_person_household_summary', { 'household_id': household.id }),
+ hideAddress: true,
+ mode: 'new',
+ buttonSize: 'btn-sm',
+ buttonText: 'Move household',
+ modalTitle: 'Move household',
+ buttonDisplayText: false,
+ } %}
+
+ -
+
+
+
+
+
+
+ {% if address is not empty %}
-
- {% endif %}
+ {% endif %}
+
{{ 'household.Household members'|trans }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/banner_custom.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/banner_custom.html.twig
index d01a53c22..564f1803e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Person/banner_custom.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/banner_custom.html.twig
@@ -17,11 +17,11 @@
{%- endif -%}
- {%- if chill_person.fields.spoken_languages == 'visible' -%}
+ {% if person|chill_resolve_center is not null%}
{{ 'Center'|trans|upper}} :
- {{ person.center.name|upper }}
+ {{ person|chill_resolve_center.name|upper }}
{%- endif -%}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig
index 7056f25a3..bd1042dd7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig
@@ -76,10 +76,9 @@
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
-
- {# TODO remove this field (vendee) #}
- {{ form_row(form.center, { 'label' : 'Center'|trans }) }}
-
+ {% if form.center is defined %}
+ {{ form_row(form.center) }}
+ {% endif %}
-
+
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
index 19f81c01c..1b1207131 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue
@@ -1,22 +1,109 @@
-
- show
- thirdparty
- {{ id }}
+
-
+
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
index 265931e81..fa9ad8b8b 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
@@ -26,7 +26,7 @@
{{ pagination.totalItems }} {{ 'third parties'|trans }}
-
+
|
@@ -69,12 +69,12 @@
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
-
-
+
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
-
-
+
{% endif %}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig
index 1997466c2..002cc87e8 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig
@@ -26,12 +26,39 @@
{{ form_row(form.profession) }}
{% endif %}
- {{ form_row(form.categories) }}
{{ form_row(form.type) }}
+ {{ form_row(form.categories) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
- {{ form_row(form.address) }}
+
+
+ {{ form_label(form.address) }}
+ {{ form_widget(form.address) }}
+
+ {% if thirdParty.address %}
+ {# include vue_address component #}
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'thirdparty', id: thirdParty.id },
+ mode: 'edit',
+ addressId: thirdParty.address.id,
+ buttonSize: 'btn-sm',
+ } %}
+ {#
+ backUrl: path('chill_3party_3party_new'),
+ #}
+ {% else %}
+ {# include vue_address component #}
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'thirdparty', id: thirdParty.id },
+ mode: 'new',
+ buttonSize: 'btn-sm',
+ buttonText: 'Create a new address',
+ modalTitle: 'Create a new address',
+ } %}
+ {% endif %}
+
+
{{ form_row(form.comment) }}
{{ form_row(form.centers) }}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/show.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/show.html.twig
index 6f647f6b6..d711bdefa 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/show.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/show.html.twig
@@ -82,7 +82,7 @@
{% if thirdParty.address == null %}
{{ 'No address given'|trans }}
{% else %}
- {{ thirdParty.address|chill_entity_render_box({'with_valid_from': false }) }}
+ {{ thirdParty.address|chill_entity_render_box({'with_valid_from': false, 'extended_infos': true }) }}
{% endif %}
@@ -103,7 +103,7 @@