possible to add a contact to a thirdparty

This commit is contained in:
Julie Lenaerts 2022-01-19 10:57:31 +01:00
parent 724ce8c9af
commit 4431428c26
5 changed files with 25 additions and 16 deletions

View File

@ -212,10 +212,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 {
@ -229,7 +241,9 @@ export default {
}
// console.log('type', type, 'data', data)
// pass datas to parent
this.$emit('saveFormOnTheFly', { type: type, data: data });
if (this.action != 'addContact') {
this.$emit('saveFormOnTheFly', { type: type, data: data });
}
this.modal.showModal = false;
},

View File

@ -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;

View File

@ -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;

View File

@ -48,7 +48,6 @@
</div>
</div>
<div v-else>
<!-- <p>Contact de&nbsp;:</p> -->
<third-party-render-box
:thirdparty="thirdparty"
:options="{
@ -66,12 +65,8 @@
</div>
<div v-if="parent">
<!-- <div class="input-group mb-3">
<input type="hidden" name="parent_id" v-model="thirdparty.parent" :value="parent.id" />
</div> -->
<div id="child-info">
<div class="input-group mb-3">
<!-- <span class="input-group-text" id="comment"><i class="fa fa-fw fa-briefcase"></i></span> -->
<select class="form-select form-select-lg" id="profession"
v-model="thirdparty.civility">
<option selected disabled >{{ $t('thirdparty.civility') }}</option>
@ -79,7 +74,6 @@
</select>
</div>
<div class="input-group mb-3">
<!-- <span class="input-group-text" id="comment"><i class="fa fa-fw fa-user-circle-o"></i></span> -->
<select class="form-select form-select-lg" id="civility"
v-model="thirdparty.profession">
<option selected disabled >{{ $t('thirdparty.profession') }}</option>
@ -230,7 +224,7 @@ export default {
})
.catch((error) => {
console.log(error)
// this.$toast.open({message: error.body})
this.$toast.open({message: error.body})
})
},
loadProfessions() {
@ -241,7 +235,7 @@ export default {
})
.catch((error) => {
console.log(error)
// this.$toast.open({message: error.body})
this.$toast.open({message: error.body})
})
},
submitAddress(payload) {

View File

@ -45,6 +45,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
'isChild' => $thirdParty->isChild(),
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),
'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context),
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(),
];
}