diff --git a/composer.json b/composer.json
index 20701e568..e6c5108f6 100644
--- a/composer.json
+++ b/composer.json
@@ -52,7 +52,8 @@
"symfony/browser-kit": "^5.2",
"symfony/css-selector": "^5.2",
"twig/markdown-extra": "^3.3",
- "erusev/parsedown": "^1.7"
+ "erusev/parsedown": "^1.7",
+ "symfony/serializer": "^5.2"
},
"conflict": {
"symfony/symfony": "*"
diff --git a/src/Bundle/ChillMainBundle/Resources/public/main.js b/src/Bundle/ChillMainBundle/Resources/public/main.js
index 2eeecd27e..fd67f55b8 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/main.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/main.js
@@ -35,7 +35,7 @@ require('./modules/download-report/index.js');
require('./modules/select_interactive_loading/index.js');
require('./modules/export-list/export-list.scss');
require('./modules/entity/index.js');
-require('./modules/tabs/index.js');
+//require('./modules/tabs/index.js');
/*
* load img
diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/AccompanyingCourse.vue b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/AccompanyingCourse.vue
new file mode 100644
index 000000000..f2d42e866
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/AccompanyingCourse.vue
@@ -0,0 +1,87 @@
+
+
+
+ - id
+ - {{ accompanying_course.id }}
+ - opening_date
+ - {{ accompanying_course.opening_date }}
+ - closing_date
+ - {{ accompanying_course.closing_date }}
+ - remark
+ - {{ accompanying_course.remark }}
+ - closing_motive
+ - {{ accompanying_course.closing_motive }}
+
+
+
+
+
+ firstname |
+ lastname |
+ startdate |
+ enddate |
+ actions |
+
+
+
+
+ {{ person.firstname }} |
+ {{ person.lastname }} |
+ {{ person.startdate }} |
+ {{ person.enddate }} |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/App.vue b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/App.vue
index 50b898cfa..7cab5069c 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/App.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/App.vue
@@ -1,19 +1,19 @@
diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/Contacts.vue b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/Contacts.vue
deleted file mode 100644
index f4bb02d7c..000000000
--- a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/components/Contacts.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
- {{contact.firstname}} |
- {{contact.lastname}} |
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/index.js b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/index.js
index c789f16ba..bc25630d9 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/modules/vue/index.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/modules/vue/index.js
@@ -2,6 +2,6 @@ import Vue from 'vue'
import App from './components/App.vue'
new Vue({
- el: '#app',
- render: h => h(App)
+ el: '#app',
+ render: h => h(App)
})
diff --git a/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss
index fd58e1c46..4f9ecf46d 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss
+++ b/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss
@@ -35,7 +35,23 @@ div#header-accompanying_course-details {
/* /!\ Contourne le positionnement problématique du div#content_conainter suivant,
* car sa position: relative le place au-dessus du bandeau et les liens sont incliquables */
-
div.subheader {
height: 130px;
}
+
+div.vue-component {
+ padding: 1.5em;
+ margin: 2em 0;
+ border: 2px dashed grey;
+ position: relative;
+ &:before {
+ content: "vuejs component";
+ position: absolute;
+ left: 1.5em;
+ top: -0.9em;
+ background-color: white;
+ color: grey;
+ padding: 0 0.3em;
+ }
+ dd { margin-left: 1em; }
+}
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
index cfd677373..dd4ba8f2d 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
@@ -3,10 +3,18 @@
namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
+use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
+use Chill\PersonBundle\Entity\Person;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Serializer\Encoder\JsonEncoder;
+use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
+use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
+use Symfony\Component\Serializer\Serializer;
+use Symfony\Component\Serializer\SerializerInterface;
/**
* Class AccompanyingCourseController
@@ -27,7 +35,7 @@ class AccompanyingCourseController extends Controller
'accompanyingCourse' => $accompanyingCourse
]);
}
-
+
/**
* Show page of Accompanying Course section
*
@@ -43,7 +51,7 @@ class AccompanyingCourseController extends Controller
'accompanyingCourse' => $accompanyingCourse
]);
}
-
+
/**
* History page of Accompanying Course section
*
@@ -58,6 +66,53 @@ class AccompanyingCourseController extends Controller
'accompanyingCourse' => $accompanyingCourse
]);
}
+
+ /**
+ * Sérialise temporairement quelques données pour donner à manger au composant vuejs
+ * @Route(
+ * "/{_locale}/api/parcours/{accompanying_period_id}/show",
+ * name="chill_person_accompanying_course_api_show")
+ * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
+ * @param SerializerInterface $serializer
+ */
+ public function showAPI(AccompanyingPeriod $accompanyingCourse): Response
+ {
+ $persons = [];
+ foreach ($accompanyingCourse->getParticipations() as $k => $participation ) {
+ /**
+ * @var AccompanyingPeriodParticipation $participation
+ * @var Person $person
+ */
+ $person = $participation->getPerson();
+ $persons[$k] = [
+ 'firstname' => $person->getFirstName(),
+ 'lastname' => $person->getLastName(),
+ 'email' => $person->getEmail(),
+ 'phone' => $person->getPhonenumber(),
+ 'startdate' => ($participation->getStartDate()) ? $participation->getStartDate()->format('Y-m-d') : null,
+ 'enddate' => ($participation->getEndDate()) ? $participation->getEndDate()->format('Y-m-d') : null
+ ];
+ }
+ $data = [
+ 'id' => $accompanyingCourse->getId(),
+ 'remark' => $accompanyingCourse->getRemark(),
+ 'closing_motive' => $accompanyingCourse->getClosingMotive()->getName()['fr'],
+ 'opening_date' => ($accompanyingCourse->getOpeningDate()) ? $accompanyingCourse->getOpeningDate()->format('Y-m-d') : null,
+ 'closing_date' => ($accompanyingCourse->getClosingDate()) ? $accompanyingCourse->getClosingDate()->format('Y-m-d') : null,
+ 'persons' => $persons
+ ];
+
+ $normalizer = [new ObjectNormalizer()];
+ $encoder = [new JsonEncoder()];
+
+ $serializer = new Serializer($normalizer, $encoder);
+ $serialized = $serializer->serialize($data,'json', []);
+
+ $response = new Response($serialized);
+ $response->headers->set('Content-Type', 'application/json');
+ return $response;
+ }
+
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index a7311f838..3034da3a9 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -251,7 +251,7 @@ class AccompanyingPeriod
*
* @return \DateTime
*/
- public function getClosingDate()
+ public function getClosingDate(): ?\DateTime
{
return $this->closingDate;
}
@@ -425,15 +425,17 @@ class AccompanyingPeriod
*
* @return boolean
*/
- public function isClosingAfterOpening()
+ public function isClosingAfterOpening(): bool
{
- $diff = $this->getOpeningDate()->diff($this->getClosingDate());
-
- if ($diff->invert === 0) {
- return true;
- } else {
+ if (null === $this->getClosingDate()) {
return false;
}
+ $diff = $this->getOpeningDate()->diff($this->getClosingDate());
+
+ if ($diff->invert === 0) {
+ return true;
+ }
+ return false;
}
function getUser(): ?User
@@ -447,8 +449,8 @@ class AccompanyingPeriod
return $this;
}
-
- public function getOrigin(): Origin
+
+ public function getOrigin(): ?Origin
{
return $this->origin;
}
@@ -539,8 +541,8 @@ class AccompanyingPeriod
return $this;
}
-
- public function getStep(): string
+
+ public function getStep(): ?string
{
return $this->step;
}
@@ -551,8 +553,8 @@ class AccompanyingPeriod
return $this;
}
-
- public function getIntensity(): string
+
+ public function getIntensity(): ?string
{
return $this->intensity;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index b493975cf..a25f84fbb 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -369,7 +369,7 @@ class Person implements HasCenterInterface
/**
* Return the opened accompanying period.
*/
- public function getOpenedAccompanyingPeriod() : AccompanyingPeriod
+ public function getOpenedAccompanyingPeriod() : ?AccompanyingPeriod
{
if ($this->isOpen() === false) {
return null;
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig
index b90aae74e..c3d8a4b8c 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/show.html.twig
@@ -8,6 +8,7 @@
{{ block('title') }}
+{#
{{ accompanyingCourse.id }}
{{ accompanyingCourse.openingDate|format_date('short') }}
@@ -20,10 +21,9 @@ usagers:
{{ p.person.id }} | {{ p.person.fullnamecanonical }} | {{ p.startdate|format_date('short') }} | {{ p.enddate|format_date('short') }}
{% endfor %}
-
{{ dump() }}
+#}
- TESTS AREA vuejs:
{% verbatim %}
{% endverbatim %}
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index 812440bee..24b35a8e3 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -38,3 +38,6 @@ services:
$personMove: '@Chill\PersonBundle\Actions\Remove\PersonMove'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
tags: ['controller.service_arguments']
+
+ Chill\PersonBundle\Controller\AccompanyingCourseController:
+ tags: ['controller.service_arguments']