diff --git a/CHANGELOG.md b/CHANGELOG.md
index abd12d439..277711c0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,12 @@ and this project adheres to
## Unreleased
+* [person] accompanying course work: fix on-the-fly update of thirdParty
+* [on-the-fly] close modal only after validation
+* [person] correct thirdparty PATCH url + add email and altnames in AddPerson and serializer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/433)
+
+
+
* renommer "dossier numéro" en "parcours numéro" dans les résultats de recherche
* renomme date de début en date d'ouverture dans le formulaire parcours
* [homepage widget] improve content tables, improve counter pluralization with style on number
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 ceb264072..2daece725 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue
@@ -101,7 +101,7 @@ export default {
OnTheFlyThirdparty,
OnTheFlyCreate
},
- props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent', 'canCloseModal'],
+ props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent'],
emits: ['saveFormOnTheFly'],
data() {
return {
@@ -179,16 +179,6 @@ export default {
return 'entity-' + this.type + ' badge-' + this.type;
}
},
- watch: {
- canCloseModal: {
- handler: function(val, oldVal) {
- if (val) {
- this.closeModal();
- }
- },
- deep: true
- }
- },
methods: {
closeModal() {
this.modal.showModal = false;
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 2ed08ffc0..c9c7136c5 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
@@ -28,7 +28,7 @@
-
+
@@ -82,7 +82,7 @@
:id="resource.resource.id"
action="edit"
@saveFormOnTheFly="saveFormOnTheFly"
- :canCloseModal="canCloseOnTheFlyModal">
+ ref="onTheFly">
@@ -116,11 +116,6 @@ export default {
},
props: ['resource'],
emits: ['remove'],
- data() {
- return {
- canCloseOnTheFlyModal: false
- }
- },
computed: {
parent() {
return {
@@ -152,12 +147,14 @@ export default {
if (payload.data.birthdate !== null) { body.birthdate = payload.data.birthdate; }
body.phonenumber = payload.data.phonenumber;
body.mobilenumber = payload.data.mobilenumber;
+ body.email = payload.data.email;
+ body.altNames = payload.data.altNames;
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;
+ this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@@ -175,10 +172,10 @@ export default {
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)
+ makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
.then(response => {
this.$store.dispatch('addThirdparty', { target: payload.target, body: response })
- this.canCloseOnTheFlyModal = true;
+ this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
index f9d1a747c..34c0794fb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue
@@ -211,7 +211,7 @@
-
+
-
@@ -286,6 +286,8 @@ import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
+import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
+
const i18n = {
messages: {
@@ -476,15 +478,27 @@ export default {
},
saveFormOnTheFly(payload) {
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
- payload.target = 'resource';
- this.$store.dispatch('patchOnTheFly', payload)
- .catch(({name, violations}) => {
- if (name === 'ValidationException' || name === 'AccessException') {
- violations.forEach((violation) => this.$toast.open({message: violation}));
+
+ let body = { type: payload.type };
+ 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/thirdparty/thirdparty/${payload.data.id}.json`, body)
+ .then(response => {
+ this.$store.dispatch('updateThirdParty', response)
+ this.$refs.onTheFly.closeModal();
+ })
+ .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'})
+ this.$toast.open({message: 'An error occurred'});
}
- });
+ })
}
}
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js
index 0ef2d0de4..143d34215 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js
@@ -1,7 +1,9 @@
import { createApp } from 'vue';
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
import { store } from './store';
-import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
+import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
+import VueToast from 'vue-toast-notification';
+import 'vue-toast-notification/dist/theme-sugar.css';
import App from './App.vue';
const i18n = _createI18n(personMessages);
@@ -10,6 +12,12 @@ const app = createApp({
template: ``,
})
.use(store)
+.use(VueToast, {
+ position: "bottom-right",
+ type: "error",
+ duration: 5000,
+ dismissible: true
+})
.use(i18n)
.component('app', App)
.mount('#accompanying_course_work_edit');
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
index 0cc85fb76..6c81748d2 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js
@@ -266,6 +266,14 @@ const store = createStore({
state.thirdParties.push(unexistings[i]);
}
},
+ updateThirdParty(state, thirdParty) {
+ for (let t of state.thirdParties) {
+ if (t.id === thirdParty.id){
+ state.thirdParties = state.thirdParties.filter(t => t.id !== thirdParty.id);
+ state.thirdParties.push(thirdParty);
+ }
+ }
+ },
removeThirdParty(state, thirdParty) {
state.thirdParties = state.thirdParties
.filter(t => t.id !== thirdParty.id);
@@ -278,6 +286,10 @@ const store = createStore({
},
},
actions: {
+ updateThirdParty({ commit }, payload) {
+ console.log(payload);
+ commit('updateThirdParty', payload);
+ },
getReachablesGoalsForAction({ getters, commit, dispatch }) {
let
socialActionId = getters.socialAction.id,
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
index c265b457b..2dfd7861d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue
@@ -70,7 +70,7 @@
:buttonText="$t('onthefly.create.button', {q: query})"
action="create"
@saveFormOnTheFly="saveFormOnTheFly"
- :canCloseModal="canCloseOnTheFlyModal">
+ ref="onTheFly">
@@ -122,7 +122,6 @@ export default {
selected: [],
priorSuggestion: {}
},
- canCloseOnTheFlyModal: false
}
},
computed: {
@@ -272,7 +271,7 @@ export default {
makeFetch('POST', '/api/1.0/person/person.json', data)
.then(response => {
this.newPriorSuggestion(response);
- this.canCloseOnTheFlyModal = true;
+ this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@@ -288,7 +287,7 @@ export default {
makeFetch('POST', '/api/1.0/thirdparty/thirdparty.json', data)
.then(response => {
this.newPriorSuggestion(response);
- this.canCloseOnTheFlyModal = true;
+ this.$refs.onTheFly.closeModal();
})
.catch((error) => {
if (error.name === 'ValidationException') {
@@ -300,7 +299,6 @@ export default {
}
})
}
- this.canCloseOnTheFlyModal = false;
}
},
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
index 9543da3bb..0e511ce5e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue
@@ -43,10 +43,11 @@
-