diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
index 584b32bfd..2ed08ffc0 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue
@@ -63,6 +63,7 @@ import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
import ButtonLocation from '../ButtonLocation.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
+import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
export default {
name: 'ParticipationItem',
@@ -111,17 +112,53 @@ export default {
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'participation';
- this.$store.dispatch('patchOnTheFly', payload)
- .then(response => {
- this.canCloseOnTheFlyModal = true;
- })
- .catch(({name, violations}) => {
- if (name === 'ValidationException' || name === 'AccessException') {
- violations.forEach((violation) => this.$toast.open({message: violation}));
- } else {
- this.$toast.open({message: 'An error occurred'})
- }
- });
+
+ let body = { type: payload.type };
+ if (payload.type === 'person') {
+ body.firstName = payload.data.firstName;
+ body.lastName = payload.data.lastName;
+ if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
+ body.phonenumber = payload.data.phonenumber;
+ body.mobilenumber = payload.data.mobilenumber;
+ body.gender = payload.data.gender;
+
+ makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
+ .then(response => {
+ this.$store.dispatch('addPerson', { target: payload.target, body: response })
+ this.canCloseOnTheFlyModal = true;
+ })
+ .catch((error) => {
+ if (error.name === 'ValidationException') {
+ for (let v of error.violations) {
+ this.$toast.open({message: v });
+ }
+ } else {
+ this.$toast.open({message: 'An error occurred'});
+ }
+ })
+ }
+ else if (payload.type === 'thirdparty') {
+ body.name = payload.data.text;
+ body.email = payload.data.email;
+ body.telephone = payload.data.phonenumber;
+ body.address = { id: payload.data.address.address_id };
+
+ makeFetch('PATCH', `/api/1.0/third-party/third-party/${payload.data.id}.json`, body)
+ .then(response => {
+ this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
+ this.canCloseOnTheFlyModal = true;
+ })
+ .catch((error) => {
+ if (error.name === 'ValidationException') {
+ for (let v of error.violations) {
+ this.$toast.open({message: v });
+ }
+ } else {
+ this.$toast.open({message: 'An error occurred'});
+ }
+ })
+ }
+
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue
index a5d6791fb..8482ea01f 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue
@@ -113,7 +113,7 @@
@@ -162,6 +162,7 @@ import PersonRenderBox from '../../_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import { mapState } from 'vuex';
+import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
export default {
name: 'Requestor',
@@ -182,7 +183,8 @@ export default {
priority: null,
uniq: true,
}
- }
+ },
+ canCloseOnTheFlyModal: false
}
},
computed: {
@@ -246,14 +248,52 @@ export default {
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
payload.target = 'requestor';
- this.$store.dispatch('patchOnTheFly', payload)
- .catch(({name, violations}) => {
- if (name === 'ValidationException' || name === 'AccessException') {
- violations.forEach((violation) => this.$toast.open({message: violation}));
- } else {
- this.$toast.open({message: 'An error occurred'})
- }
- });
+
+ let body = { type: payload.type };
+ if (payload.type === 'person') {
+ body.firstName = payload.data.firstName;
+ body.lastName = payload.data.lastName;
+ if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
+ body.phonenumber = payload.data.phonenumber;
+ body.mobilenumber = payload.data.mobilenumber;
+ body.gender = payload.data.gender;
+
+ makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
+ .then(response => {
+ this.$store.dispatch('addPerson', { target: payload.target, body: response })
+ this.canCloseOnTheFlyModal = true;
+ })
+ .catch((error) => {
+ if (error.name === 'ValidationException') {
+ for (let v of error.violations) {
+ this.$toast.open({message: v });
+ }
+ } else {
+ this.$toast.open({message: 'An error occurred'});
+ }
+ })
+ }
+ else if (payload.type === 'thirdparty') {
+ body.name = payload.data.text;
+ body.email = payload.data.email;
+ body.telephone = payload.data.phonenumber;
+ body.address = { id: payload.data.address.address_id };
+
+ makeFetch('PATCH', `/api/1.0/third-party/third-party/${payload.data.id}.json`, body)
+ .then(response => {
+ this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
+ this.canCloseOnTheFlyModal = true;
+ })
+ .catch((error) => {
+ if (error.name === 'ValidationException') {
+ for (let v of error.violations) {
+ this.$toast.open({message: v });
+ }
+ } else {
+ this.$toast.open({message: 'An error occurred'});
+ }
+ })
+ }
},
addSuggestedEntity(e) {
this.$store.dispatch('addRequestor', { result: e, type: e.type })
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
index e7bc18371..102dcf741 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue
@@ -34,7 +34,8 @@
:type="resource.resource.type"
:id="resource.resource.id"
action="edit"
- @saveFormOnTheFly="saveFormOnTheFly">
+ @saveFormOnTheFly="saveFormOnTheFly"
+ :canCloseModal="canCloseOnTheFlyModal">