From bd2ee9ddc1a8d1c95504b0448afc516791ef6833 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 2 Nov 2021 09:49:47 +0100 Subject: [PATCH] visgraph: adding endpoint to get list of relations --- .../ChillPersonExtension.php | 23 ++++++++++++++++++- .../Entity/Relationships/Relation.php | 1 + .../Resources/public/vuejs/VisGraph/api.js | 11 ++++++++- .../ChillPersonBundle/chill.api.specs.yaml | 17 +++++++++++--- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 684813c76..ea23f2b4b 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -900,7 +900,28 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ] ], ] - ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class, + 'controller' => \Chill\PersonBundle\Controller\RelationshipApiController::class, + 'name' => 'relations', + 'base_path' => '/api/1.0/relations/relation', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ], + ], + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ] + ], + ] + ], ] ]); } diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php index 7628863fe..5334069a7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php +++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relation.php @@ -20,6 +20,7 @@ class Relation * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"read"}) */ private ?int $id = null; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js index 5533bd6ff..ed5d026aa 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/api.js @@ -110,6 +110,14 @@ const getRelationshipsByPerson = (person) => { `/api/1.0/relations/relationship/by-person/${person._id}.json`) } +/** + * Return list of relations + * @returns {Promise} + */ +const getRelationsList = () => { + return getFetch(`/api/1.0/relations/relation.json`) +} + /** * @function postRelationship * @param person @@ -132,5 +140,6 @@ export { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson, - postRelationship + getRelationsList, + postRelationship, } diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index ab55d052a..241febd36 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -307,7 +307,7 @@ components: - $ref: "#/components/schemas/RelationById" reverse: type: boolean - + paths: /1.0/person/person/{id}.json: @@ -1093,7 +1093,7 @@ paths: description: "OK" 400: description: "transition cannot be applyed" - + /1.0/person/accompanying-course/by-person/{person_id}.json: get: tags: @@ -1647,7 +1647,7 @@ paths: description: "OK" 400: description: "Bad Request" - + /1.0/relations/relationship.json: post: tags: @@ -1671,3 +1671,14 @@ paths: description: "Unauthorized" 422: description: "Invalid data: the data is a valid json, could be deserialized, but does not pass validation" + + /1.0/relations/relation.json: + get: + tags: + - relationships + summary: get a list of relations + responses: + 401: + description: "Unauthorized" + 200: + description: "OK"