From 1b0c19a68f544a0c74bb58f667cdaa320774e872 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 18 Oct 2021 15:47:57 +0200
Subject: [PATCH 001/119] prepare vue_visgraph component, with store, dataset
and display basic graph
---
.../Controller/HouseholdController.php | 17 +++-
.../Resources/public/page/vis/index.js | 32 --------
.../Resources/public/page/vis/scss/vis.scss | 5 --
.../Resources/public/vuejs/VisGraph/App.vue | 51 ++++++++++++
.../Resources/public/vuejs/VisGraph/api.js | 79 +++++++++++++++++++
.../Resources/public/vuejs/VisGraph/i18n.js | 15 ++++
.../Resources/public/vuejs/VisGraph/index.js | 27 +++++++
.../Resources/public/vuejs/VisGraph/store.js | 47 +++++++++++
.../views/Household/relationship.html.twig | 30 ++++---
.../ChillPersonBundle/chill.webpack.config.js | 2 +-
.../translations/messages+intl-icu.fr.yaml | 4 +-
11 files changed, 250 insertions(+), 59 deletions(-)
delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
delete mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
index 1b9824184..bd3bf7889 100644
--- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php
@@ -9,6 +9,8 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
+use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Chill\PersonBundle\Entity\Household\Household;
@@ -24,11 +26,16 @@ class HouseholdController extends AbstractController
private PositionRepository $positionRepository;
- public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
+ private SerializerInterface $serializer;
- {
+ public function __construct(
+ TranslatorInterface $translator,
+ PositionRepository $positionRepository,
+ SerializerInterface $serializer
+ ) {
$this->translator = $translator;
$this->positionRepository = $positionRepository;
+ $this->serializer = $serializer;
}
/**
@@ -177,9 +184,13 @@ class HouseholdController extends AbstractController
*/
public function showRelationship(Request $request, Household $household)
{
+ $jsonString = $this->serializer->serialize($household->getCurrentPersons(),
+ 'json', [ AbstractNormalizer::GROUPS => ['read']]);
+
return $this->render('@ChillPerson/Household/relationship.html.twig',
[
- 'household' => $household
+ 'household' => $household,
+ 'persons' => $jsonString
]
);
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js b/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
deleted file mode 100644
index f11e930c0..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import vis from 'vis-network/dist/vis-network.min';
-
-require('./scss/vis.scss');
-
-// create an array with nodes
-let nodes = new vis.DataSet([
- { id: 1, label: "Node 1" },
- { id: 2, label: "Node 2" },
- { id: 3, label: "Node 3" },
- { id: 4, label: "Node 4" },
- { id: 5, label: "Node 5", cid: 1 },
-]);
-
-// create an array with edges
-let edges = new vis.DataSet([
- { from: 1, to: 3 },
- { from: 1, to: 2 },
- { from: 2, to: 4 },
- { from: 2, to: 5 },
- { from: 3, to: 3 },
-]);
-
-// create a network
-let container = document.getElementById("graph-relationship");
-let data = {
- nodes: nodes,
- edges: edges,
-};
-let options = {};
-
-//
-let network = new vis.Network(container, data, options);
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss b/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
deleted file mode 100644
index 3d29c47ce..000000000
--- a/src/Bundle/ChillPersonBundle/Resources/public/page/vis/scss/vis.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-div#graph-relationship {
- margin: 2em auto;
- height: 500px;
- border: 1px solid lightgray;
-}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
new file mode 100644
index 000000000..bbaebf670
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
new file mode 100644
index 000000000..009d1309d
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -0,0 +1,79 @@
+/**
+ * @var makeFetch
+ */
+const makeFetch = (method, url, body) => {
+
+ return fetch(url, {
+ method: method,
+ headers: {
+ 'Content-Type': 'application/json;charset=utf-8'
+ },
+ body: JSON.stringify(body)
+ })
+ .then(response => {
+
+ if (response.ok) {
+ return response.json();
+ }
+
+ if (response.status === 422) {
+ return response.json();
+ }
+
+ throw {
+ msg: 'Error while updating AccompanyingPeriod Course.',
+ sta: response.status,
+ txt: response.statusText,
+ err: new Error(),
+ body: response.body
+ };
+ });
+}
+
+/**
+ * @var getHousehold
+*/
+const getHousehold = (person) => {
+ console.log('getHousehold', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/person/household/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+/**
+ * @var getCourse
+*/
+const getCourse = (person) => {
+ console.log('getCourse', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/person/accompanying-course/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+/**
+ * @var getRelationship
+*/
+const getRelationship = (person) => {
+ console.log('getRelationship', person.id)
+ makeFetch(
+ 'GET',
+ `/api/1.0/relations/relationship/by-person/${person.id}.json`,
+ {
+ type: 'person',
+ id: person.id
+ })
+}
+
+export {
+ getHousehold,
+ getCourse,
+ getRelationship
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
new file mode 100644
index 000000000..950f5533c
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -0,0 +1,15 @@
+//import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
+
+const visMessages = {
+ fr: {
+ visgraph: {
+
+ }
+ }
+}
+
+//Object.assign(visMessages.fr, personMessages.fr);
+
+export {
+ visMessages
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
new file mode 100644
index 000000000..e70e3bb18
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -0,0 +1,27 @@
+import { createApp } from "vue"
+import { store } from "./store.js"
+import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
+import { visMessages } from './i18n'
+import App from './App.vue'
+
+const i18n = _createI18n(visMessages)
+
+const container = document.getElementById('relationship-graph')
+
+const persons = JSON.parse(container.dataset.persons)
+
+persons.forEach(person => {
+ store.dispatch('addPerson', person)
+ store.dispatch('fetchInfoForPerson', person)
+})
+
+const app = createApp({
+ template: ` `
+})
+.use(store)
+.use(i18n)
+.component('app', App)
+.mount('#relationship-graph')
+
+
+//console.log('container dataset', container.dataset.persons)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
new file mode 100644
index 000000000..ecb79c16e
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -0,0 +1,47 @@
+import { createStore } from 'vuex'
+import { getHousehold, getCourse, getRelationship } from './api'
+
+const debug = process.env.NODE_ENV !== 'production'
+
+const store = createStore({
+ strict: debug,
+ state: {
+ persons: [],
+ households: [],
+ courses: [],
+ relationships: [],
+ },
+ getters: {
+ getNodes() {
+ let nodes = [];
+ state.households.forEach(h => {
+ nodes.push(h)
+ });
+ return nodes
+ },
+ getEdges() {
+ }
+ },
+ mutations: {
+ addPerson(state, person) {
+ person.label = person.text // vis need label
+ state.persons.push(person)
+ }
+ },
+ actions: {
+ addPerson({ commit }, person) {
+ //console.log('addPerson', person)
+ commit('addPerson', person)
+ },
+ fetchInfoForPerson({ commit }, person) {
+ console.log('fetchInfoForPerson', person)
+
+ getHousehold(person)
+ getCourse(person)
+ getRelationship(person)
+
+ },
+ }
+});
+
+export { store }
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
index 5d5fc77af..db143e39f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
@@ -4,24 +4,22 @@
{% block content %}
{{ block('title') }}
-
- {% for m in household.members %}
- {% if m.endDate is null %}
- {{ dump(m) }}
- {% endif %}
- {% endfor %}
+
+
+ {#
+ {{ dump() }}
+ #}
{% endblock %}
-{% block js %}
- {{ parent() }}
- {{ encore_entry_script_tags('page_vis') }}
-{% endblock %}
-
-{% block css %}
- {{ parent() }}
- {{ encore_entry_link_tags('page_vis') }}
-{% endblock %}
-
{% block block_post_menu %}{% endblock %}
+
+{% block js %}
+ {{ encore_entry_script_tags('vue_visgraph') }}
+{% endblock %}
+
+{% block css %}
+ {{ encore_entry_link_tags('vue_visgraph') }}
+{% endblock %}
diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js
index 925a5ccf8..e033fc89d 100644
--- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js
+++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js
@@ -12,9 +12,9 @@ module.exports = function(encore, entries)
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
encore.addEntry('vue_accourse_work_create', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js');
encore.addEntry('vue_accourse_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js');
+ encore.addEntry('vue_visgraph', __dirname + '/Resources/public/vuejs/VisGraph/index.js');
encore.addEntry('page_household_edit_metadata', __dirname + '/Resources/public/page/household_edit_metadata/index.js');
encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js');
encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');
- encore.addEntry('page_vis', __dirname + '/Resources/public/page/vis/index.js');
};
diff --git a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
index c92dc6a31..ba7133b2a 100644
--- a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
+++ b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml
@@ -51,8 +51,8 @@ household:
Household summary: Résumé du ménage
Accompanying period: Parcours d'accompagnement
Addresses: Historique adresse
- Relationship: Composition familiale
- Household relationships: Composition du ménage
+ Relationship: Filiation
+ Household relationships: Filiations dans le ménage
Current address: Adresse actuelle
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
Edit household members: Modifier l'appartenance au ménage
From 902c45f0cd012a63768dfa375c95fc8febad1e89 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 20 Oct 2021 13:11:58 +0200
Subject: [PATCH 002/119] endpoint created for acc periods by-person
---
.../AccompanyingCourseApiController.php | 25 ++++++++++++++++++-
.../ChillPersonExtension.php | 8 ++++++
.../ChillPersonBundle/chill.api.specs.yaml | 23 +++++++++++++++++
.../config/services/controller.yaml | 10 +++++---
4 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 8201752af..e7243fba1 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -18,7 +18,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Entity\Scope;
+use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
+use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Workflow\Registry;
+use Symfony\Component\Routing\Annotation\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingCourseApiController extends ApiController
{
@@ -28,14 +32,18 @@ class AccompanyingCourseApiController extends ApiController
private Registry $registry;
+ private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
+
public function __construct(
EventDispatcherInterface $eventDispatcher,
ValidatorInterface $validator,
- Registry $registry
+ Registry $registry,
+ AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository
) {
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
$this->registry = $registry;
+ $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
}
public function confirmApi($id, Request $request, $_format): Response
@@ -187,4 +195,19 @@ $workflow = $this->registry->get($accompanyingPeriod);
return null;
}
+
+ /**
+ * @Route("/api/1.0/person/accompanying-course/by-person/{person_id}.{_format}",
+ * name="chill_person_accompanyingperiod_by_person",
+ * requirements={
+ * "_format"="json"
+ * })
+ *
+ * @ParamConverter("person", options={"id" = "person_id"})
+ */
+ public function getAccompanyingPeriodsByPerson(Person $person){
+ $accompanyingPeriods = $person->getAccompanyingPeriods();
+ return $this->json(\array_values($accompanyingPeriods), Response::HTTP_OK, [], ['groups' => [ 'read']]);
+ }
+
}
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
index bc3b798fa..1dd1a7979 100644
--- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
+++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
@@ -585,6 +585,14 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
]
],
+ 'findAccompanyingPeriodsByPerson' => [
+ 'path' => '/by-person/{person_id}.{_format}',
+ 'controller_action' => 'findAccompanyingPeriodsByPerson',
+ 'methods' => [
+ Request::METHOD_GET => true,
+ Request::METHOD_HEAD => true,
+ ]
+ ]
]
],
[
diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
index 4041c52b7..5d3f07259 100644
--- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
+++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml
@@ -1058,6 +1058,29 @@ paths:
description: "OK"
400:
description: "transition cannot be applyed"
+
+ /1.0/person/accompanying-course/by-person/{person_id}.json:
+ get:
+ tags:
+ - accompanying period
+ summary: get a list of accompanying periods for a person
+ description: Returns a list of the current accompanying periods for a person
+ parameters:
+ - name: person_id
+ in: path
+ required: true
+ description: The person id
+ schema:
+ type: integer
+ format: integer
+ minimum: 1
+ responses:
+ 401:
+ description: "Unauthorized"
+ 404:
+ description: "Not found"
+ 200:
+ description: "OK"
/1.0/person/accompanying-period/origin.json:
get:
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index 489168425..c61362583 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -41,10 +41,12 @@ services:
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
- arguments:
- $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $registry: '@Symfony\Component\Workflow\Registry'
+ autowire: true
+ autoconfigure: true
+ # arguments:
+ # $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
+ # $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
+ # $registry: '@Symfony\Component\Workflow\Registry'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonApiController:
From 8d947ea81b8489b2a7d6b38aa2df8f651f73bb1d Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 20 Oct 2021 13:37:27 +0200
Subject: [PATCH 003/119] viewing permission checked for returned accompanying
periods by-person
---
.../Controller/AccompanyingCourseApiController.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index e7243fba1..891a0f461 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -207,7 +207,11 @@ $workflow = $this->registry->get($accompanyingPeriod);
*/
public function getAccompanyingPeriodsByPerson(Person $person){
$accompanyingPeriods = $person->getAccompanyingPeriods();
- return $this->json(\array_values($accompanyingPeriods), Response::HTTP_OK, [], ['groups' => [ 'read']]);
+ $accompanyingPeriodsChecked = array_filter($accompanyingPeriods,
+ function(AccompanyingPeriod $period){
+ return $this->isGranted(AccompanyingPeriodVoter::SEE, $period);
+ });
+ return $this->json(\array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
}
From d7cf45885e7fcff61f9f88852f85af2108cee7bf Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 20 Oct 2021 10:15:33 +0200
Subject: [PATCH 004/119] vue_visgraph: vuex get household and update nodes
array
---
.../Resources/public/vuejs/VisGraph/App.vue | 58 +++++----
.../Resources/public/vuejs/VisGraph/api.js | 120 ++++++++++++------
.../Resources/public/vuejs/VisGraph/index.js | 5 +-
.../Resources/public/vuejs/VisGraph/store.js | 65 ++++++++--
4 files changed, 171 insertions(+), 77 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index bbaebf670..f78b9fb62 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -4,40 +4,52 @@
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 009d1309d..50aafc04b 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -1,14 +1,17 @@
/**
- * @var makeFetch
+ * @function makeFetch
+ * @param method
+ * @param url
+ * @param body
+ * @returns {Promise}
*/
const makeFetch = (method, url, body) => {
-
return fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
- body: JSON.stringify(body)
+ body: (body !== null) ? JSON.stringify(body) : null
})
.then(response => {
@@ -31,49 +34,92 @@ const makeFetch = (method, url, body) => {
}
/**
- * @var getHousehold
-*/
-const getHousehold = (person) => {
- console.log('getHousehold', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/person/household/by-person/${person.id}.json`,
- {
- type: 'person',
- id: person.id
- })
+ * @function getFetch
+ * @param url
+ * @returns {Promise}
+ */
+const getFetch = (url) => {
+ return makeFetch('GET', url, null);
}
/**
- * @var getCourse
-*/
-const getCourse = (person) => {
- console.log('getCourse', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/person/accompanying-course/by-person/${person.id}.json`,
- {
- type: 'person',
- id: person.id
- })
+ * @function postFetch
+ * @param url
+ * @param body
+ * @returns {Promise}
+ */
+const postFetch = (url, body) => {
+ return makeFetch('POST', url, body);
}
/**
- * @var getRelationship
-*/
+ * @function patchFetch
+ * @param url
+ * @param body
+ * @returns {Promise}
+ */
+const patchFetch = (url, body) => {
+ return makeFetch('PATCH', url, body);
+}
+
+
+/**
+ * @function getHouseholdByPerson
+ * @param person
+ * @returns {Promise}
+ */
+const getHouseholdByPerson = (person) => {
+ //console.log('getHouseholdByPerson', person.id)
+ if (person.current_household_id === null) {
+ throw 'Currently the person has not household!'
+ }
+ return getFetch(
+ `/api/1.0/person/household/${person.current_household_id}.json`)
+}
+
+/**
+ * @function getCourseByPerson
+ * @param person
+ * @returns {Promise}
+ */
+const getCourseByPerson = (person) => {
+ //console.log('getCourseByPerson', person.id)
+ return getFetch(
+ `/api/1.0/person/accompanying-course/by-person/${person.id}.json`)
+}
+
+/**
+ * @function getRelationship
+ * @param person
+ * @returns {Promise}
+ */
const getRelationship = (person) => {
- console.log('getRelationship', person.id)
- makeFetch(
- 'GET',
- `/api/1.0/relations/relationship/by-person/${person.id}.json`,
+ //console.log('getRelationship', person.id)
+ return getFetch(
+ `/api/1.0/relations/relationship/by-person/${person.id}.json`)
+}
+
+/**
+ * @function postRelationship
+ * @param person
+ * @returns {Promise}
+ */
+const postRelationship = (person) => {
+ //console.log('postRelationship', person.id)
+ return postFetch(
+ `/api/1.0/relations/relationship.json`,
{
- type: 'person',
- id: person.id
- })
+ from: { type: 'person', id: 0 },
+ to: { type: 'person', id: 0 },
+ relation: { type: 'relation', id: 0 },
+ reverse: bool
+ }
+ )
}
export {
- getHousehold,
- getCourse,
- getRelationship
+ getHouseholdByPerson,
+ getCourseByPerson,
+ getRelationship,
+ postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
index e70e3bb18..0aeb032d5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -12,7 +12,7 @@ const persons = JSON.parse(container.dataset.persons)
persons.forEach(person => {
store.dispatch('addPerson', person)
- store.dispatch('fetchInfoForPerson', person)
+ //store.dispatch('fetchInfoForPerson', person)
})
const app = createApp({
@@ -22,6 +22,3 @@ const app = createApp({
.use(i18n)
.component('app', App)
.mount('#relationship-graph')
-
-
-//console.log('container dataset', container.dataset.persons)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index ecb79c16e..d286bf75f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,5 +1,5 @@
import { createStore } from 'vuex'
-import { getHousehold, getCourse, getRelationship } from './api'
+import { getHouseholdByPerson, getCourseByPerson, getRelationship } from './api'
const debug = process.env.NODE_ENV !== 'production'
@@ -10,36 +10,75 @@ const store = createStore({
households: [],
courses: [],
relationships: [],
+ householdLoadingIds: [],
},
getters: {
- getNodes() {
+ nodes(state) {
let nodes = [];
+ state.persons.forEach(p => {
+ nodes.push(p)
+ })
state.households.forEach(h => {
nodes.push(h)
- });
+ })
+ // push all others kinds of nodes..
return nodes
},
- getEdges() {
- }
+ edges(state) {
+ return []
+ },
+ isHouseholdLoading: (state) => (household_id) => {
+ return state.householdLoadingIds.includes(household_id);
+ },
},
mutations: {
addPerson(state, person) {
person.label = person.text // vis need label
state.persons.push(person)
+ },
+ addHousehold(state, household) {
+ household.label = `Ménage n° ${household.id}` // vis need label
+ state.households.push(household)
+ },
+ markHouseholdLoading(state, id) {
+ console.log('mutation: markHouseholdLoading', id)
+ state.householdLoadingIds.push(id)
+ },
+ unmarkHouseholdLoading(state, id) {
+ state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
}
},
actions: {
- addPerson({ commit }, person) {
- //console.log('addPerson', person)
+ addPerson({ commit, dispatch }, person) {
+ console.log('addPerson', person.id)
commit('addPerson', person)
+ dispatch('fetchInfoForPerson', person)
+ },
+ fetchInfoForPerson({ dispatch }, person) {
+ //console.log('fetchInfoForPerson', person.id)
+ dispatch('fetchHouseholdForPerson', person)
+ //getCourseByPerson(person)
+ //getRelationship(person)
},
- fetchInfoForPerson({ commit }, person) {
- console.log('fetchInfoForPerson', person)
-
- getHousehold(person)
- getCourse(person)
- getRelationship(person)
+ /**
+ * Fetch person current household if it is not already loading
+ * check first isHouseholdLoading to fetch household once
+ */
+ fetchHouseholdForPerson({ commit, getters }, person) {
+ console.log('isHouseholdLoading', getters.isHouseholdLoading(person.current_household_id))
+ if (! getters.isHouseholdLoading(person.current_household_id)) {
+ commit('markHouseholdLoading', person.current_household_id)
+ getHouseholdByPerson(person)
+ .then(household => new Promise(resolve => {
+ console.log('getHouseholdByPerson', household)
+ commit('addHousehold', household)
+ resolve()
+ })
+ ).catch( () => {
+ commit('unmarkHouseholdLoading', person.current_household_id)
+ });
+ }
},
}
});
From 6ff80be88d958cb49f84046284ec01327a554adc Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 22 Oct 2021 10:11:33 +0200
Subject: [PATCH 005/119] vue_visgraph: add vis manipulation actions and vis
styles
---
.../Resources/public/vuejs/VisGraph/App.vue | 82 +++++++++++++------
.../Resources/public/vuejs/VisGraph/store.js | 2 +
2 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index f78b9fb62..0518a93d2 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -1,59 +1,87 @@
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 77a01af4a..f7af08240 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -6,7 +6,8 @@ const visMessages = {
'Course': 'Parcours',
'Household': 'Ménage',
}
- }
+ },
+ en: {}
}
//Object.assign(visMessages.fr, personMessages.fr);
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 288bc1f94..a06e6e55c 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -74,10 +74,19 @@ const store = createStore({
},
},
actions: {
+ /**
+ * 1) Add a person in state
+ * @param Person person
+ */
addPerson({ commit, dispatch }, person) {
commit('addPerson', person)
dispatch('fetchInfoForPerson', person)
},
+
+ /**
+ * 2) Fetch infos for this person (hub)
+ * @param Person person
+ */
fetchInfoForPerson({ dispatch }, person) {
dispatch('fetchHouseholdForPerson', person)
dispatch('fetchCoursesByPerson', person)
@@ -85,8 +94,9 @@ const store = createStore({
},
/**
- * Fetch person current household if it is not already loading
+ * 3) Fetch person current household (if it is not already loading)
* check first isHouseholdLoading to fetch household once
+ * @param Person person
*/
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
@@ -104,6 +114,11 @@ const store = createStore({
})
}
},
+
+ /**
+ * 4) Add an edge for each household member (household -> person)
+ * @param Household household
+ */
addLinkFromPersonsToHousehold({ commit }, household) {
const members = household.members.filter(v => household.current_members_id.includes(v.id))
members.forEach(m => {
@@ -111,14 +126,20 @@ const store = createStore({
commit('addRelationship', {
from: `${m.person.type}_${m.person.id}`,
to: `household_${m.person.current_household_id}`,
- id: `p${m.person.id}-h${m.person.current_household_id}`
+ id: `p${m.person.id}-h${m.person.current_household_id}`,
+ arrows: 'from',
+ color: 'pink',
+ font: { color: 'pink' },
+ label: 'enfant',
+ ////group: 'link_person_household',
})
})
},
/**
- * Fetch person current AccompanyingCourses
+ * 5) Fetch AccompanyingCourses for the person
+ * @param Person person
*/
fetchCoursesByPerson({ dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
@@ -130,6 +151,11 @@ const store = createStore({
}))
},
+
+ /**
+ * 6) Add each distinct course
+ * @param array courses
+ */
addCourse({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
let currentCourses = courses.filter(c => c.closingDate === null)
@@ -143,6 +169,11 @@ const store = createStore({
}
})
},
+
+ /**
+ * 7) Add an edge for each course participation (course <- person)
+ * @param AccompanyingCourse course
+ */
addLinkFromPersonsToCourse({ commit }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
@@ -150,7 +181,12 @@ const store = createStore({
commit('addRelationship', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
- id: `p${p.person.id}-c`+ course.id.split('_')[2]
+ id: `p${p.person.id}-c`+ course.id.split('_')[2],
+ arrows: 'to',
+ color: 'orange',
+ font: { color: 'orange' },
+ label: 'usager',
+ //group: 'link_person_course',
})
})
},
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f90b8a917..cc0ef717a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -8,6 +8,8 @@ import { visMessages } from './i18n'
*/
window.options = {
+ locale: 'fr',
+ locales: visMessages,
manipulation: {
enabled: true,
initiallyActive: true,
@@ -20,6 +22,10 @@ window.options = {
console.log('editNode', nodeData)
callback(nodeData);
},
+ deleteNode: function(nodeData, callback) {
+ console.log('deleteNode', nodeData)
+ callback(nodeData);
+ },
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData);
@@ -28,12 +34,78 @@ window.options = {
console.log('editNode', edgeData)
callback(edgeData);
},
+ deleteEdge: function(edgeData, callback) {
+ console.log('deleteNode', edgeData)
+ callback(edgeData);
+ },
+ controlNodeStyle: { /*
+ shape:'dot',
+ size: 6,
+ color: {
+ background: '#ff0000',
+ border: '#3c3c3c',
+ highlight: {
+ background: '#07f968',
+ border: '#3c3c3c'
+ }
+ },
+ borderWidth: 2,
+ borderWidthSelected: 2
+ */
+ }
},
nodes: {
- physics: true
+ physics: true,
+ borderWidth: 1,
+ borderWidthSelected: 3,
},
edges: {
- physics: true
+ physics: true,
+ font: {
+ color: '#b0b0b0',
+ size: 9,
+ face: 'arial',
+ background: 'none',
+ strokeWidth: 2, // px
+ strokeColor: '#ffffff',
+ align: 'horizontal',
+ multi: false,
+ vadjust: 0,
+ },
+ scaling:{
+ label: true,
+ },
+ smooth: true,
+ },
+ groups: {
+ person: {
+ shape: 'box',
+ shapeProperties: {
+ borderDashes: false,
+ borderRadius: 3,
+ },
+ color: {
+ border: '#b0b0b0',
+ background: 'rgb(193,229,222)',
+ highlight: {
+ border: '#368d7e',
+ background: 'rgb(193,229,222)'
+ }
+ }
+ },
+ household: {
+ /*
+ shape: 'dot',
+ */
+ color: 'pink'
+ },
+ accompanying_period: {
+ /*
+ shape: 'triangle',
+ */
+ color: 'orange',
+
+ },
}
};
@@ -45,6 +117,7 @@ window.network = {};
* and add properties needed by vis
*/
const adapt2vis = (entity) => {
+ entity.group = entity.type
switch (entity.type) {
case 'person':
entity._id = entity.id
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
index db143e39f..c6d7330fa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/relationship.html.twig
@@ -8,13 +8,11 @@
- {#
- {{ dump() }}
- #}
-
{% endblock %}
-{% block block_post_menu %}{% endblock %}
+{% block block_post_menu %}
+
+{% endblock %}
{% block js %}
{{ encore_entry_script_tags('vue_visgraph') }}
From b7466c7e85291b449e164abd9d48628f916f8f92 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Tue, 26 Oct 2021 14:49:12 +0200
Subject: [PATCH 014/119] GET for relationship fixed: associated relation
displayed
---
.../Controller/RelationshipApiController.php | 7 +---
.../Relationships/RelationshipRepository.php | 4 +-
.../Normalizer/RelationshipNormalizer.php | 37 +++++++++++++++++++
3 files changed, 41 insertions(+), 7 deletions(-)
create mode 100644 src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 0327d335e..921f2d151 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -23,12 +23,6 @@ class RelationshipApiController extends ApiController
$this->repository = $repository;
}
- public function createEntity(string $action, Request $request): object
- {
- $relationship = parent::createEntity($action, $request);
- return $relationship;
- }
-
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
* name="chill_relation_relationship_by_person")
@@ -39,6 +33,7 @@ class RelationshipApiController extends ApiController
{
//TODO: add permissions? (voter?)
$relationships = $this->repository->findByPerson($person);
+ dump($relationships[0]->getRelation());
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
index ad251b4ff..00546e424 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
@@ -27,7 +27,9 @@ class RelationshipRepository extends ServiceEntityRepository
{
// return all relationships of which person is part? or only where person is the fromPerson?
return $this->createQueryBuilder('r')
- ->andWhere('r.fromPerson = :val')
+ ->select('r, t') // entity Relationship
+ ->join('r.relation', 't')
+ ->where('r.fromPerson = :val')
->orWhere('r.toPerson = :val')
->setParameter('val', $personId)
->getQuery()
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
new file mode 100644
index 000000000..6036a18e9
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
@@ -0,0 +1,37 @@
+ 'relationship',
+ 'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
+ 'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
+ 'relation' => $this->normalizer->normalize($relationship->getRelation()),
+ 'reverse' => $relationship->getReverse()
+ ];
+ }
+
+ public function supportsNormalization($data, ?string $format = null)
+ {
+ return $data instanceof Relationship;
+ }
+
+}
\ No newline at end of file
From 9609fcb5d3974c72c8d94b1ad71cb6a18f536af2 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 14:53:42 +0200
Subject: [PATCH 015/119] visgraph: edit interface fr translations
---
.../Resources/public/vuejs/VisGraph/i18n.js | 32 +++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index f7af08240..9fa8eca26 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -5,9 +5,37 @@ const visMessages = {
visgraph: {
'Course': 'Parcours',
'Household': 'Ménage',
- }
+ },
+ edit: 'Éditer',
+ del: 'Supprimer',
+ back: 'Revenir en arrière',
+ addNode: 'Ajouter un noeuds',
+ addEdge: 'Ajouter un lien',
+ editNode: 'Éditer un noeuds',
+ editEdge: 'Éditer un lien',
+ addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
+ edgeDescription: 'Cliquez sur un nœud et faites glisser le lien vers un autre nœud pour les connecter.',
+ editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
+ createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
+ deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
+ editClusterError: 'Les clusters ne peuvent pas être modifiés.'
},
- en: {}
+ en: {
+ edit: 'Edit',
+ del: 'Delete selected',
+ back: 'Back',
+ addNode: 'Add Node',
+ addEdge: 'Add Link',
+ editNode: 'Edit Switch',
+ editEdge: 'Edit Link',
+ addDescription: 'Click in an empty space to place a new node.',
+ edgeDescription: 'Click on a node and drag the link to another node to connect them.',
+ editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
+ createEdgeError: 'Cannot link edges to a cluster.',
+ deleteClusterError: 'Clusters cannot be deleted.',
+ editClusterError: 'Clusters cannot be edited.'
+
+ }
}
//Object.assign(visMessages.fr, personMessages.fr);
From a20eeb6a34a10b304e50b47881fdfecd40f984fa Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 15:15:44 +0200
Subject: [PATCH 016/119] vue_visgraph: add a mechanism to force update
component
cfr. https://medium.com/emblatech/ways-to-force-vue-to-re-render-a-component-df866fbacf47
---
.../Resources/public/vuejs/VisGraph/App.vue | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 5979a2c71..d0e78bfaa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -66,6 +66,11 @@ export default {
// Instanciate vis objects in window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
+ },
+ forceUpdateComponent() {
+ console.log('forceUpdateComponent - method 3')
+ this.$forceUpdate()
+ this.refreshNetwork
}
}
/*
From 2a86fd12d7a0e0f2e97eebdede5541d5538991ac Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 26 Oct 2021 21:29:17 +0200
Subject: [PATCH 017/119] vue_visgraph: add checkbox legend to enable/disable
layers
---
.../Resources/public/vuejs/VisGraph/App.vue | 104 +++++++++++++-----
.../Resources/public/vuejs/VisGraph/store.js | 17 ++-
.../public/vuejs/VisGraph/vis-network.js | 10 +-
3 files changed, 97 insertions(+), 34 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index d0e78bfaa..cb9e07716 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -1,30 +1,28 @@
-
+
+Checked layers: {{ checkedLayers }}
+Unchecked layers: {{ excludedNodesIds }}
+
Rafraîchir
@@ -37,12 +35,19 @@ export default {
name: "App",
data() {
return {
- container: ''
+ container: '',
+ checkedLayers: [],
}
},
computed: {
- //not used ...mapState(['persons', 'households', 'courses', 'relationships', 'householdLoadingIds', 'courseLoadedIds']),
...mapGetters(['nodes', 'edges']),
+ ...mapState(['households', 'courses',
+ 'excludedNodesIds'
+ //'persons',
+ //'relationships',
+ //'householdLoadingIds',
+ //'courseLoadedIds',
+ ]),
visgraph_data() {
console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
@@ -51,10 +56,36 @@ export default {
edges: this.edges
}
},
+
refreshNetwork() { // B
console.log('--- refresh network')
window.network.setData(this.visgraph_data)
+ },
+
+ legendLayers() {
+ console.log('--- refresh legendLayers')
+ return [
+ ...this.households,
+ ...this.courses
+ ]
+ },
+
+ rebuildCheckedLayers() {
+ console.log('-*- rebuild checked Layers Arrays from graph nodes')
+ this.checkedLayers = []
+ let layersDisplayed = [
+ ...this.nodes.filter(n => n.id.startsWith('household')),
+ ...this.nodes.filter(n => n.id.startsWith('accompanying'))
+ ]
+ layersDisplayed.forEach(layer => {
+ this.checkedLayers.push(layer.id)
+ })
+ },
+
+ checkedLayers() { // required to refresh data checkedLayers
+ return this.checkedLayers
}
+
},
mounted() {
console.log('=== mounted: init graph')
@@ -63,7 +94,6 @@ export default {
methods: {
initGraph() {
this.container = document.getElementById('visgraph')
-
// Instanciate vis objects in window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
},
@@ -71,7 +101,29 @@ export default {
console.log('forceUpdateComponent - method 3')
this.$forceUpdate()
this.refreshNetwork
- }
+ },
+
+ toggleLayer(value) {
+ let id = value.target.value
+ console.log('--> toggleLayer', this.checkedLayers)
+ if (this.checkedLayers.includes(id)) {
+ this.removeLayer(id)
+ } else {
+ this.addLayer(id)
+ }
+ console.log('<-- toggleLayer after', this.checkedLayers)
+ },
+ addLayer(id) {
+ console.log('+ add Layer', id)
+ this.checkedLayers.push(id)
+ this.$store.commit('removeExcludedNode', id)
+ },
+ removeLayer(id) {
+ console.log('- remove Layer', id)
+ this.checkedLayers = this.checkedLayers.filter(i => i !== id)
+ this.$store.commit('addExcludedNode', id)
+ },
+
}
/*
TODO / TO CHECK / TO UNDERSTAND
@@ -98,14 +150,6 @@ div#visgraph {
}
div#visgraph-legend {
div.post-menu.legend {
- ul.legend-list {
- padding-left: 0;
- list-style-type: square;
- li::marker {
- color: red;
- background-color: cyan;
- }
- }
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index a06e6e55c..b4938ff4a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -12,7 +12,8 @@ const store = createStore({
courses: [],
relationships: [],
householdLoadingIds: [],
- courseLoadedIds: []
+ courseLoadedIds: [],
+ excludedNodesIds: []
},
getters: {
nodes(state) {
@@ -26,6 +27,10 @@ const store = createStore({
state.courses.forEach(c => {
nodes.push(c)
})
+ // except excluded nodes (unchecked layers)
+ state.excludedNodesIds.forEach(excluded => {
+ nodes = nodes.filter(n => n.id !== excluded)
+ })
return nodes
},
edges(state) {
@@ -56,7 +61,7 @@ const store = createStore({
state.courses.push(adapt2vis(course))
},
addRelationship(state, relationship) {
- console.log('+ addRelationship', relationship)
+ console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
state.relationships.push(relationship)
},
markHouseholdLoading(state, id) {
@@ -72,6 +77,12 @@ const store = createStore({
unmarkCourseLoaded(state, id) {
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
},
+ addExcludedNode(state, id) {
+ state.excludedNodesIds.push(id)
+ },
+ removeExcludedNode(state, id) {
+ state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
+ }
},
actions: {
/**
@@ -185,7 +196,7 @@ const store = createStore({
arrows: 'to',
color: 'orange',
font: { color: 'orange' },
- label: 'usager',
+ label: 'concerné',
//group: 'link_person_course',
})
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index cc0ef717a..bfdc74991 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -10,6 +10,14 @@ import { visMessages } from './i18n'
window.options = {
locale: 'fr',
locales: visMessages,
+ /*
+ configure: {
+ enabled: true,
+ filter: 'nodes,edges',
+ container: undefined,
+ showButton: true
+ },
+ */
manipulation: {
enabled: true,
initiallyActive: true,
@@ -63,7 +71,7 @@ window.options = {
physics: true,
font: {
color: '#b0b0b0',
- size: 9,
+ size: 9,
face: 'arial',
background: 'none',
strokeWidth: 2, // px
From 326fe5f50b27cc389cf6b1b16057a4d86cb0e81c Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 11:53:34 +0200
Subject: [PATCH 018/119] vue_visgraph: cleaning + i18n
---
.../Resources/public/vuejs/_js/i18n.js | 3 +-
.../Resources/public/vuejs/VisGraph/App.vue | 35 +++++++------------
.../Resources/public/vuejs/VisGraph/i18n.js | 5 +--
3 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
index c16b4c65d..4b998f98a 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js
@@ -45,7 +45,8 @@ const messages = {
redirect: {
person: "Quitter la page et ouvrir la fiche de l'usager",
thirdparty: "Quitter la page et voir le tiers",
- }
+ },
+ refresh: 'Rafraîchir'
},
nav: {
next: "Suivant",
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index cb9e07716..7be18e6eb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -3,7 +3,7 @@
-
-Checked layers: {{ checkedLayers }}
-Unchecked layers: {{ excludedNodesIds }}
-
- Rafraîchir
+ {{ $t('action.refresh') }}
@@ -41,8 +36,7 @@ export default {
},
computed: {
...mapGetters(['nodes', 'edges']),
- ...mapState(['households', 'courses',
- 'excludedNodesIds'
+ ...mapState(['households', 'courses', 'excludedNodesIds'
//'persons',
//'relationships',
//'householdLoadingIds',
@@ -57,13 +51,13 @@ export default {
}
},
- refreshNetwork() { // B
+ refreshNetwork() {
console.log('--- refresh network')
window.network.setData(this.visgraph_data)
},
legendLayers() {
- console.log('--- refresh legendLayers')
+ console.log('--- refresh legend')
return [
...this.households,
...this.courses
@@ -71,7 +65,7 @@ export default {
},
rebuildCheckedLayers() {
- console.log('-*- rebuild checked Layers Arrays from graph nodes')
+ console.log('--- rebuild checked Layers')
this.checkedLayers = []
let layersDisplayed = [
...this.nodes.filter(n => n.id.startsWith('household')),
@@ -94,36 +88,33 @@ export default {
methods: {
initGraph() {
this.container = document.getElementById('visgraph')
- // Instanciate vis objects in window variables, see vis-network.js
- window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A
+ // Instanciate vis objects in separate window variables, see vis-network.js
+ window.network = new vis.Network(this.container, this.visgraph_data, window.options )
},
forceUpdateComponent() {
- console.log('forceUpdateComponent - method 3')
+ console.log('forceUpdateComponent')
this.$forceUpdate()
this.refreshNetwork
},
-
toggleLayer(value) {
+ //console.log('toggleLayer')
let id = value.target.value
- console.log('--> toggleLayer', this.checkedLayers)
if (this.checkedLayers.includes(id)) {
this.removeLayer(id)
} else {
this.addLayer(id)
}
- console.log('<-- toggleLayer after', this.checkedLayers)
},
addLayer(id) {
- console.log('+ add Layer', id)
+ console.log('+ addLayer', id)
this.checkedLayers.push(id)
this.$store.commit('removeExcludedNode', id)
},
removeLayer(id) {
- console.log('- remove Layer', id)
+ console.log('- removeLayer', id)
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
this.$store.commit('addExcludedNode', id)
},
-
}
/*
TODO / TO CHECK / TO UNDERSTAND
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 9fa8eca26..db3f8998f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -3,8 +3,9 @@
const visMessages = {
fr: {
visgraph: {
- 'Course': 'Parcours',
- 'Household': 'Ménage',
+ Course: 'Parcours',
+ Household: 'Ménage',
+ Legend: 'Légende',
},
edit: 'Éditer',
del: 'Supprimer',
From c200e9909ebecfad9f7391ec59d7108109d07c33 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 15:16:13 +0200
Subject: [PATCH 019/119] i18n minor changes
---
.../Resources/public/vuejs/VisGraph/i18n.js | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index db3f8998f..077c3c7f6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -1,11 +1,9 @@
-//import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
-
const visMessages = {
fr: {
visgraph: {
Course: 'Parcours',
Household: 'Ménage',
- Legend: 'Légende',
+ Legend: 'Calques',
},
edit: 'Éditer',
del: 'Supprimer',
@@ -39,8 +37,6 @@ const visMessages = {
}
}
-//Object.assign(visMessages.fr, personMessages.fr);
-
export {
visMessages
}
From a3b203c30629c18ebb0de9e2d79f4b5dc0643ae5 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:28:13 +0200
Subject: [PATCH 020/119] fix backend error with AccompanyingCourse endpoints
---
.../Controller/RelationshipApiController.php | 6 +++---
.../ChillPersonBundle/config/services/controller.yaml | 5 +----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 921f2d151..765d13d25 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -26,15 +26,15 @@ class RelationshipApiController extends ApiController
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
* name="chill_relation_relationship_by_person")
- *
+ *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getRelationshipsByPerson(Person $person)
{
//TODO: add permissions? (voter?)
$relationships = $this->repository->findByPerson($person);
- dump($relationships[0]->getRelation());
+ //dump($relationships[0]->getRelation());
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
index cb7ebd76c..45a656e89 100644
--- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml
@@ -41,10 +41,7 @@ services:
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
- arguments:
- $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
- $registry: '@Symfony\Component\Workflow\Registry'
+ autowire: true
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonApiController:
From 7ad0e2f2c803819db97d69928affc1c720e2d54d Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:29:16 +0200
Subject: [PATCH 021/119] rename fetch api method
---
.../Resources/public/vuejs/VisGraph/api.js | 10 +++++-----
.../Resources/public/vuejs/VisGraph/store.js | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 957e01fbc..ee288dcc0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -89,14 +89,14 @@ const getCoursesByPerson = (person) => {
}
/**
- * @function getRelationship
+ * @function getRelationshipByPerson
* @param person
* @returns {Promise}
*/
-const getRelationship = (person) => {
- //console.log('getRelationship', person.id)
+const getRelationshipByPerson = (person) => {
+ //console.log('getRelationshipByPerson', person.id)
return getFetch(
- `/api/1.0/relations/relationship/by-person/${person.id}.json`)
+ `/api/1.0/relations/relationship/by-person/${person._id}.json`)
}
/**
@@ -120,6 +120,6 @@ const postRelationship = (person) => {
export {
getHouseholdByPerson,
getCoursesByPerson,
- getRelationship,
+ getRelationshipByPerson,
postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index b4938ff4a..25d044afb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,5 +1,5 @@
import { createStore } from 'vuex'
-import { getHouseholdByPerson, getCoursesByPerson, getRelationship } from './api'
+import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
import { adapt2vis } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -208,9 +208,9 @@ const store = createStore({
*/
fetchRelationship({ commit, getters }, person) {
console.log('fetchRelationship', person)
- getRelationship(person)
+ getRelationshipByPerson(person)
.then(relationship => new Promise(resolve => {
- console.log('getRelationship', relationship)
+ console.log('getRelationshipByPerson', relationship)
commit('addRelationship', relationship)
resolve()
}))
From 8ff581d5facce919fa108beecd4221404d1bfe15 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 16:29:54 +0200
Subject: [PATCH 022/119] vue_visgraph: add links array state in store
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 7be18e6eb..916fb05ef 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -38,6 +38,7 @@ export default {
...mapGetters(['nodes', 'edges']),
...mapState(['households', 'courses', 'excludedNodesIds'
//'persons',
+ //'links,
//'relationships',
//'householdLoadingIds',
//'courseLoadedIds',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 25d044afb..310315946 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -11,6 +11,7 @@ const store = createStore({
households: [],
courses: [],
relationships: [],
+ links: [],
householdLoadingIds: [],
courseLoadedIds: [],
excludedNodesIds: []
@@ -35,6 +36,9 @@ const store = createStore({
},
edges(state) {
let edges = []
+ state.links.forEach(l => {
+ edges.push(l)
+ })
state.relationships.forEach(r => {
edges.push(r)
})
@@ -60,6 +64,10 @@ const store = createStore({
console.log('+ addCourse', course.id)
state.courses.push(adapt2vis(course))
},
+ addLink(state, link) {
+ console.log('+ addLink from', link.from, 'to', link.to)
+ state.links.push(link)
+ },
addRelationship(state, relationship) {
console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
state.relationships.push(relationship)
@@ -134,7 +142,7 @@ const store = createStore({
const members = household.members.filter(v => household.current_members_id.includes(v.id))
members.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
- commit('addRelationship', {
+ commit('addLink', {
from: `${m.person.type}_${m.person.id}`,
to: `household_${m.person.current_household_id}`,
id: `p${m.person.id}-h${m.person.current_household_id}`,
@@ -189,7 +197,7 @@ const store = createStore({
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
currentParticipations.forEach(p => {
- commit('addRelationship', {
+ commit('addLink', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
id: `p${p.person.id}-c`+ course.id.split('_')[2],
@@ -202,7 +210,6 @@ const store = createStore({
})
},
-
/**
* Fetch Relationship
*/
From 1d1a54f653f7b58a72534ca8cf3723229c0e9e5c Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 17:24:23 +0200
Subject: [PATCH 023/119] vue_visgraph: improve household links (edges)
---
.../Resources/public/vuejs/VisGraph/i18n.js | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 15 +++--
.../public/vuejs/VisGraph/vis-network.js | 59 +++++++++++++++----
3 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 077c3c7f6..c4ad74907 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -3,6 +3,7 @@ const visMessages = {
visgraph: {
Course: 'Parcours',
Household: 'Ménage',
+ Holder: 'Titulaire',
Legend: 'Calques',
},
edit: 'Éditer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 310315946..0d0ff4442 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
-import { adapt2vis } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -139,8 +139,8 @@ const store = createStore({
* @param Household household
*/
addLinkFromPersonsToHousehold({ commit }, household) {
- const members = household.members.filter(v => household.current_members_id.includes(v.id))
- members.forEach(m => {
+ const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
+ currentMembers.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
commit('addLink', {
from: `${m.person.type}_${m.person.id}`,
@@ -148,9 +148,9 @@ const store = createStore({
id: `p${m.person.id}-h${m.person.current_household_id}`,
arrows: 'from',
color: 'pink',
- font: { color: 'pink' },
- label: 'enfant',
- ////group: 'link_person_household',
+ font: { color: '#D04A60' },
+ label: getHouseholdLabel(m),
+ width: getHouseholdWidth(m),
})
})
@@ -203,9 +203,8 @@ const store = createStore({
id: `p${p.person.id}-c`+ course.id.split('_')[2],
arrows: 'to',
color: 'orange',
- font: { color: 'orange' },
+ font: { color: 'darkorange' },
label: 'concerné',
- //group: 'link_person_course',
})
})
},
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index bfdc74991..8774501a0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,12 +1,14 @@
import { visMessages } from './i18n'
-/*
+/**
* Vis-network initial data/configuration script
* Notes:
* Use window.network and window.options to avoid conflict between vue and vis
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
+window.network = {};
+
window.options = {
locale: 'fr',
locales: visMessages,
@@ -14,7 +16,7 @@ window.options = {
configure: {
enabled: true,
filter: 'nodes,edges',
- container: undefined,
+ //container: undefined,
showButton: true
},
*/
@@ -46,7 +48,8 @@ window.options = {
console.log('deleteNode', edgeData)
callback(edgeData);
},
- controlNodeStyle: { /*
+ controlNodeStyle: {
+ /*
shape:'dot',
size: 6,
color: {
@@ -112,18 +115,16 @@ window.options = {
shape: 'triangle',
*/
color: 'orange',
-
},
}
};
-window.network = {};
-
-/*
-* Adapt entity to graph (id, label)
-* we rename id in _id
-* and add properties needed by vis
-*/
+/**
+ * Adapt entity to graph (id, label)
+ * rename id in _id and add properties needed by vis
+ * @param entity
+ * @returns entity
+ */
const adapt2vis = (entity) => {
entity.group = entity.type
switch (entity.type) {
@@ -146,6 +147,38 @@ const adapt2vis = (entity) => {
return entity
}
-export {
- adapt2vis
+/**
+ * Return member position in household
+ * @param member
+ * @returns string
+ */
+const getHouseholdLabel = (member) => {
+ let position = member.position.label.fr
+ let holder = member.holder ? ` (${visMessages.fr.visgraph.Holder})` : ''
+ return position + holder
+}
+
+/**
+ * Return edge width for member (depends of position in household)
+ * @param member
+ * @returns string
+ */
+const getHouseholdWidth = (member) => {
+ switch (member.position.ordering) {
+ case 1: //adult
+ if (member.holder) {
+ return 6
+ }
+ return 3
+ case 2: //children
+ case 3: //children out of household
+ return 1
+ }
+}
+
+
+export {
+ adapt2vis,
+ getHouseholdLabel,
+ getHouseholdWidth
}
From 6752a2f6d3279865bf0465591c54c2685d63f29f Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 27 Oct 2021 17:40:15 +0200
Subject: [PATCH 024/119] fixture created for Relation entity
---
.../DataFixtures/ORM/LoadRelations.php | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
new file mode 100644
index 000000000..bcd7df547
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
@@ -0,0 +1,45 @@
+ ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
+ ['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
+ ['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
+ ['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
+ ['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Frère']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
+ ['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
+ ];
+
+ foreach($relations as $value){
+ print "Creating a new relation type: relation" . $value['title']['fr'] . "reverse relation: " . $value['reverseTitle']['fr'] . "\n";
+ $relation = new Relation();
+ $relation->setTitle($value['title'])
+ ->setReverseTitle($value['reverseTitle']);
+ $manager->persist($relation);
+ }
+
+ $manager->flush();
+
+ }
+
+}
\ No newline at end of file
From 83e8b117db388e39f75716de1770ae1d9bd147dc Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Wed, 27 Oct 2021 18:10:35 +0200
Subject: [PATCH 025/119] start of Relationship fixture
---
.../ChillPersonBundle/DataFixtures/ORM/LoadRelations.php | 3 +++
.../ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php | 0
2 files changed, 3 insertions(+)
create mode 100644 src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
index bcd7df547..2b72052c6 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php
@@ -10,6 +10,8 @@ use Doctrine\Persistence\ObjectManager;
class LoadRelations extends Fixture implements FixtureGroupInterface
{
+ public const RELATIONS = 'relations';
+
public static function getGroups(): array
{
return ['person_relations'];
@@ -36,6 +38,7 @@ class LoadRelations extends Fixture implements FixtureGroupInterface
$relation->setTitle($value['title'])
->setReverseTitle($value['reverseTitle']);
$manager->persist($relation);
+ $this->addReference(self::RELATIONS, $relation);
}
$manager->flush();
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
new file mode 100644
index 000000000..e69de29bb
From 2cb1ad6afc3bcb2820d6815517aa09ecad197b8a Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 18:11:14 +0200
Subject: [PATCH 026/119] improve household position fixture
---
.../DataFixtures/ORM/LoadHouseholdPosition.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
index cf0bf3de1..23bd499f8 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php
@@ -10,8 +10,8 @@ class LoadHouseholdPosition extends Fixture
{
const POSITIONS_DATA = [
["Adulte", true, true, 1.0, self::ADULT ],
- ["Enfants", true, false, 2.0, self::CHILD ],
- ["Enfants hors ménage", false, false, 3.0, self::CHILD_OUT ]
+ ["Enfant", true, false, 2.0, self::CHILD ],
+ ["Enfant hors ménage", false, false, 3.0, self::CHILD_OUT ]
];
const ADULT = "position_adulte";
From f834bb3bd613342aeff825852abcd947f51e0d2e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 19:54:28 +0200
Subject: [PATCH 027/119] backend normalizer: add id to relationship endpoint
---
.../Serializer/Normalizer/RelationshipNormalizer.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
index 6036a18e9..e410dd90b 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
@@ -22,6 +22,7 @@ class RelationshipNormalizer implements NormalizerInterface, NormalizerAwareInte
{
return [
'type' => 'relationship',
+ 'id' => $this->normalizer->normalize($relationship->getId()),
'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
'relation' => $this->normalizer->normalize($relationship->getRelation()),
From 92c1bf15cc6194fad153faa1470bba5711f85973 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Wed, 27 Oct 2021 19:55:24 +0200
Subject: [PATCH 028/119] vue_visgraph: add relationship links with relations
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/api.js | 8 +-
.../Resources/public/vuejs/VisGraph/i18n.js | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 100 ++++++++++++++----
.../public/vuejs/VisGraph/vis-network.js | 17 ++-
5 files changed, 104 insertions(+), 23 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 916fb05ef..1804460f7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -42,6 +42,7 @@ export default {
//'relationships',
//'householdLoadingIds',
//'courseLoadedIds',
+ //'relationshipLoadedIds',
]),
visgraph_data() {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index ee288dcc0..f595daa34 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -89,12 +89,12 @@ const getCoursesByPerson = (person) => {
}
/**
- * @function getRelationshipByPerson
+ * @function getRelationshipsByPerson
* @param person
* @returns {Promise}
*/
-const getRelationshipByPerson = (person) => {
- //console.log('getRelationshipByPerson', person.id)
+const getRelationshipsByPerson = (person) => {
+ //console.log('getRelationshipsByPerson', person.id)
return getFetch(
`/api/1.0/relations/relationship/by-person/${person._id}.json`)
}
@@ -120,6 +120,6 @@ const postRelationship = (person) => {
export {
getHouseholdByPerson,
getCoursesByPerson,
- getRelationshipByPerson,
+ getRelationshipsByPerson,
postRelationship
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index c4ad74907..9ca273f72 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -5,6 +5,7 @@ const visMessages = {
Household: 'Ménage',
Holder: 'Titulaire',
Legend: 'Calques',
+ concerned: 'concerné',
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 0d0ff4442..da13d9bd3 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,7 @@
import { createStore } from 'vuex'
-import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth } from './vis-network'
+import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel } from './vis-network'
+import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -14,6 +15,7 @@ const store = createStore({
links: [],
householdLoadingIds: [],
courseLoadedIds: [],
+ relationshipLoadedIds: [],
excludedNodesIds: []
},
getters: {
@@ -39,9 +41,9 @@ const store = createStore({
state.links.forEach(l => {
edges.push(l)
})
- state.relationships.forEach(r => {
- edges.push(r)
- })
+ //state.relationships.forEach(r => {
+ // edges.push(r)
+ //})
return edges
},
isHouseholdLoading: (state) => (household_id) => {
@@ -50,6 +52,9 @@ const store = createStore({
isCourseLoaded: (state) => (course_id) => {
return state.courseLoadedIds.includes(course_id)
},
+ isRelationshipLoaded: (state) => (relationship_id) => {
+ return state.relationshipLoadedIds.includes(relationship_id)
+ }
},
mutations: {
addPerson(state, person) {
@@ -64,14 +69,14 @@ const store = createStore({
console.log('+ addCourse', course.id)
state.courses.push(adapt2vis(course))
},
+ addRelationship(state, relationship) {
+ console.log('+ addRelationship', relationship.id)
+ state.relationships.push(adapt2vis(relationship))
+ },
addLink(state, link) {
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
- addRelationship(state, relationship) {
- console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
- state.relationships.push(relationship)
- },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
@@ -85,6 +90,12 @@ const store = createStore({
unmarkCourseLoaded(state, id) {
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
},
+ markRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds.push(id)
+ },
+ unmarkRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
+ },
addExcludedNode(state, id) {
state.excludedNodesIds.push(id)
},
@@ -109,7 +120,7 @@ const store = createStore({
fetchInfoForPerson({ dispatch }, person) {
dispatch('fetchHouseholdForPerson', person)
dispatch('fetchCoursesByPerson', person)
- //dispatch('fetchRelationship', person)
+ dispatch('fetchRelationshipByPerson', person)
},
/**
@@ -204,23 +215,76 @@ const store = createStore({
arrows: 'to',
color: 'orange',
font: { color: 'darkorange' },
- label: 'concerné',
+ label: visMessages.fr.visgraph.concerned,
})
})
},
/**
- * Fetch Relationship
+ * 8) Fetch Relationship
+ * @param Person person
*/
- fetchRelationship({ commit, getters }, person) {
- console.log('fetchRelationship', person)
- getRelationshipByPerson(person)
- .then(relationship => new Promise(resolve => {
- console.log('getRelationshipByPerson', relationship)
- commit('addRelationship', relationship)
+ fetchRelationshipByPerson({ dispatch }, person) {
+ //console.log('fetchRelationshipByPerson', person)
+ getRelationshipsByPerson(person)
+ .then(relationships => new Promise(resolve => {
+ console.log('fetch relationships', relationships.length)
+ dispatch('addRelationship', relationships)
resolve()
}))
+ },
+
+ /**
+ * 9) Add each distinct relationship
+ * @param array relationships
+ */
+ addRelationship({ commit, getters, dispatch }, relationships) {
+ relationships.forEach(relationship => {
+ console.log(' isRelationshipLoaded ?', getters.isRelationshipLoaded(relationship.id))
+ if (! getters.isRelationshipLoaded(relationship.id)) {
+ //console.log('relationship', relationship.id)
+ commit('markRelationshipLoaded', relationship.id)
+ commit('addRelationship', relationship)
+ dispatch('addLinkFromRelationship', relationship)
+ }
+ })
+ },
+
+ /**
+ * 10) Add an edge for each relationship (person -> person)
+ * @param Relationship relationship
+ */
+ addLinkFromRelationship({ commit }, r) {
+
+ console.log(
+ '-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id,
+ //'reverse', r.reverse,
+ //'relation', r.relation.title.fr, r.relation.reverseTitle.fr
+ )
+
+ commit('addLink', {
+ from: `person_${r.fromPerson.id}`,
+ to: `person_${r.toPerson.id}`,
+ id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
+ arrows: 'from',
+ color: 'lightblue', dashes: true,
+ font: { color: 'lightblue' },
+ label: getRelationshipLabel(r, false),
+ })
+
+ /*
+ // add reverse relation
+ commit('addLink', {
+ from: `person_${r.toPerson.id}`,
+ to: `person_${r.fromPerson.id}`,
+ id: 'rr' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
+ arrows: 'from',
+ color: 'lightblue', dashes: true,
+ font: { color: 'lightblue' },
+ label: getRelationshipLabel(r, true),
+ })
+ */
},
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 8774501a0..3ed6a7e7a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -143,6 +143,12 @@ const adapt2vis = (entity) => {
entity.label = `${visMessages.fr.visgraph.Course} n° ${entity.id}`
entity.id = `accompanying_period_${entity.id}`
break
+ case 'relationship':
+ entity._id = entity.id
+ entity.id = `relationship_${entity.id}`
+
+ // sera utilisé pour les links :
+ //entity.id = 'r' + entity._id + '_p' + entity.fromPerson.id + '_p' + entity.toPerson.id
}
return entity
}
@@ -176,9 +182,18 @@ const getHouseholdWidth = (member) => {
}
}
+/**
+ * Return label edge
+ * @param relationship
+ * @returns string
+ */
+const getRelationshipLabel = (relationship, reverse) => {
+ return (!reverse) ? relationship.relation.title.fr : relationship.relation.reverseTitle.fr
+}
export {
adapt2vis,
getHouseholdLabel,
- getHouseholdWidth
+ getHouseholdWidth,
+ getRelationshipLabel
}
From 317ba0a095ab9c4ce86b21b99de0de4519311ab7 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 28 Oct 2021 12:11:51 +0200
Subject: [PATCH 029/119] vue_visgraph: store missing persons from courses,
household and relationship
---
.../Resources/public/vuejs/VisGraph/App.vue | 10 +--
.../Resources/public/vuejs/VisGraph/store.js | 83 +++++++++++--------
.../public/vuejs/VisGraph/vis-network.js | 8 +-
3 files changed, 57 insertions(+), 44 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 1804460f7..74409c7f1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -36,13 +36,9 @@ export default {
},
computed: {
...mapGetters(['nodes', 'edges']),
- ...mapState(['households', 'courses', 'excludedNodesIds'
- //'persons',
- //'links,
- //'relationships',
- //'householdLoadingIds',
- //'courseLoadedIds',
- //'relationshipLoadedIds',
+ ...mapState(['households', 'courses', 'excludedNodesIds',
+ // not used
+ 'persons', 'links', 'relationships', 'personLoadedIds', 'householdLoadingIds', 'courseLoadedIds', 'relationshipLoadedIds',
]),
visgraph_data() {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index da13d9bd3..c18323684 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -13,6 +13,7 @@ const store = createStore({
courses: [],
relationships: [],
links: [],
+ personLoadedIds: [],
householdLoadingIds: [],
courseLoadedIds: [],
relationshipLoadedIds: [],
@@ -41,9 +42,6 @@ const store = createStore({
state.links.forEach(l => {
edges.push(l)
})
- //state.relationships.forEach(r => {
- // edges.push(r)
- //})
return edges
},
isHouseholdLoading: (state) => (household_id) => {
@@ -54,6 +52,9 @@ const store = createStore({
},
isRelationshipLoaded: (state) => (relationship_id) => {
return state.relationshipLoadedIds.includes(relationship_id)
+ },
+ isPersonLoaded: (state) => (person_id) => {
+ return state.personLoadedIds.includes(person_id)
}
},
mutations: {
@@ -77,6 +78,12 @@ const store = createStore({
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
+ markPersonLoaded(state, id) {
+ state.personLoadedIds.push(id)
+ },
+ unmarkPersonLoaded(state, id) {
+ state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
+ },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
@@ -108,7 +115,9 @@ const store = createStore({
* 1) Add a person in state
* @param Person person
*/
+
addPerson({ commit, dispatch }, person) {
+ commit('markPersonLoaded', person.id)
commit('addPerson', person)
dispatch('fetchInfoForPerson', person)
},
@@ -149,7 +158,7 @@ const store = createStore({
* 4) Add an edge for each household member (household -> person)
* @param Household household
*/
- addLinkFromPersonsToHousehold({ commit }, household) {
+ addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
currentMembers.forEach(m => {
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
@@ -163,30 +172,32 @@ const store = createStore({
label: getHouseholdLabel(m),
width: getHouseholdWidth(m),
})
+ if (!getters.isPersonLoaded(m.person.id)) {
+ console.log(' person is not loaded', m.person.id)
+ dispatch('addMissingPerson', m.person)
+ }
})
-
},
/**
* 5) Fetch AccompanyingCourses for the person
* @param Person person
*/
- fetchCoursesByPerson({ dispatch }, person) {
+ fetchCoursesByPerson({ commit, dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
getCoursesByPerson(person)
.then(courses => new Promise(resolve => {
console.log('fetch courses', courses.length)
- dispatch('addCourse', courses)
+ dispatch('addCourses', courses)
resolve()
}))
-
},
/**
* 6) Add each distinct course
* @param array courses
*/
- addCourse({ commit, getters, dispatch }, courses) {
+ addCourses({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
let currentCourses = courses.filter(c => c.closingDate === null)
currentCourses.forEach(course => {
@@ -204,7 +215,7 @@ const store = createStore({
* 7) Add an edge for each course participation (course <- person)
* @param AccompanyingCourse course
*/
- addLinkFromPersonsToCourse({ commit }, course) {
+ addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
console.log(' participations', currentParticipations.length)
currentParticipations.forEach(p => {
@@ -217,6 +228,10 @@ const store = createStore({
font: { color: 'darkorange' },
label: visMessages.fr.visgraph.concerned,
})
+ if (!getters.isPersonLoaded(p.person.id)) {
+ console.log(' person is not loaded', p.person.id)
+ dispatch('addMissingPerson', p.person)
+ }
})
},
@@ -229,7 +244,7 @@ const store = createStore({
getRelationshipsByPerson(person)
.then(relationships => new Promise(resolve => {
console.log('fetch relationships', relationships.length)
- dispatch('addRelationship', relationships)
+ dispatch('addRelationships', relationships)
resolve()
}))
},
@@ -239,7 +254,7 @@ const store = createStore({
* 9) Add each distinct relationship
* @param array relationships
*/
- addRelationship({ commit, getters, dispatch }, relationships) {
+ addRelationships({ commit, getters, dispatch }, relationships) {
relationships.forEach(relationship => {
console.log(' isRelationshipLoaded ?', getters.isRelationshipLoaded(relationship.id))
if (! getters.isRelationshipLoaded(relationship.id)) {
@@ -253,40 +268,36 @@ const store = createStore({
/**
* 10) Add an edge for each relationship (person -> person)
- * @param Relationship relationship
+ * @param Relationship r
*/
- addLinkFromRelationship({ commit }, r) {
-
- console.log(
- '-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id,
- //'reverse', r.reverse,
- //'relation', r.relation.title.fr, r.relation.reverseTitle.fr
- )
-
+ addLinkFromRelationship({ commit, getters, dispatch }, r) {
+ //console.log('-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id)
commit('addLink', {
from: `person_${r.fromPerson.id}`,
to: `person_${r.toPerson.id}`,
id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
- arrows: 'from',
+ arrows: 'to',
color: 'lightblue', dashes: true,
- font: { color: 'lightblue' },
+ font: { color: '#33839d' },
label: getRelationshipLabel(r, false),
})
-
- /*
- // add reverse relation
- commit('addLink', {
- from: `person_${r.toPerson.id}`,
- to: `person_${r.fromPerson.id}`,
- id: 'rr' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
- arrows: 'from',
- color: 'lightblue', dashes: true,
- font: { color: 'lightblue' },
- label: getRelationshipLabel(r, true),
- })
- */
+ for (let person of [r.fromPerson, r.toPerson]) {
+ if (!getters.isPersonLoaded(person.id)) {
+ console.log(' person is not loaded', person.id)
+ dispatch('addMissingPerson', person)
+ }
+ }
},
+ /**
+ * Fetch missing person
+ * @param Person person
+ */
+ addMissingPerson({ commit, getters, dispatch }, person) {
+ //console.log('addMissingPerson', person)
+ commit('markPersonLoaded', person.id)
+ commit('addPerson', person)
+ },
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 3ed6a7e7a..f1e9ab05e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -167,7 +167,11 @@ const getHouseholdLabel = (member) => {
/**
* Return edge width for member (depends of position in household)
* @param member
- * @returns string
+ * @returns integer (width)
+ *
+ * TODO
+ * to use: holder, shareHousehold
+ * not use: ordering, position (-> null)
*/
const getHouseholdWidth = (member) => {
switch (member.position.ordering) {
@@ -179,6 +183,8 @@ const getHouseholdWidth = (member) => {
case 2: //children
case 3: //children out of household
return 1
+ default:
+ throw 'Ordering not supported'
}
}
From 998295dc5fb5004ca80e13581cefc10b87d49735 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Thu, 28 Oct 2021 15:47:40 +0200
Subject: [PATCH 030/119] vue_visgraph improve (physics, corrections)
---
.../Resources/public/vuejs/VisGraph/App.vue | 1 +
.../Resources/public/vuejs/VisGraph/store.js | 2 +-
.../public/vuejs/VisGraph/vis-network.js | 79 +++++++++++++++++--
3 files changed, 75 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 74409c7f1..fd45dd750 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -96,6 +96,7 @@ export default {
},
toggleLayer(value) {
//console.log('toggleLayer')
+ this.forceUpdateComponent()
let id = value.target.value
if (this.checkedLayers.includes(id)) {
this.removeLayer(id)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index c18323684..394fd55e6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -223,7 +223,7 @@ const store = createStore({
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
id: `p${p.person.id}-c`+ course.id.split('_')[2],
- arrows: 'to',
+ arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
label: visMessages.fr.visgraph.concerned,
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f1e9ab05e..eeddb7da4 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -20,6 +20,55 @@ window.options = {
showButton: true
},
*/
+ physics:{
+ enabled: true,
+ barnesHut: {
+ theta: 0.5,
+ gravitationalConstant: -2000,
+ centralGravity: 0.1, //// 0.3
+ springLength: 200, //// 95
+ springConstant: 0.04,
+ damping: 0.09,
+ avoidOverlap: 0
+ },
+ forceAtlas2Based: {
+ theta: 0.5,
+ gravitationalConstant: -50,
+ centralGravity: 0.01,
+ springConstant: 0.08,
+ springLength: 100,
+ damping: 0.4,
+ avoidOverlap: 0
+ },
+ repulsion: {
+ centralGravity: 0.2,
+ springLength: 200,
+ springConstant: 0.05,
+ nodeDistance: 100,
+ damping: 0.09
+ },
+ hierarchicalRepulsion: {
+ centralGravity: 0.0,
+ springLength: 100,
+ springConstant: 0.01,
+ nodeDistance: 120,
+ damping: 0.09,
+ avoidOverlap: 0
+ },
+ maxVelocity: 50,
+ minVelocity: 0.1,
+ solver: 'barnesHut',
+ stabilization: {
+ enabled: true,
+ iterations: 1000,
+ updateInterval: 100,
+ onlyDynamicEdges: false,
+ fit: true
+ },
+ timestep: 0.5,
+ adaptiveTimestep: true,
+ wind: { x: 0, y: 0 }
+ },
manipulation: {
enabled: true,
initiallyActive: true,
@@ -66,12 +115,12 @@ window.options = {
}
},
nodes: {
- physics: true,
+ //physics: true,
borderWidth: 1,
borderWidthSelected: 3,
},
edges: {
- physics: true,
+ //physics: true,
font: {
color: '#b0b0b0',
size: 9,
@@ -130,7 +179,7 @@ const adapt2vis = (entity) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = entity.text
+ entity.label = `${entity.text}\n` + getGender(entity.gender_numeric) +' - '+ getAge(entity.birthdate)
entity.id = `person_${entity.id}`
break
case 'household':
@@ -146,13 +195,31 @@ const adapt2vis = (entity) => {
case 'relationship':
entity._id = entity.id
entity.id = `relationship_${entity.id}`
-
- // sera utilisé pour les links :
- //entity.id = 'r' + entity._id + '_p' + entity.fromPerson.id + '_p' + entity.toPerson.id
}
return entity
}
+const getGender = (gender) => {
+ switch (gender) {
+ case 0:
+ return 'N'
+ case 1:
+ return 'M'
+ case 2:
+ return 'F'
+ default:
+ throw 'gender undefined'
+ }
+}
+const getAge = (birthdate) => {
+ if (null === birthdate) {
+ return null
+ }
+ const birthday = new Date(birthdate.datetime)
+ const now = new Date()
+ return (now.getFullYear() - birthday.getFullYear()) + ' ans'
+}
+
/**
* Return member position in household
* @param member
From 3a7af94058e0bd6d9c7c42d0651a9656abd1b5a0 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 09:29:27 +0200
Subject: [PATCH 031/119] GET and POST both working.
---
.../AccompanyingCourseApiController.php | 2 -
.../DataFixtures/ORM/LoadRelationships.php | 22 +++++++
.../ChillPersonExtension.php | 4 --
.../Entity/Relationships/Relation.php | 16 +++--
.../Entity/Relationships/Relationship.php | 58 +++++++++++--------
5 files changed, 68 insertions(+), 34 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 891a0f461..132dc1172 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -32,8 +32,6 @@ class AccompanyingCourseApiController extends ApiController
private Registry $registry;
- private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
-
public function __construct(
EventDispatcherInterface $eventDispatcher,
ValidatorInterface $validator,
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
index e69de29bb..cfabde912 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php
@@ -0,0 +1,22 @@
+ [
'_entity' => [
'methods' => [
- Request::METHOD_GET => true,
- Request::METHOD_HEAD => true,
Request::METHOD_POST => true,
Request::METHOD_PATCH => true
],
'roles' => [
- Request::METHOD_GET => 'ROLE_USER',
- Request::METHOD_HEAD => 'ROLE_USER',
Request::METHOD_POST => 'ROLE_USER',
Request::METHOD_PATCH => 'ROLE_USER'
]
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
index 7cd000dd5..a0fefc877 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
@@ -3,10 +3,16 @@
namespace Chill\PersonBundle\Entity\Relationships;
use Doctrine\ORM\Mapping as ORM;
+use Doctrine\ORM\Mapping\DiscriminatorColumn;
+use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
+use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity()
* @ORM\Table(name="chill_person_relations")
+ * @DiscriminatorMap(typeProperty="type", mapping={
+ * "relation"=Relation::class
+ * })
*/
class Relation
{
@@ -15,17 +21,19 @@ class Relation
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
- private $id;
+ private ?int $id = null;
/**
* @ORM\Column(type="json", nullable=true)
+ * @Serializer\Groups({"read"})
*/
- private $title = [];
+ private array $title = [];
/**
* @ORM\Column(type="json", nullable=true)
+ * @Serializer\Groups({"read"})
*/
- private $reverseTitle = [];
+ private array $reverseTitle = [];
public function getId(): ?int
{
@@ -55,4 +63,4 @@ class Relation
return $this;
}
-}
+}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
index e748f9797..54be21140 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php
@@ -2,50 +2,60 @@
namespace Chill\PersonBundle\Entity\Relationships;
+use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
+use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Relationships\Relation;
+use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
-use Symfony\Component\Serializer\Annotation\Groups;
+use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
+use Doctrine\ORM\Mapping\DiscriminatorColumn;
+use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity()
* @ORM\Table(name="chill_person_relationships")
+ * @DiscriminatorColumn(name="relation_id", type="integer")
+ * @DiscriminatorMap(typeProperty="type", mapping={
+ * "relationship"=Relationship::class
+ * })
+ *
*/
-class Relationship
+class Relationship implements TrackCreationInterface, TrackUpdateInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
- * @Groups({"read"})
+ * @Serializer\Groups({"read"})
*/
- private $id;
+ private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $fromPerson;
+ private ?Person $fromPerson = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $toPerson;
+ private ?Person $toPerson = null;
/**
* @ORM\ManyToOne(targetEntity=Relation::class)
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
- * @Assert\NotBlank()
- * @Groups({"read", "write"})
+ * @Assert\NotNull()
+ * @Serializer\Groups({"read", "write"})
*/
- private $relation;
+ private ?Relation $relation = null;
/**
* @ORM\Column(type="boolean")
@@ -53,30 +63,30 @@ class Relationship
* type="bool",
* message="This must be of type boolean"
* )
- * @Groups({"read"})
+ * @Serializer\Groups({"read", "write"})
*/
- private $reverse;
+ private bool $reverse;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
- private $createdBy;
+ private ?User $createdBy = null;
/**
* @ORM\Column(type="datetime_immutable")
*/
- private $createdAt;
+ private ?DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
- private $updatedBy;
+ private ?User $updatedBy = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
- private $updatedAt;
+ private ?DateTimeImmutable $updatedAt = null;
public function getId(): ?int
@@ -125,9 +135,9 @@ class Relationship
return $this->createdBy;
}
- public function setCreatedBy(?User $createdBy): self
+ public function setCreatedBy(?User $user): self
{
- $this->createdBy = $createdBy;
+ $this->createdBy = $user;
return $this;
}
@@ -137,7 +147,7 @@ class Relationship
return $this->createdAt;
}
- public function setCreatedAt(\DateTimeImmutable $createdAt): self
+ public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -161,7 +171,7 @@ class Relationship
return $this->updatedAt;
}
- public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
+ public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
@@ -179,4 +189,4 @@ class Relationship
return $this;
}
-}
+}
\ No newline at end of file
From 76d6a9b4dfe2943cf5ff3bf6301edeba7b18e187 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 10:01:14 +0200
Subject: [PATCH 032/119] vue_visgraph: makeFetch (api), add validation
exception
---
.../Resources/public/vuejs/VisGraph/api.js | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index f595daa34..5533bd6ff 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -20,7 +20,9 @@ const makeFetch = (method, url, body) => {
}
if (response.status === 422) {
- return response.json();
+ return response.json().then(violations => {
+ throw ValidationException(violations)
+ });
}
throw {
@@ -33,13 +35,22 @@ const makeFetch = (method, url, body) => {
});
}
+/**
+ * @param violations
+ * @constructor
+ */
+const ValidationException = (violations) => {
+ this.violations = violations
+ this.name = 'ValidationException'
+}
+
/**
* @function getFetch
* @param url
* @returns {Promise}
*/
const getFetch = (url) => {
- return makeFetch('GET', url, null);
+ return makeFetch('GET', url, null)
}
/**
@@ -49,7 +60,7 @@ const getFetch = (url) => {
* @returns {Promise}
*/
const postFetch = (url, body) => {
- return makeFetch('POST', url, body);
+ return makeFetch('POST', url, body)
}
/**
@@ -59,7 +70,7 @@ const postFetch = (url, body) => {
* @returns {Promise}
*/
const patchFetch = (url, body) => {
- return makeFetch('PATCH', url, body);
+ return makeFetch('PATCH', url, body)
}
From 1155555bb3ec1c375ef683f13ea355772d305214 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 10:37:51 +0200
Subject: [PATCH 033/119] backend: adapt deprecated getGenderNumeric
---
src/Bundle/ChillPersonBundle/Entity/Person.php | 14 ++++++++++----
.../Serializer/Normalizer/PersonNormalizer.php | 1 -
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index 9aaad8c04..01a524beb 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -901,13 +901,19 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* return gender as a Numeric form.
* This is used for translations
* @return int
+ * @deprecated Keep for legacy. Used in Chill 1.5 for feminize before icu translations
*/
public function getGenderNumeric()
{
- if ($this->getGender() == self::FEMALE_GENDER) {
- return 1;
- } else {
- return 0;
+ switch ($this->getGender()) {
+ case self::FEMALE_GENDER:
+ return 1;
+ case self::MALE_GENDER:
+ return 0;
+ case self::BOTH_GENDER:
+ return 2;
+ default:
+ return -1;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
index 2b82780c2..380112a12 100644
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
+++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php
@@ -79,7 +79,6 @@ class PersonNormalizer implements
'mobilenumber' => $person->getMobilenumber(),
'altNames' => $this->normalizeAltNames($person->getAltNames()),
'gender' => $person->getGender(),
- 'gender_numeric' => $person->getGenderNumeric(),
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
];
From 50fbc7fd158b9c038953433b338cdc5c3d70b8b6 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 11:30:01 +0200
Subject: [PATCH 034/119] processing of review. still ACL left to do
---
.../Controller/RelationshipApiController.php | 2 +-
.../Entity/Relationships/Relation.php | 18 ++++++
.../Relationships/RelationRepository.php | 62 ++++++++-----------
.../Relationships/RelationshipRepository.php | 50 ++++++++++-----
.../Normalizer/RelationshipNormalizer.php | 38 ------------
.../migrations/Version20211029075117.php | 29 +++++++++
6 files changed, 110 insertions(+), 89 deletions(-)
delete mode 100644 src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 765d13d25..69809d6ee 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -25,7 +25,7 @@ class RelationshipApiController extends ApiController
/**
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
- * name="chill_relation_relationship_by_person")
+ * name="chill_relationship_by_person")
*
* @ParamConverter("person", options={"id" = "person_id"})
*/
diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
index a0fefc877..7628863fe 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php
@@ -35,6 +35,12 @@ class Relation
*/
private array $reverseTitle = [];
+ /**
+ * @ORM\Column(type="boolean", nullable=true)
+ * @Serializer\Groups({"read"})
+ */
+ private bool $isActive = true;
+
public function getId(): ?int
{
return $this->id;
@@ -63,4 +69,16 @@ class Relation
return $this;
}
+
+ public function getIsActive(): bool
+ {
+ return $this->isActive;
+ }
+
+ public function setIsActive(?bool $isActive): self
+ {
+ $this->isActive = $isActive;
+
+ return $this;
+ }
}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
index 8b5fbb743..b735138f4 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php
@@ -2,49 +2,41 @@
namespace Chill\PersonBundle\Repository\Relationships;
-use App\Entity\Relation;
-use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Persistence\ManagerRegistry;
+use Chill\PersonBundle\Entity\Relationships\Relation;
+use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\EntityRepository;
+use Doctrine\Persistence\ObjectRepository;
-/**
- * @method Relation|null find($id, $lockMode = null, $lockVersion = null)
- * @method Relation|null findOneBy(array $criteria, array $orderBy = null)
- * @method Relation[] findAll()
- * @method Relation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
-class RelationRepository extends ServiceEntityRepository
+class RelationRepository implements ObjectRepository
{
- public function __construct(ManagerRegistry $registry)
+ private EntityRepository $repository;
+
+ public function __construct(EntityManagerInterface $entityManager)
{
- parent::__construct($registry, Relation::class);
+ $this->repository = $entityManager->getRepository(Relation::class);
+ }
+ public function find($id): ?Relation
+ {
+ return $this->repository->find($id);
}
- // /**
- // * @return Relation[] Returns an array of Relation objects
- // */
- /*
- public function findByExampleField($value)
+ public function findAll(): array
{
- return $this->createQueryBuilder('r')
- ->andWhere('r.exampleField = :val')
- ->setParameter('val', $value)
- ->orderBy('r.id', 'ASC')
- ->setMaxResults(10)
- ->getQuery()
- ->getResult()
- ;
+ return $this->repository->findAll();
}
- */
- /*
- public function findOneBySomeField($value): ?Relation
+ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
- return $this->createQueryBuilder('r')
- ->andWhere('r.exampleField = :val')
- ->setParameter('val', $value)
- ->getQuery()
- ->getOneOrNullResult()
- ;
+ return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
+ }
+
+ public function findOneBy(array $criteria): ?Relation
+ {
+ return $this->findOneBy($criteria);
+ }
+
+ public function getClassName(): string
+ {
+ return MaritalStatus::class;
}
- */
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
index 00546e424..3f105537a 100644
--- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php
@@ -3,30 +3,50 @@
namespace Chill\PersonBundle\Repository\Relationships;
use Chill\PersonBundle\Entity\Relationships\Relationship;
-use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ObjectRepository;
-/**
- * @method Relationship|null find($id, $lockMode = null, $lockVersion = null)
- * @method Relationship|null findOneBy(array $criteria, array $orderBy = null)
- * @method Relationship[] findAll()
- * @method Relationship[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
-class RelationshipRepository extends ServiceEntityRepository
+class RelationshipRepository implements ObjectRepository
{
- public function __construct(ManagerRegistry $registry)
+
+ private EntityRepository $repository;
+
+ public function __construct(EntityManagerInterface $em)
{
- parent::__construct($registry, Relationship::class);
+ $this->repository = $em->getRepository(Relationship::class);
}
- // /**
- // * @return Relationship[] Returns an array of Relationship objects linked to certain person.
- // */
+ public function find($id): ?Relationship
+ {
+ return $this->repository->find($id);
+ }
+
+ public function findAll(): array
+ {
+ return $this->repository->findAll();
+ }
+
+ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
+ {
+ return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
+ }
+
+ public function findOneBy(array $criteria): ?Relationship
+ {
+ return $this->findOneBy($criteria);
+ }
+
+ public function getClassName(): string
+ {
+ return MaritalStatus::class;
+ }
- public function findByPerson($personId)
+ public function findByPerson($personId): array
{
// return all relationships of which person is part? or only where person is the fromPerson?
- return $this->createQueryBuilder('r')
+ return $this->repository->createQueryBuilder('r')
->select('r, t') // entity Relationship
->join('r.relation', 't')
->where('r.fromPerson = :val')
diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
deleted file mode 100644
index e410dd90b..000000000
--- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipNormalizer.php
+++ /dev/null
@@ -1,38 +0,0 @@
- 'relationship',
- 'id' => $this->normalizer->normalize($relationship->getId()),
- 'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
- 'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
- 'relation' => $this->normalizer->normalize($relationship->getRelation()),
- 'reverse' => $relationship->getReverse()
- ];
- }
-
- public function supportsNormalization($data, ?string $format = null)
- {
- return $data instanceof Relationship;
- }
-
-}
\ No newline at end of file
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
new file mode 100644
index 000000000..9c3d5131e
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
@@ -0,0 +1,29 @@
+addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN NOT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE chill_person_relations DROP isActive');
+ }
+}
From 039c74a1e435426a4f8840ee943aa4d65b78ff96 Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 13:20:56 +0200
Subject: [PATCH 035/119] route annotation removed
---
.../Controller/AccompanyingCourseApiController.php | 7 -------
.../Controller/RelationshipApiController.php | 5 -----
2 files changed, 12 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
index 132dc1172..72ca7aa5b 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php
@@ -21,7 +21,6 @@ use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Workflow\Registry;
-use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingCourseApiController extends ApiController
@@ -195,12 +194,6 @@ $workflow = $this->registry->get($accompanyingPeriod);
}
/**
- * @Route("/api/1.0/person/accompanying-course/by-person/{person_id}.{_format}",
- * name="chill_person_accompanyingperiod_by_person",
- * requirements={
- * "_format"="json"
- * })
- *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getAccompanyingPeriodsByPerson(Person $person){
diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
index 69809d6ee..bf4452942 100644
--- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php
@@ -8,9 +8,7 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;
-use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Symfony\Component\HttpFoundation\Request;
class RelationshipApiController extends ApiController
{
@@ -24,9 +22,6 @@ class RelationshipApiController extends ApiController
}
/**
- * @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
- * name="chill_relationship_by_person")
- *
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getRelationshipsByPerson(Person $person)
From 1c60a5b51e33a3a8159886c81108d0835d94352a Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 12:06:59 +0200
Subject: [PATCH 036/119] vue_visgraph: improve graph
---
.../Resources/public/vuejs/VisGraph/i18n.js | 5 ++
.../Resources/public/vuejs/VisGraph/store.js | 13 ++--
.../public/vuejs/VisGraph/vis-network.js | 74 +++++++++++--------
3 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 9ca273f72..0e1cf4686 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -6,6 +6,11 @@ const visMessages = {
Holder: 'Titulaire',
Legend: 'Calques',
concerned: 'concerné',
+ both: 'neutre, non binaire',
+ woman: 'féminin',
+ man: 'masculin',
+ years: 'ans'
+
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 394fd55e6..b336da45a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -115,7 +115,6 @@ const store = createStore({
* 1) Add a person in state
* @param Person person
*/
-
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
commit('addPerson', person)
@@ -127,7 +126,9 @@ const store = createStore({
* @param Person person
*/
fetchInfoForPerson({ dispatch }, person) {
- dispatch('fetchHouseholdForPerson', person)
+ if (null !== person.current_household_id) {
+ dispatch('fetchHouseholdForPerson', person)
+ }
dispatch('fetchCoursesByPerson', person)
dispatch('fetchRelationshipByPerson', person)
},
@@ -226,7 +227,7 @@ const store = createStore({
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
- label: visMessages.fr.visgraph.concerned,
+ //label: visMessages.fr.visgraph.concerned,
})
if (!getters.isPersonLoaded(p.person.id)) {
console.log(' person is not loaded', p.person.id)
@@ -277,9 +278,11 @@ const store = createStore({
to: `person_${r.toPerson.id}`,
id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
arrows: 'to',
- color: 'lightblue', dashes: true,
+ color: 'lightblue',
font: { color: '#33839d' },
+ dashes: true,
label: getRelationshipLabel(r, false),
+ title: getRelationshipTitle(r),
})
for (let person of [r.fromPerson, r.toPerson]) {
if (!getters.isPersonLoaded(person.id)) {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index eeddb7da4..f8001f441 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -128,7 +128,7 @@ window.options = {
background: 'none',
strokeWidth: 2, // px
strokeColor: '#ffffff',
- align: 'horizontal',
+ align: 'middle',
multi: false,
vadjust: 0,
},
@@ -154,15 +154,9 @@ window.options = {
}
},
household: {
- /*
- shape: 'dot',
- */
color: 'pink'
},
accompanying_period: {
- /*
- shape: 'triangle',
- */
color: 'orange',
},
}
@@ -179,7 +173,8 @@ const adapt2vis = (entity) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = `${entity.text}\n` + getGender(entity.gender_numeric) +' - '+ getAge(entity.birthdate)
+ entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
+ //entity.title = `${entity.text}`
entity.id = `person_${entity.id}`
break
case 'household':
@@ -195,29 +190,42 @@ const adapt2vis = (entity) => {
case 'relationship':
entity._id = entity.id
entity.id = `relationship_${entity.id}`
+ break
+ default:
+ throw 'entity undefined'
}
return entity
}
+/**
+ * @param gender
+ * @returns {string}
+ */
const getGender = (gender) => {
switch (gender) {
- case 0:
- return 'N'
- case 1:
- return 'M'
- case 2:
- return 'F'
+ case 'both':
+ return visMessages.fr.visgraph.both
+ case 'woman':
+ return visMessages.fr.visgraph.woman
+ case 'man':
+ return visMessages.fr.visgraph.man
default:
throw 'gender undefined'
}
}
+
+/**
+ * TODO Repeat getAge() in PersonRenderBox.vue
+ * @param birthdate
+ * @returns {string|null}
+ */
const getAge = (birthdate) => {
if (null === birthdate) {
return null
}
const birthday = new Date(birthdate.datetime)
const now = new Date()
- return (now.getFullYear() - birthday.getFullYear()) + ' ans'
+ return (now.getFullYear() - birthday.getFullYear()) + ' '+ visMessages.fr.visgraph.years
}
/**
@@ -235,24 +243,15 @@ const getHouseholdLabel = (member) => {
* Return edge width for member (depends of position in household)
* @param member
* @returns integer (width)
- *
- * TODO
- * to use: holder, shareHousehold
- * not use: ordering, position (-> null)
*/
const getHouseholdWidth = (member) => {
- switch (member.position.ordering) {
- case 1: //adult
- if (member.holder) {
- return 6
- }
- return 3
- case 2: //children
- case 3: //children out of household
- return 1
- default:
- throw 'Ordering not supported'
+ if (member.holder) {
+ return 5
}
+ if (member.shareHousehold) {
+ return 2
+ }
+ return 1
}
/**
@@ -264,9 +263,22 @@ const getRelationshipLabel = (relationship, reverse) => {
return (!reverse) ? relationship.relation.title.fr : relationship.relation.reverseTitle.fr
}
+/**
+ * Return title edge
+ * @param relationship
+ * @returns string
+ */
+const getRelationshipTitle = (relationship) => {
+ return relationship.relation.title.fr + ': '
+ + relationship.fromPerson.text + '\n'
+ + relationship.relation.reverseTitle.fr + ': '
+ + relationship.toPerson.text
+}
+
export {
adapt2vis,
getHouseholdLabel,
getHouseholdWidth,
- getRelationshipLabel
+ getRelationshipLabel,
+ getRelationshipTitle
}
From a9d3d2027b84bfa9c95e19e93925e2910cb4ab3e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 15:32:12 +0200
Subject: [PATCH 037/119] minor
---
.../Resources/public/vuejs/VisGraph/store.js | 35 ++++++++++++-------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index b336da45a..86b21d3de 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,7 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
-import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@@ -113,7 +112,8 @@ const store = createStore({
actions: {
/**
* 1) Add a person in state
- * @param Person person
+ * @param object
+ * @param person
*/
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
@@ -123,7 +123,8 @@ const store = createStore({
/**
* 2) Fetch infos for this person (hub)
- * @param Person person
+ * @param object
+ * @param person
*/
fetchInfoForPerson({ dispatch }, person) {
if (null !== person.current_household_id) {
@@ -136,7 +137,8 @@ const store = createStore({
/**
* 3) Fetch person current household (if it is not already loading)
* check first isHouseholdLoading to fetch household once
- * @param Person person
+ * @param object
+ * @param person
*/
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
@@ -157,7 +159,8 @@ const store = createStore({
/**
* 4) Add an edge for each household member (household -> person)
- * @param Household household
+ * @param object
+ * @param household
*/
addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
@@ -182,7 +185,8 @@ const store = createStore({
/**
* 5) Fetch AccompanyingCourses for the person
- * @param Person person
+ * @param object
+ * @param person
*/
fetchCoursesByPerson({ commit, dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
@@ -196,7 +200,8 @@ const store = createStore({
/**
* 6) Add each distinct course
- * @param array courses
+ * @param object
+ * @param courses
*/
addCourses({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
@@ -214,7 +219,8 @@ const store = createStore({
/**
* 7) Add an edge for each course participation (course <- person)
- * @param AccompanyingCourse course
+ * @param object
+ * @param course
*/
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
@@ -227,7 +233,6 @@ const store = createStore({
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
- //label: visMessages.fr.visgraph.concerned,
})
if (!getters.isPersonLoaded(p.person.id)) {
console.log(' person is not loaded', p.person.id)
@@ -238,7 +243,8 @@ const store = createStore({
/**
* 8) Fetch Relationship
- * @param Person person
+ * @param object
+ * @param person
*/
fetchRelationshipByPerson({ dispatch }, person) {
//console.log('fetchRelationshipByPerson', person)
@@ -253,7 +259,8 @@ const store = createStore({
/**
* 9) Add each distinct relationship
- * @param array relationships
+ * @param object
+ * @param relationships
*/
addRelationships({ commit, getters, dispatch }, relationships) {
relationships.forEach(relationship => {
@@ -269,7 +276,8 @@ const store = createStore({
/**
* 10) Add an edge for each relationship (person -> person)
- * @param Relationship r
+ * @param object
+ * @param r (relationship)
*/
addLinkFromRelationship({ commit, getters, dispatch }, r) {
//console.log('-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id)
@@ -294,7 +302,8 @@ const store = createStore({
/**
* Fetch missing person
- * @param Person person
+ * @param object
+ * @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
//console.log('addMissingPerson', person)
From e6183f664629f315ef8666ade8796b79c697a53c Mon Sep 17 00:00:00 2001
From: Julie Lenaerts
Date: Fri, 29 Oct 2021 15:56:57 +0200
Subject: [PATCH 038/119] migration fixed to insert default true value for
isActive
---
.../ChillPersonBundle/migrations/Version20211029075117.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
index 9c3d5131e..ef739dcb8 100644
--- a/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
+++ b/src/Bundle/ChillPersonBundle/migrations/Version20211029075117.php
@@ -19,7 +19,7 @@ final class Version20211029075117 extends AbstractMigration
public function up(Schema $schema): void
{
- $this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN NOT NULL');
+ $this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN DEFAULT true NOT NULL');
}
public function down(Schema $schema): void
From 8eedee5e9106792f58624891c3244fdefcab698e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 16:54:22 +0200
Subject: [PATCH 039/119] visgraph: default uncheck layers when loading
---
.../ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 86b21d3de..a0109c9c8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -148,6 +148,7 @@ const store = createStore({
.then(household => new Promise(resolve => {
//console.log('getHouseholdByPerson', household)
commit('addHousehold', household)
+ commit('addExcludedNode', household.id)
dispatch('addLinkFromPersonsToHousehold', household)
resolve()
})
@@ -212,6 +213,7 @@ const store = createStore({
//console.log('course', course.id)
commit('markCourseLoaded', course.id)
commit('addCourse', course)
+ commit('addExcludedNode', course.id)
dispatch('addLinkFromPersonsToCourse', course)
}
})
From 83129553913d030a3298de333a9691192f416fa9 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 17:34:37 +0200
Subject: [PATCH 040/119] visgraph: hide somes persons nodes labels (folded)
---
.../Resources/public/vuejs/VisGraph/i18n.js | 4 +-
.../Resources/public/vuejs/VisGraph/store.js | 50 +++++++++++--------
.../public/vuejs/VisGraph/vis-network.js | 9 +++-
3 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 0e1cf4686..5b408e209 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -9,8 +9,8 @@ const visMessages = {
both: 'neutre, non binaire',
woman: 'féminin',
man: 'masculin',
- years: 'ans'
-
+ years: 'ans',
+ click_to_expand: 'cliquez pour étendre',
},
edit: 'Éditer',
del: 'Supprimer',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index a0109c9c8..0944667bc 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -59,49 +59,53 @@ const store = createStore({
mutations: {
addPerson(state, person) {
console.log('+ addPerson', person.id)
- state.persons.push(adapt2vis(person))
+ state.persons.push(person)
},
addHousehold(state, household) {
console.log('+ addHousehold', household.id)
- state.households.push(adapt2vis(household))
+ state.households.push(household)
},
addCourse(state, course) {
console.log('+ addCourse', course.id)
- state.courses.push(adapt2vis(course))
+ state.courses.push(course)
},
addRelationship(state, relationship) {
console.log('+ addRelationship', relationship.id)
- state.relationships.push(adapt2vis(relationship))
+ state.relationships.push(relationship)
},
addLink(state, link) {
console.log('+ addLink from', link.from, 'to', link.to)
state.links.push(link)
},
+
+ //// id markers
markPersonLoaded(state, id) {
state.personLoadedIds.push(id)
},
- unmarkPersonLoaded(state, id) {
- state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
- },
+ unmarkPersonLoaded(state, id) {
+ state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
+ },
markHouseholdLoading(state, id) {
console.log('..loading household', id)
state.householdLoadingIds.push(id)
},
- unmarkHouseholdLoading(state, id) {
- state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
- },
+ unmarkHouseholdLoading(state, id) {
+ state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
+ },
markCourseLoaded(state, id) {
state.courseLoadedIds.push(id)
},
- unmarkCourseLoaded(state, id) {
- state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
- },
+ unmarkCourseLoaded(state, id) {
+ state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
+ },
markRelationshipLoaded(state, id) {
state.relationshipLoadedIds.push(id)
},
- unmarkRelationshipLoaded(state, id) {
- state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
- },
+ unmarkRelationshipLoaded(state, id) {
+ state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
+ },
+
+ //// excluded
addExcludedNode(state, id) {
state.excludedNodesIds.push(id)
},
@@ -117,7 +121,7 @@ const store = createStore({
*/
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
- commit('addPerson', person)
+ commit('addPerson', adapt2vis(person, { folded: false }))
dispatch('fetchInfoForPerson', person)
},
@@ -147,7 +151,7 @@ const store = createStore({
getHouseholdByPerson(person)
.then(household => new Promise(resolve => {
//console.log('getHouseholdByPerson', household)
- commit('addHousehold', household)
+ commit('addHousehold', adapt2vis(household))
commit('addExcludedNode', household.id)
dispatch('addLinkFromPersonsToHousehold', household)
resolve()
@@ -212,7 +216,7 @@ const store = createStore({
if (! getters.isCourseLoaded(course.id)) {
//console.log('course', course.id)
commit('markCourseLoaded', course.id)
- commit('addCourse', course)
+ commit('addCourse', adapt2vis(course))
commit('addExcludedNode', course.id)
dispatch('addLinkFromPersonsToCourse', course)
}
@@ -270,7 +274,7 @@ const store = createStore({
if (! getters.isRelationshipLoaded(relationship.id)) {
//console.log('relationship', relationship.id)
commit('markRelationshipLoaded', relationship.id)
- commit('addRelationship', relationship)
+ commit('addRelationship', adapt2vis(relationship))
dispatch('addLinkFromRelationship', relationship)
}
})
@@ -308,9 +312,11 @@ const store = createStore({
* @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
- //console.log('addMissingPerson', person)
commit('markPersonLoaded', person.id)
- commit('addPerson', person)
+ commit('addPerson', adapt2vis(person, { folded: true }))
+
+ console.log('********* fetch infos for missing', person.id, '******')
+ //dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index f8001f441..8cafdda9f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -166,15 +166,20 @@ window.options = {
* Adapt entity to graph (id, label)
* rename id in _id and add properties needed by vis
* @param entity
+ * @param options
* @returns entity
*/
-const adapt2vis = (entity) => {
+const adapt2vis = (entity, options = {}) => {
entity.group = entity.type
switch (entity.type) {
case 'person':
entity._id = entity.id
entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
- //entity.title = `${entity.text}`
+ if (options.folded) {
+ entity.title = visMessages.fr.visgraph.click_to_expand
+ entity._label = entity.label // keep label
+ entity.label = null
+ }
entity.id = `person_${entity.id}`
break
case 'household':
From 09903c2f52ea8dbd370f6ee1aab8765c1009ee12 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Fri, 29 Oct 2021 19:08:52 +0200
Subject: [PATCH 041/119] click node event (wip)
---
.../ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index fd45dd750..9ff406e47 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -114,6 +114,10 @@ export default {
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
this.$store.commit('addExcludedNode', id)
},
+ clickOnNode(callback) {
+ console.log('** click on node **')
+ window.network.on('click', callback)
+ },
}
/*
TODO / TO CHECK / TO UNDERSTAND
From 851a24625798bd9489a0bd8a9876887d3685218b Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Sat, 30 Oct 2021 00:27:10 +0200
Subject: [PATCH 042/119] visgraph: improve label with basic markdown
---
.../Resources/public/vuejs/VisGraph/vis-network.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 8cafdda9f..ecec18c9b 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -118,6 +118,9 @@ window.options = {
//physics: true,
borderWidth: 1,
borderWidthSelected: 3,
+ font: {
+ multi: 'md'
+ }
},
edges: {
//physics: true,
@@ -148,7 +151,7 @@ window.options = {
border: '#b0b0b0',
background: 'rgb(193,229,222)',
highlight: {
- border: '#368d7e',
+ border: '#8d3686',
background: 'rgb(193,229,222)'
}
}
@@ -174,7 +177,7 @@ const adapt2vis = (entity, options = {}) => {
switch (entity.type) {
case 'person':
entity._id = entity.id
- entity.label = `${entity.text}\n` + getGender(entity.gender) +' - '+ getAge(entity.birthdate)
+ entity.label = `*${entity.text}*\n_${getGender(entity.gender)} - ${getAge(entity.birthdate)}_`
if (options.folded) {
entity.title = visMessages.fr.visgraph.click_to_expand
entity._label = entity.label // keep label
From a57a23dc4934225c9e6a5310c1767e4ec5b7ae63 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Sat, 30 Oct 2021 01:51:02 +0200
Subject: [PATCH 043/119] visgraph options settings
---
.../Resources/public/vuejs/VisGraph/store.js | 2 +-
.../public/vuejs/VisGraph/vis-network.js | 22 ++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 0944667bc..80e4d0768 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -316,7 +316,7 @@ const store = createStore({
commit('addPerson', adapt2vis(person, { folded: true }))
console.log('********* fetch infos for missing', person.id, '******')
- //dispatch('fetchInfoForPerson', person)
+ dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index ecec18c9b..fca3c0876 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -25,8 +25,8 @@ window.options = {
barnesHut: {
theta: 0.5,
gravitationalConstant: -2000,
- centralGravity: 0.1, //// 0.3
- springLength: 200, //// 95
+ centralGravity: 0.08, //// 0.3
+ springLength: 220, //// 95
springConstant: 0.04,
damping: 0.09,
avoidOverlap: 0
@@ -151,10 +151,22 @@ window.options = {
border: '#b0b0b0',
background: 'rgb(193,229,222)',
highlight: {
- border: '#8d3686',
- background: 'rgb(193,229,222)'
+ border: '#89c9a9',
+ background: 'rgb(156,213,203)'
+ },
+ hover: {
+ border: '#89c9a9',
+ background: 'rgb(156,213,203)'
}
- }
+ },
+ opacity: 0.85,
+ shadow:{
+ enabled: true,
+ color: 'rgba(0,0,0,0.5)',
+ size:10,
+ x:5,
+ y:5
+ },
},
household: {
color: 'pink'
From 869e442c2c515bb01ab614beee93a890db4aa105 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 09:49:55 +0100
Subject: [PATCH 044/119] visgraph: add hover interaction
---
.../Resources/public/vuejs/VisGraph/store.js | 4 ++--
.../Resources/public/vuejs/VisGraph/vis-network.js | 12 ++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 80e4d0768..066b7c1dc 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -294,7 +294,7 @@ const store = createStore({
arrows: 'to',
color: 'lightblue',
font: { color: '#33839d' },
- dashes: true,
+ dashes: true, //physics: false,
label: getRelationshipLabel(r, false),
title: getRelationshipTitle(r),
})
@@ -316,7 +316,7 @@ const store = createStore({
commit('addPerson', adapt2vis(person, { folded: true }))
console.log('********* fetch infos for missing', person.id, '******')
- dispatch('fetchInfoForPerson', person)
+ //dispatch('fetchInfoForPerson', person)
},
}
})
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index fca3c0876..15d9fafdd 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -69,6 +69,16 @@ window.options = {
adaptiveTimestep: true,
wind: { x: 0, y: 0 }
},
+ interaction: {
+ hover: true,
+ keyboard: {
+ enabled: true,
+ speed: {x: 3, y: 3, zoom: 0.02},
+ bindToWindow: false
+ },
+ multiselect: true,
+ navigationButtons: false
+ },
manipulation: {
enabled: true,
initiallyActive: true,
@@ -115,7 +125,6 @@ window.options = {
}
},
nodes: {
- //physics: true,
borderWidth: 1,
borderWidthSelected: 3,
font: {
@@ -123,7 +132,6 @@ window.options = {
}
},
edges: {
- //physics: true,
font: {
color: '#b0b0b0',
size: 9,
From c4ba78d076a3106575cc13f71068e33af4708d7e Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 10:50:13 +0100
Subject: [PATCH 045/119] minor
---
.../public/vuejs/VisGraph/vis-network.js | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 15d9fafdd..7932217b1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -7,7 +7,7 @@ import { visMessages } from './i18n'
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
-window.network = {};
+window.network = {}
window.options = {
locale: 'fr',
@@ -84,28 +84,28 @@ window.options = {
initiallyActive: true,
addNode: function(nodeData, callback) {
console.log('addNode', nodeData)
- nodeData.label = 'hello world';
- callback(nodeData);
+ nodeData.label = 'hello world'
+ callback(nodeData)
},
editNode: function(nodeData, callback) {
console.log('editNode', nodeData)
- callback(nodeData);
+ callback(nodeData)
},
deleteNode: function(nodeData, callback) {
console.log('deleteNode', nodeData)
- callback(nodeData);
+ callback(nodeData)
},
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
deleteEdge: function(edgeData, callback) {
console.log('deleteNode', edgeData)
- callback(edgeData);
+ callback(edgeData)
},
controlNodeStyle: {
/*
@@ -183,7 +183,7 @@ window.options = {
color: 'orange',
},
}
-};
+}
/**
* Adapt entity to graph (id, label)
@@ -285,6 +285,7 @@ const getHouseholdWidth = (member) => {
/**
* Return label edge
* @param relationship
+ * @param reverse
* @returns string
*/
const getRelationshipLabel = (relationship, reverse) => {
From a0940a0c8517667dc27374a8d7403bd5b9d48c61 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 10:45:37 +0100
Subject: [PATCH 046/119] visgraph: init window.eventHub as external emitter
called in Vue. This implementation works with vue2, but is deprecated in vue3
!!
see https://vue3-fr.netlify.app/guide/migration/events-api.html#_2-x-syntax
---
.../Resources/public/vuejs/VisGraph/App.vue | 9 +++++++++
.../Resources/public/vuejs/VisGraph/index.js | 1 +
.../Resources/public/vuejs/VisGraph/vis-network.js | 7 +++++++
3 files changed, 17 insertions(+)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 9ff406e47..c72c3689f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -79,6 +79,12 @@ export default {
}
},
+ created() {
+ eventHub.$on('add-switch', this.addSwitch)
+ },
+ unmounted() {
+ eventHub.$off('add-switch', this.addSwitch)
+ },
mounted() {
console.log('=== mounted: init graph')
this.initGraph()
@@ -118,6 +124,9 @@ export default {
console.log('** click on node **')
window.network.on('click', callback)
},
+ addSwitch(edgeData) {
+ console.log('==> addSwitch <=======================', edgeData)
+ },
}
/*
TODO / TO CHECK / TO UNDERSTAND
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
index 332b6cf6c..9e3da390f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/index.js
@@ -3,6 +3,7 @@ import { store } from "./store.js"
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { visMessages } from './i18n'
import App from './App.vue'
+
import './vis-network'
const i18n = _createI18n(visMessages)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 7932217b1..a5d2a8daa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,4 +1,5 @@
import { visMessages } from './i18n'
+import {createApp} from "vue"
/**
* Vis-network initial data/configuration script
@@ -7,6 +8,11 @@ import { visMessages } from './i18n'
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
+console.log('@@@@@@@ eventHub App @@@@@@@@@@')
+window.eventHub = createApp()
+console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
+
+
window.network = {}
window.options = {
@@ -98,6 +104,7 @@ window.options = {
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData)
+ eventHub.$emit('add-switch', edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
From 41f815bbb91e0b06bb6d30914141665a771e9b1d Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 11:46:30 +0100
Subject: [PATCH 047/119] tiny-emitter package is used as "centralized event
hub" between vis-network and vue3
---
.../Resources/public/vuejs/VisGraph/App.vue | 8 ++++----
.../Resources/public/vuejs/VisGraph/vis-network.js | 12 +++++-------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index c72c3689f..5bd654bd5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -80,10 +80,10 @@ export default {
},
created() {
- eventHub.$on('add-switch', this.addSwitch)
+ eventHub.on('add-relationship-link', this.addRelationshipLink)
},
unmounted() {
- eventHub.$off('add-switch', this.addSwitch)
+ eventHub.off('add-relationship-link', this.addRelationshipLink)
},
mounted() {
console.log('=== mounted: init graph')
@@ -124,8 +124,8 @@ export default {
console.log('** click on node **')
window.network.on('click', callback)
},
- addSwitch(edgeData) {
- console.log('==> addSwitch <=======================', edgeData)
+ addRelationshipLink(edgeData) {
+ console.log('==> addRelationshipLink <=======================', edgeData)
},
}
/*
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index a5d2a8daa..086608e19 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -1,5 +1,5 @@
import { visMessages } from './i18n'
-import {createApp} from "vue"
+import { TinyEmitter } from "tiny-emitter";
/**
* Vis-network initial data/configuration script
@@ -8,10 +8,8 @@ import {createApp} from "vue"
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
-console.log('@@@@@@@ eventHub App @@@@@@@@@@')
-window.eventHub = createApp()
-console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
-
+console.log('@@@ init eventHub App @@@')
+window.eventHub = new TinyEmitter()
window.network = {}
@@ -26,7 +24,7 @@ window.options = {
showButton: true
},
*/
- physics:{
+ physics: {
enabled: true,
barnesHut: {
theta: 0.5,
@@ -104,7 +102,7 @@ window.options = {
addEdge: function(edgeData, callback) {
console.log('addEdge', edgeData)
callback(edgeData)
- eventHub.$emit('add-switch', edgeData)
+ eventHub.emit('add-relationship-link', edgeData)
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
From 5d995115babc03b5a476b046e8117db5f0f1e935 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 12:40:22 +0100
Subject: [PATCH 048/119] visgraph: only addEdge for person to person
---
.../Resources/public/vuejs/VisGraph/i18n.js | 2 +-
.../Resources/public/vuejs/VisGraph/store.js | 4 +--
.../public/vuejs/VisGraph/vis-network.js | 31 ++++++++++++++++---
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
index 5b408e209..609299cfe 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js
@@ -20,7 +20,7 @@ const visMessages = {
editNode: 'Éditer un noeuds',
editEdge: 'Éditer un lien',
addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
- edgeDescription: 'Cliquez sur un nœud et faites glisser le lien vers un autre nœud pour les connecter.',
+ edgeDescription: 'Cliquez sur un usager et faites glisser le lien vers un autre usager pour les connecter.',
editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 066b7c1dc..772af6630 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -1,6 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
-import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
+import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, splitId } from './vis-network'
const debug = process.env.NODE_ENV !== 'production'
@@ -235,7 +235,7 @@ const store = createStore({
commit('addLink', {
from: `${p.person.type}_${p.person.id}`,
to: `${course.id}`,
- id: `p${p.person.id}-c`+ course.id.split('_')[2],
+ id: `p${p.person.id}-c`+ splitId(course.id,'id'),
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 086608e19..b13f9ac32 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -100,9 +100,14 @@ window.options = {
callback(nodeData)
},
addEdge: function(edgeData, callback) {
- console.log('addEdge', edgeData)
- callback(edgeData)
- eventHub.emit('add-relationship-link', edgeData)
+ if (
+ splitId(edgeData.from,'type') === 'person'
+ && splitId(edgeData.to,'type') === 'person'
+ ) {
+ console.log('addEdge', edgeData)
+ eventHub.emit('add-relationship-link', edgeData)
+ callback(edgeData)
+ }
},
editEdge: function(edgeData, callback) {
console.log('editNode', edgeData)
@@ -309,10 +314,28 @@ const getRelationshipTitle = (relationship) => {
+ relationship.toPerson.text
}
+/**
+ * Split string id and return type|id substring
+ * @param id
+ * @param position
+ * @returns string
+ */
+const splitId = (id, position) => {
+ switch (position) {
+ case 'type':
+ return /(.+)_/.exec(id)[1] // return 'accompanying_period'
+ case 'id':
+ return id.split("_").pop() // return '124'
+ default:
+ throw 'position undefined'
+ }
+}
+
export {
adapt2vis,
getHouseholdLabel,
getHouseholdWidth,
getRelationshipLabel,
- getRelationshipTitle
+ getRelationshipTitle,
+ splitId
}
From d3a08149f0f12886cef414b2a25d12df5f927c73 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Mon, 1 Nov 2021 13:31:58 +0100
Subject: [PATCH 049/119] visgraph: open vue modal when adding/editing edge
---
.../Resources/public/vuejs/VisGraph/App.vue | 45 ++++++++++++++++---
.../public/vuejs/VisGraph/vis-network.js | 20 ++++++---
2 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 5bd654bd5..ffe73a7ab 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -4,7 +4,6 @@
@@ -147,8 +147,8 @@ export default {
container: '',
checkedLayers: [],
relations: [],
- relation: null,
- reverse: false,
+ //relation: null,
+ //reverse: false,
displayHelpMessage: false,
listenPersonFlag: 'normal',
newEdgeData: {},
@@ -157,7 +157,13 @@ export default {
modalDialogClass: "modal-md",
title: null,
action: null,
- data: {},
+ data: {
+ type: 'relationship',
+ from: null,
+ to: null,
+ relation: null,
+ reverse: false
+ },
button: {
class: null,
text: null
@@ -216,26 +222,24 @@ export default {
},
- /*
relation: {
get() {
- return this.relation
+ return this.modal.data.relation
},
set(value) {
- //console.log('setter relation', value) // <=== InternalError: too much recursion
- this.relation = value
+ this.modal.data.relation = value
}
},
reverse: {
get() {
- return this.reverse
+ return this.modal.data.reverse
},
- set(newValue) {
- //console.log('setter reverse', newValue) // <=== InternalError: too much recursion
- this.reverse = newValue
+ set(value) {
+ this.modal.data.reverse = value
}
},
+ /*
*/
},
@@ -377,8 +381,9 @@ export default {
/// control Modal
addRelationshipModal(edgeData) {
- this.modal.data = edgeData
- console.log('==- addRelationshipModal', edgeData) // { from: "person_1617", to: "person_1614" }
+ console.log('==- addRelationshipModal', edgeData)
+ this.modal.data.from = edgeData.from
+ this.modal.data.to = edgeData.to
this.modal.action = 'create'
this.modal.title = 'visgraph.add_relationship_link'
this.modal.button.class = 'btn-create'
@@ -410,7 +415,13 @@ export default {
resetForm() {
console.log('==- reset Form')
- this.modal.data = {}
+ this.modal.data = {
+ type: 'relationship',
+ from: null,
+ to: null,
+ relation: null,
+ reverse: false
+ }
this.modal.action = null
this.modal.title = null
this.modal.button.class = null
@@ -428,6 +439,7 @@ export default {
//console.log('customLabel', value)
return (value.title && value.reverseTitle) ? `${value.title.fr} ↔ ${value.reverseTitle.fr}` : ''
},
+
getPerson(idtext) {
let person = this.persons.filter(p => p.id === idtext)
return person[0]
@@ -439,8 +451,9 @@ export default {
console.log(' @@> switch listener to create link mode:', this.listenPersonFlag)
},
dropRelationship() {
- console.log('delete')
- deleteRelationship(relationship) /// param ?
+ console.log('delete', this.modal.data)
+ deleteRelationship(this.modal.data)
+ this.$store.commit('removeLink', this.modal.data.id)
this.modal.showModal = false
this.resetForm()
},
@@ -449,9 +462,7 @@ export default {
switch (this.modal.action) {
case 'create':
- return postRelationship(
- this.getPerson(this.modal.data.from), this.getPerson(this.modal.data.to), this.relation, this.reverse
- )
+ return postRelationship(this.modal.data)
.then(relationship => new Promise(resolve => {
console.log('post response', relationship)
this.$store.dispatch('addLinkFromRelationship', relationship)
@@ -462,10 +473,10 @@ export default {
.catch()
case 'edit':
- return patchRelationship(relationship)
+ return patchRelationship(this.modal.data)
.then(relationship => new Promise(resolve => {
console.log('patch relationship', relationship)
- this.$store.dispatch('updateLinkFromRelationship', relationship)
+ this.$store.commit('updateLink', relationship)
this.modal.showModal = false
this.resetForm()
resolve()
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 024486a07..2035c8e1e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -1,3 +1,5 @@
+import { splitId } from './vis-network'
+
/**
* @function makeFetch
* @param method
@@ -130,21 +132,19 @@ const getRelationsList = () => {
/**
* @function postRelationship
- * @param fromPerson
- * @param toPerson
- * @param relation
- * @param reverse
+ * @param relationship
* @returns {Promise}
*/
-const postRelationship = (fromPerson, toPerson, relation, reverse) => {
+const postRelationship = (relationship) => {
+ console.log(relationship)
return postFetch(
`/api/1.0/relations/relationship.json`,
{
type: 'relationship',
- fromPerson: { type: 'person', id: fromPerson._id },
- toPerson: { type: 'person', id: toPerson._id },
- relation: { type: 'relation', id: relation.id },
- reverse: reverse
+ fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
+ toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
+ relation: { type: 'relation', id: relationship.relation.id },
+ reverse: relationship.reverse
}
)
}
@@ -156,12 +156,14 @@ const postRelationship = (fromPerson, toPerson, relation, reverse) => {
*/
const patchRelationship = (relationship) => {
console.log(relationship)
+ let linkType = splitId(relationship.id, 'link')
+ let id = splitId(linkType, 'id')
return patchFetch(
- `/api/1.0/relations/relationship/${relationship.id}.json`,
+ `/api/1.0/relations/relationship/${id}.json`,
{
type: 'relationship',
- fromPerson: { type: 'person', id: relationship.fromPerson.id },
- toPerson: { type: 'person', id: relationship.toPerson.id },
+ fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
+ toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
relation: { type: 'relation', id: relationship.relation.id },
reverse: relationship.reverse
}
@@ -174,8 +176,11 @@ const patchRelationship = (relationship) => {
* @returns {Promise}
*/
const deleteRelationship = (relationship) => {
+ console.log(relationship)
+ let linkType = splitId(relationship.id, 'link')
+ let id = splitId(linkType, 'id')
return deleteFetch(
- `/api/1.0/relations/relationship/${relationship.id}.json`
+ `/api/1.0/relations/relationship/${id}.json`
)
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 98f188fdf..1cdd472d8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -160,6 +160,30 @@ const store = createStore({
addLink(state, link) {
state.links.push(link)
},
+ updateLink(state, link) {
+ console.log('updateLink', link)
+ let link_ = {
+ from: `person_${link.fromPerson.id}`,
+ to: `person_${link.toPerson.id}`,
+ id: 'relationship_' + splitId(link.id,'id')
+ + '-person_' + link.fromPerson.id + '-person_' + link.toPerson.id,
+ arrows: getRelationshipDirection(link),
+ color: 'lightblue',
+ font: { color: '#33839d' },
+ dashes: true,
+ label: getRelationshipLabel(link),
+ title: getRelationshipTitle(link),
+ relation: link.relation,
+ reverse: link.reverse
+ }
+ // find row position and replace by updatedLink
+ state.links.splice(
+ state.links.findIndex(item => item.id === link_.id), 1, link_
+ )
+ },
+ removeLink(state, link_id) {
+ state.links = state.links.filter(l => l.id !== link_id)
+ },
//// id markers
markInWhitelist(state, person) {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 011f83977..98ea88fb5 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -266,13 +266,12 @@ const getRelationshipTitle = (relationship) => {
* @param position
* @returns string|integer
*/
-const splitId = (id, position) => {
+const splitId = (id, position) => { console.log(id, position)
switch (position) {
case 'type': // return 'accompanying_period'
return /(.+)_/.exec(id)[1]
case 'id': // return 124
- return parseInt(id
- .toString()
+ return parseInt(id.toString()
.split("_")
.pop())
case 'link':
From bfca6d2afc549b73626666e925742e1efa44652f Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 9 Nov 2021 19:58:04 +0100
Subject: [PATCH 105/119] cleaning
---
.../Resources/public/vuejs/VisGraph/App.vue | 30 ++++---------------
.../Resources/public/vuejs/VisGraph/api.js | 6 ++--
.../Resources/public/vuejs/VisGraph/store.js | 7 ++---
.../public/vuejs/VisGraph/vis-network.js | 3 +-
4 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index d21f21446..312b5d722 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -82,10 +82,8 @@
-
+
@@ -108,10 +107,6 @@
>
{{ $t('visgraph.reverse_relation') }}
-
@@ -147,8 +142,6 @@ export default {
container: '',
checkedLayers: [],
relations: [],
- //relation: null,
- //reverse: false,
displayHelpMessage: false,
listenPersonFlag: 'normal',
newEdgeData: {},
@@ -218,9 +211,11 @@ export default {
return this.checkedLayers
},
+ /*
toggleIdPerson() {
-
+ console.log('toggleIdPerson')
},
+ */
relation: {
get() {
@@ -239,8 +234,6 @@ export default {
this.modal.data.reverse = value
}
},
- /*
- */
},
mounted() {
@@ -394,24 +387,13 @@ export default {
this.modal.data = edgeData
this.relation = this.modal.data.relation
this.reverse = this.modal.data.reverse
- console.log('==- editRelationshipModal', this.modal.data, this.relation, this.reverse)
+ console.log('==- editRelationshipModal', this.modal.data)
this.modal.action = 'edit'
this.modal.title = 'visgraph.edit_relationship_link'
this.modal.button.class = 'btn-edit'
this.modal.button.text = 'action.edit'
this.modal.showModal = true
},
- /*
- deleteRelationshipModal(edgeData) {
- this.modal.data = edgeData
- console.log('==- deleteRelationshipModal', edgeData)
- this.modal.action = 'delete'
- this.modal.title = 'visgraph.delete_relationship_link'
- this.modal.button.class = 'btn-delete'
- this.modal.button.text = 'action.delete'
- this.modal.showModal = true
- },
- */
resetForm() {
console.log('==- reset Form')
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
index 2035c8e1e..448ff6633 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js
@@ -136,7 +136,7 @@ const getRelationsList = () => {
* @returns {Promise}
*/
const postRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
return postFetch(
`/api/1.0/relations/relationship.json`,
{
@@ -155,7 +155,7 @@ const postRelationship = (relationship) => {
* @returns {Promise}
*/
const patchRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
let linkType = splitId(relationship.id, 'link')
let id = splitId(linkType, 'id')
return patchFetch(
@@ -176,7 +176,7 @@ const patchRelationship = (relationship) => {
* @returns {Promise}
*/
const deleteRelationship = (relationship) => {
- console.log(relationship)
+ //console.log(relationship)
let linkType = splitId(relationship.id, 'link')
let id = splitId(linkType, 'id')
return deleteFetch(
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
index 1cdd472d8..edde88f1f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js
@@ -71,7 +71,7 @@ const store = createStore({
//console.log(link.id, state.excludedNodesIds.indexOf(splitId(link.id, 'link')))
}
})
- console.log(array.length, array.map(i => i.id))
+ console.log('count links', array.length, array.map(i => i.id))
return array.length
},
@@ -120,9 +120,8 @@ const store = createStore({
mutations: {
addPerson(state, [person, options]) {
let debug = ''
- /// Debug mode ~ display person_id on visgraph
- // uncomment
- debug = `\nid ${person.id}`
+ /// Debug mode: uncomment to display person_id on visgraph
+ //debug = `\nid ${person.id}`
person.group = person.type
person._id = person.id
person.id = `person_${person.id}`
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
index 98ea88fb5..cf3dc1baa 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js
@@ -266,7 +266,8 @@ const getRelationshipTitle = (relationship) => {
* @param position
* @returns string|integer
*/
-const splitId = (id, position) => { console.log(id, position)
+const splitId = (id, position) => {
+ //console.log(id, position)
switch (position) {
case 'type': // return 'accompanying_period'
return /(.+)_/.exec(id)[1]
From a63e1321b0f7ac65e06676a77dc729e390e4a4e8 Mon Sep 17 00:00:00 2001
From: Mathieu Jaumotte
Date: Tue, 9 Nov 2021 22:48:29 +0100
Subject: [PATCH 106/119] cleaning
---
.../Resources/public/vuejs/VisGraph/App.vue | 60 ++++++++-----------
.../Resources/public/vuejs/VisGraph/store.js | 4 +-
.../public/vuejs/VisGraph/vis-network.js | 12 ++--
3 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
index 312b5d722..3cd3de56d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue
@@ -5,7 +5,7 @@