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 a47658580..dec6fea68 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -100,6 +100,7 @@ import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue'; import OnTheFlyCreate from './Create.vue'; import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue'; import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue'; +import { postThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly"; export default { name: 'OnTheFly', @@ -219,16 +220,23 @@ export default { if (this.action === 'addContact') { type = 'thirdparty' data = this.$refs.castThirdparty.$data.thirdparty; - // console.log(data) + // create the new contact here, bypassing saveFormOnTheFly() -> not working here? + console.log('addContact data', data) + postThirdparty(data) + .then(thirdparty => new Promise((resolve, reject) => { + this.newPriorSuggestion(thirdparty); + resolve(); + })); } else { type = this.$refs.castNew.radioType; data = this.$refs.castNew.castDataByType(); + console.log(data) } } else { throw 'error with object type'; } } - console.log('type', type, 'data', data) + // console.log('type', type, 'data', data) // pass datas to parent this.$emit('saveFormOnTheFly', { type: type, data: data }); diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 97d18ae62..7404846e4 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", "read", "write", "docgen:read:3party:parent"}) + * @Groups({"docgen:read", "docgen:read:3party:parent"}) * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ private ?Civility $civility = null; @@ -166,7 +166,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) + * @Groups({"read", "docgen:read", "docgen:read:3party:parent"}) */ private ?int $id = 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({"read", "write", "docgen:read"}) + * @Groups({"docgen:read"}) * @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"}) */ private ?ThirdParty $parent = 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 7b25012dd..5299319fa 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -154,8 +154,7 @@ export default { return { //context: {}, <-- thirdparty: { - type: 'thirdparty', - parent: this.parent.id + type: 'thirdparty' }, professions: [], civilities: [], @@ -213,7 +212,7 @@ export default { getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => { this.thirdparty = thirdparty; this.thirdparty.kind = thirdparty.kind; - //console.log('get thirdparty', thirdparty); + console.log('get thirdparty', thirdparty); if (this.action !== 'show') { if (thirdparty.address !== null) { // bof! we force getInitialAddress because addressId not available when mounted @@ -262,6 +261,9 @@ export default { this.loadData(); } if (this.action === 'addContact') { + this.$data.thirdparty.kind = 'child' + // this.$data.thirdparty.parent = this.parent.id + this.$data.thirdparty.address = null this.loadProfessions(); this.loadCivilities(); }