From 20d22b726c1696331e47137354d9064adad0df72 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 19 Jan 2022 10:57:31 +0100 Subject: [PATCH] possible to add a contact to a thirdparty --- .../vuejs/OnTheFly/components/OnTheFly.vue | 18 +++++++++++++++--- .../Entity/ThirdParty.php | 6 +++--- .../Entity/ThirdPartyProfession.php | 2 +- .../vuejs/_components/OnTheFly/ThirdParty.vue | 10 ++-------- .../Normalizer/ThirdPartyNormalizer.php | 1 + 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index b65a2c26b..531d4f739 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -218,10 +218,22 @@ export default { type = 'thirdparty' data = this.$refs.castThirdparty.$data.thirdparty; // create the new contact here, bypassing saveFormOnTheFly() -> not working here? - console.log('addContact data', data) - postThirdparty(data) + const body = { + "type": "thirdparty", + "kind": "child", + "name": data.text, + "isChild": true, + "parent": {"type": "thirdparty", "id": this.parent.id}, + "civility": {"id": data.civility}, + "profession": {"id": data.profession}, + "comment": data.comment, + "phonenumber": data.phonenumber, + } + // console.log('body', body) + postThirdparty(body) .then(thirdparty => new Promise((resolve, reject) => { - this.newPriorSuggestion(thirdparty); + // this.newPriorSuggestion(thirdparty); + console.log('thirdparty created', thirdparty) resolve(); })); } else { diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 7404846e4..5679ea1f2 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -126,7 +126,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @var Civility * @ORM\ManyToOne(targetEntity=Civility::class) * ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true) - * @Groups({"docgen:read", "docgen:read:3party:parent"}) + * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ private ?Civility $civility = null; @@ -199,7 +199,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children") * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - * @Groups({"docgen:read"}) + * @Groups({"read", "write", "docgen:read"}) * @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"}) */ private ?ThirdParty $parent = null; @@ -210,7 +210,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @var ThirdPartyProfession * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession") * ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true) - * @Groups({"docgen:read", "docgen:read:3party:parent"}) + * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ private ?ThirdPartyProfession $profession = null; diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php index bf10c7cf1..12b0818b5 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php @@ -31,7 +31,7 @@ class ThirdPartyProfession * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") - * @Serializer\Groups({"docgen:read", "read"}) + * @Serializer\Groups({"docgen:read", "read", "write"}) */ private ?int $id = null; diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 5299319fa..4b7bade24 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -48,7 +48,6 @@
- -
-
-