diff --git a/CHANGELOG.md b/CHANGELOG.md
index c98d7db27..8256536da 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -65,6 +65,14 @@ and this project adheres to
* [person suggest] In widget "add person", improve the pertinence of persons when one of the names starts with the pattern;
* [person] do not ask for center any more on person creation
* [3party] do not ask for center any more on 3party creation
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+* [validation] toasts are displayed for errors when modifying accompanying course (generalization required).
+>>>>>>> 16b59681 (changelog updated)
+=======
+* [validation] toasts are displayed for errors when modifying accompanying course (generalization required).
+>>>>>>> b8889ed58d3abb68d1c2859b31bf7428addda36e
## Test releases
diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js
new file mode 100644
index 000000000..5b49ba546
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js
@@ -0,0 +1,106 @@
+/**
+ * Generic api method that can be adapted to any fetch request
+ */
+ const makeFetch = (method, url, body) => {
+ return fetch(url, {
+ method: method,
+ headers: {
+ 'Content-Type': 'application/json;charset=utf-8'
+ },
+ body: (body !== null) ? JSON.stringify(body) : null
+ })
+ .then(response => {
+
+ if (response.ok) {
+ return response.json();
+ }
+
+ if (response.status === 422) {
+ return response.json().then(response => {
+ throw ValidationException(response)
+ });
+ }
+
+ if (response.status === 403) {
+ return response.json().then(() => {
+ throw AccessException();
+ });
+ }
+
+ throw {
+ name: 'Exception',
+ sta: response.status,
+ txt: response.statusText,
+ err: new Error(),
+ violations: response.body
+ };
+ });
+}
+
+/**
+ * Fetch results with certain parameters
+ */
+const _fetchAction = (page, uri, params) => {
+ const item_per_page = 50;
+ if (params === undefined) {
+ params = {};
+ }
+ let url = uri + '?' + new URLSearchParams({ item_per_page, page, ...params });
+
+ return fetch(url, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json;charset=utf-8'
+ },
+ }).then(response => {
+ if (response.ok) { return response.json(); }
+ throw Error({ m: response.statusText });
+ });
+};
+
+const fetchResults = async (uri, params) => {
+ let promises = [],
+ page = 1;
+ let firstData = await _fetchAction(page, uri, params);
+
+ promises.push(Promise.resolve(firstData.results));
+
+ if (firstData.pagination.more) {
+ do {
+ page = ++page;
+ promises.push(_fetchAction(page, uri, params).then(r => Promise.resolve(r.results)));
+ } while (page * firstData.pagination.items_per_page < firstData.count)
+ }
+
+ return Promise.all(promises).then(values => values.flat());
+};
+
+const fetchScopes = () => {
+ return fetchResults('/api/1.0/main/scope.json');
+};
+
+
+/**
+ * Error objects to be thrown
+ */
+const ValidationException = (response) => {
+ const error = {};
+ error.name = 'ValidationException';
+ error.violations = response.violations.map((violation) => `${violation.title}`);
+
+ return error;
+}
+
+const AccessException = () => {
+ const error = {};
+ error.name = 'AccessException';
+ error.violations = ['You are no longer permitted to perform this action'];
+
+ return error;
+}
+
+export {
+ makeFetch,
+ fetchResults,
+ fetchScopes
+}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/download.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/download.js
index 625103ebe..dec8ba727 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/download.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/download.js
@@ -1,39 +1,39 @@
-const _fetchAction = (page, uri, params) => {
- const item_per_page = 50;
- if (params === undefined) {
- params = {};
- }
- let url = uri + '?' + new URLSearchParams({ item_per_page, page, ...params });
+// const _fetchAction = (page, uri, params) => {
+// const item_per_page = 50;
+// if (params === undefined) {
+// params = {};
+// }
+// let url = uri + '?' + new URLSearchParams({ item_per_page, page, ...params });
- return fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- }).then(response => {
- if (response.ok) { return response.json(); }
- throw Error({ m: response.statusText });
- });
-};
+// return fetch(url, {
+// method: 'GET',
+// headers: {
+// 'Content-Type': 'application/json;charset=utf-8'
+// },
+// }).then(response => {
+// if (response.ok) { return response.json(); }
+// throw Error({ m: response.statusText });
+// });
+// };
-const fetchResults = async (uri, params) => {
- let promises = [],
- page = 1;
- let firstData = await _fetchAction(page, uri, params);
+// const fetchResults = async (uri, params) => {
+// let promises = [],
+// page = 1;
+// let firstData = await _fetchAction(page, uri, params);
- promises.push(Promise.resolve(firstData.results));
+// promises.push(Promise.resolve(firstData.results));
- if (firstData.pagination.more) {
- do {
- page = ++page;
- promises.push(_fetchAction(page, uri, params).then(r => Promise.resolve(r.results)));
- } while (page * firstData.pagination.items_per_page < firstData.count)
- }
+// if (firstData.pagination.more) {
+// do {
+// page = ++page;
+// promises.push(_fetchAction(page, uri, params).then(r => Promise.resolve(r.results)));
+// } while (page * firstData.pagination.items_per_page < firstData.count)
+// }
- return Promise.all(promises).then(values => values.flat());
-};
+// return Promise.all(promises).then(values => values.flat());
+// };
-export {
- fetchResults
-};
+// export {
+// fetchResults
+// };
diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/scope.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/scope.js
index 4c4223d77..a155c84a2 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/scope.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/scope.js
@@ -1,9 +1,9 @@
-import { fetchResults } from 'ChillMainAssets/lib/api/download.js';
+// import { fetchResults } from 'ChillMainAssets/lib/api/download.js';
-const fetchScopes = () => {
- return fetchResults('/api/1.0/main/scope.json');
-};
+// const fetchScopes = () => {
+// return fetchResults('/api/1.0/main/scope.json');
+// };
-export {
- fetchScopes
-};
+// export {
+// fetchScopes
+// };
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Confidential.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Confidential.vue
index 5fe040e14..efdf62926 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Confidential.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Confidential.vue
@@ -13,7 +13,6 @@ export default {
methods : {
toggleBlur: function(e){
if(e.target.matches('.toggle')){
- console.log(e);
e.target.previousElementSibling.classList.toggle("blur");
e.target.classList.toggle("fa-eye");
e.target.classList.toggle("fa-eye-slash");
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index 958d7d58b..6b0c5d768 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -277,7 +277,7 @@ class AccompanyingPeriod implements
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
* )
* @Groups({"read"})
- * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
+ * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope")
*/
private $scopes;
@@ -289,7 +289,7 @@ class AccompanyingPeriod implements
* name="chill_person_accompanying_period_social_issues"
* )
* @Groups({"read"})
- * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
+ * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must contains at least one social issue")
*/
private Collection $socialIssues;
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/lib/household.js b/src/Bundle/ChillPersonBundle/Resources/public/lib/household.js
index 52754fa97..c96694dcb 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/lib/household.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/lib/household.js
@@ -1,4 +1,4 @@
-import { fetchResults } from 'ChillMainAssets/lib/api/download.js';
+import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.js';
const fetchHouseholdByAddressReference = async (reference) => {
const url = `/api/1.0/person/household/by-address-reference/${reference.id}.json`
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
index c559ae56e..30a8bbf2a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue
@@ -59,7 +59,7 @@ export default {
'accompanyingCourse',
'addressContext'
]),
- },
+ }
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
index c372ac7a7..4eb6f2a33 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
@@ -1,4 +1,4 @@
-import { fetchResults } from 'ChillMainAssets/lib/api/download.js';
+import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.js';
/*
* Endpoint v.2 chill_api_single_accompanying_course__entity
@@ -15,44 +15,17 @@ const getAccompanyingCourse = (id) => {
});
};
-/*
-* Endpoint v.2 chill_api_single_accompanying_course__entity
-* method PATCH, patch AccompanyingCourse Instance
-*
-* @id integer - id of accompanyingCourse
-* @body Object - dictionary with changes to post
-*/
-const patchAccompanyingCourse = (id, body) => {
- //console.log('body', body);
- const url = `/api/1.0/person/accompanying-course/${id}.json`;
- return fetch(url, {
- method: 'PATCH',
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- body: JSON.stringify(body)
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- console.log(response);
- throw { msg: 'Error while updating AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
+const getUsers = () => {
+ const url = `/api/1.0/main/user.json`;
+
+ return fetchResults(url);
};
-/*
-* Endpoint to change 'DRAFT' step to 'CONFIRMED'
-*/
-const confirmAccompanyingCourse = (id) => {
- const url = `/api/1.0/person/accompanying-course/${id}/confirm.json`
- return fetch(url, {
- method: 'POST',
- headers: {'Content-Type': 'application/json;charset=utf-8'}
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while confirming AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
+const getReferrersSuggested = (course) => {
+ const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
+
+ return fetchResults(url);
+}
/*
* Endpoint
@@ -66,115 +39,6 @@ const getSocialIssues = () => {
});
};
-/*
-* Endpoint v.2 chill_api_single_accompanying_course_participation,
-* method POST/DELETE, add/close a participation to the accompanyingCourse
-*
-* @id integer - id of accompanyingCourse
-* @payload integer - id of person
-* @method string - POST or DELETE
-*/
-const postParticipation = (id, payload, method) => {
- const body = { type: payload.type, id: payload.id };
- const url = `/api/1.0/person/accompanying-course/${id}/participation.json`;
- return fetch(url, {
- method: method,
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- body: JSON.stringify(body)
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- // TODO: adjust message according to status code? Or how to access the message from the violation array?
- throw { msg: 'Error while sending AccompanyingPeriod Course participation', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-/*
-* Endpoint v.2 chill_api_single_accompanying_course_requestor,
-* method POST/DELETE, add/close a requestor to the accompanyingCourse
-*
-* @id integer - id of accompanyingCourse
-* @payload object of type person|thirdparty
-* @method string - POST or DELETE
-*/
-const postRequestor = (id, payload, method) => {
- //console.log('payload', payload);
- const body = (payload)? { type: payload.type, id: payload.id } : {};
- //console.log('body', body);
- const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`;
- return fetch(url, {
- method: method,
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- body: JSON.stringify(body)
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while sending AccompanyingPeriod Course requestor', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-/*
-* Endpoint v.2 chill_api_single_accompanying_course_resource,
-* method POST/DELETE, add/remove a resource to the accompanyingCourse
-*
-* @id integer - id of accompanyingCourse
-* @payload object of type person|thirdparty
-* @method string - POST or DELETE
-*/
-const postResource = (id, payload, method) => {
- //console.log('payload', payload);
- const body = { type: "accompanying_period_resource" };
- switch (method) {
- case 'DELETE':
- body['id'] = payload.id;
- break;
- default:
- body['resource'] = { type: payload.type, id: payload.id };
- }
- //console.log('body', body);
- const url = `/api/1.0/person/accompanying-course/${id}/resource.json`;
- return fetch(url, {
- method: method,
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- body: JSON.stringify(body)
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while sending AccompanyingPeriod Course resource.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-/*
-* Endpoint to Add/remove SocialIssue
-*/
-const postSocialIssue = (id, body, method) => {
- //console.log('api body and method', body, method);
- const url = `/api/1.0/person/accompanying-course/${id}/socialissue.json`;
- return fetch(url, {
- method: method,
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- body: JSON.stringify(body)
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while updating SocialIssue.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-const getUsers = () => {
- const url = `/api/1.0/main/user.json`;
-
- return fetchResults(url);
-};
-
const whoami = () => {
const url = `/api/1.0/main/whoami.json`;
return fetch(url)
@@ -184,74 +48,10 @@ const whoami = () => {
});
};
-const getListOrigins = () => {
- const url = `/api/1.0/person/accompanying-period/origin.json`;
- return fetch(url)
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while retriving origin\'s list.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-const addScope = (id, scope) => {
- const url = `/api/1.0/person/accompanying-course/${id}/scope.json`;
- console.log(url);
- console.log(scope);
-
- return fetch(url, {
- method: 'POST',
- body: JSON.stringify({
- id: scope.id,
- type: scope.type,
- }),
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while adding scope', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-const removeScope = (id, scope) => {
- const url = `/api/1.0/person/accompanying-course/${id}/scope.json`;
-
- return fetch(url, {
- method: 'DELETE',
- body: JSON.stringify({
- id: scope.id,
- type: scope.type,
- }),
- headers: {
- 'Content-Type': 'application/json;charset=utf-8'
- },
- })
- .then(response => {
- if (response.ok) { return response.json(); }
- throw { msg: 'Error while adding scope', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
- });
-};
-
-const getReferrersSuggested = (course) => {
- const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
-
- return fetchResults(url);
-}
-
export {
- getAccompanyingCourse,
- patchAccompanyingCourse,
- confirmAccompanyingCourse,
- getSocialIssues,
- postParticipation,
- postRequestor,
- postResource,
- getUsers,
whoami,
- getListOrigins,
- postSocialIssue,
- addScope,
- removeScope,
+ getSocialIssues,
+ getAccompanyingCourse,
+ getUsers,
getReferrersSuggested,
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
index fca3cee20..459e5e758 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue
@@ -53,13 +53,34 @@ export default {
//temporaire (modif backend)
value = "occasional";
}
- this.$store.dispatch('toggleIntensity', value);
+ this.$store.dispatch('toggleIntensity', value)
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
},
toggleEmergency() {
- this.$store.dispatch('toggleEmergency', (!this.isEmergency));
+ this.$store.dispatch('toggleEmergency', (!this.isEmergency))
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
},
toggleConfidential() {
- this.$store.dispatch('toggleConfidential', (!this.isConfidential));
+ this.$store.dispatch('toggleConfidential', (!this.isConfidential))
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue
index b9e52f300..344119c44 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue
@@ -59,7 +59,15 @@ export default {
locationStatusTo: 'person',
personId: this.person.id
};
- this.$store.dispatch('updateLocation', payload);
+ this.$store.dispatch('updateLocation', 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'})
+ }
+ });
+
window.location.assign('#section-20');
this.modal.showModal = false;
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue
index 1bff3f44d..7f5b04f99 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue
@@ -83,12 +83,24 @@ export default {
},
methods: {
submitform() {
- //console.log('submit');
- this.$store.dispatch('postFirstComment', this.formdata);
+ this.$store.dispatch('postFirstComment', this.formdata)
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
},
removeComment() {
- //console.log('remove');
- this.$store.dispatch('postFirstComment', {});
+ this.$store.dispatch('postFirstComment', {})
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
index 4142b4f50..d3e0ae4d7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
@@ -115,9 +115,14 @@ export default {
},
methods: {
confirmCourse() {
- //console.log('@@ CLICK confirmCourse');
- this.$store.dispatch('confirmAccompanyingCourse');
- //console.log('confirm last');
+ this.$store.dispatch('confirmAccompanyingCourse')
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
}
}
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue
index 79e983301..ae85af6a9 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue
@@ -187,7 +187,14 @@ export default {
locationStatusTo: 'none'
};
//console.log('remove address');
- this.$store.dispatch('updateLocation', payload);
+ this.$store.dispatch('updateLocation', 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'})
+ }
+ });
},
displayErrors() {
return this.$refs.addAddress.errorMsg;
@@ -195,7 +202,15 @@ export default {
submitTemporaryAddress(payload) {
//console.log('@@@ click on Submit Temporary Address Button', payload);
payload['locationStatusTo'] = 'address'; // <== temporary, not none, not person
- this.$store.dispatch('updateLocation', payload);
+ this.$store.dispatch('updateLocation', 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'})
+ }
+ });
+
this.$store.commit('setEditContextTrue', payload);
}
},
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
index b88bf0747..ee5ad469a 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
@@ -29,7 +29,7 @@
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/SocialIssue.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/SocialIssue.vue
index 41fd85f0e..5046e641d 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/SocialIssue.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/SocialIssue.vue
@@ -30,7 +30,7 @@