From 0f2cbbe553e0ee145b3fad09d48e25b0b1e04a67 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 24 Jan 2022 14:24:56 +0100 Subject: [PATCH] bugfix emit saveFormOnTheFly and add newly created contact to suggestion list immediately --- .../public/vuejs/OnTheFly/components/OnTheFly.vue | 8 +------- .../Resources/public/vuejs/_components/AddPersons.vue | 11 ++++++----- .../vuejs/_components/AddPersons/PersonSuggestion.vue | 6 +++++- .../vuejs/_components/AddPersons/TypeThirdParty.vue | 7 +++++++ 4 files changed, 19 insertions(+), 13 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 a456637da..304b7c5a9 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -212,7 +212,7 @@ export default { type = 'thirdparty' data = this.$refs.castThirdparty.$data.thirdparty; // create the new contact here, bypassing saveFormOnTheFly() -> not working here? - const body = { + data = { "type": "thirdparty", "kind": "child", "name": data.text, @@ -225,12 +225,6 @@ export default { "email": data.email, "address": null } - postThirdparty(body) - .then(thirdparty => new Promise((resolve, reject) => { - // this.$parent.newPriorSuggestion(thirdparty); - console.log('thirdparty created', thirdparty) - resolve(); - })); } else { type = this.$refs.castNew.radioType; data = this.$refs.castNew.castDataByType(); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index f118671ed..4dd9670f9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -60,6 +60,7 @@ v-bind:item="item" v-bind:search="search" v-bind:type="checkUniq" + @saveFormOnTheFly="saveFormOnTheFly" @updateSelected="updateSelected"> @@ -259,15 +260,15 @@ export default { result: entity } this.search.priorSuggestion = suggestion; - console.log('search priorSuggestion', this.search.priorSuggestion); + // console.log('search priorSuggestion', this.search.priorSuggestion); } else { this.search.priorSuggestion = {}; } }, saveFormOnTheFly({ type, data }) { - console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); + // console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); if (type === 'person') { - console.log('type person with', data); + // console.log('type person with', data); postPerson(data) .then(person => new Promise((resolve, reject) => { console.log('onthefly create: post person', person); @@ -276,10 +277,10 @@ export default { })); } else if (type === 'thirdparty') { - console.log('type thirdparty with', data); + // console.log('type thirdparty with', data); postThirdparty(data) .then(thirdparty => new Promise((resolve, reject) => { - console.log('onthefly create: post thirdparty', thirdparty); + // console.log('onthefly create: post thirdparty', thirdparty); this.newPriorSuggestion(thirdparty); resolve(); })); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue index ce2f52a50..4894e1d8b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/PersonSuggestion.vue @@ -18,6 +18,7 @@ @@ -47,7 +48,7 @@ export default { 'search', 'type' ], - emits: ['updateSelected'], + emits: ['updateSelected', 'saveFormOnTheFly'], computed: { selected: { set(value) { @@ -65,6 +66,9 @@ export default { methods: { setValueByType(value, type) { return (type === 'radio')? [value] : value; + }, + emitEvent({data, type}) { + this.$emit('saveFormOnTheFly', {type: type, data: data}) } } }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue index 77a241339..cb9d4ae29 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue @@ -25,6 +25,7 @@