From 582c7c0e48c3e400b283335033c4d160e75ebcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Thu, 30 Sep 2021 15:42:12 +0200 Subject: [PATCH] check for errors and display success message if ok --- src/store/modules/map.js | 1 - src/views/project/Project_mapping.vue | 28 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/store/modules/map.js b/src/store/modules/map.js index 416cc1ec..8ef4ebad 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -192,7 +192,6 @@ const map = { return axios .delete(url) .then((response) => { - console.log(response) if (response && response.status === 204) { commit("REMOVE_BASEMAP_ID_TO_DELETE", basemapId) return response diff --git a/src/views/project/Project_mapping.vue b/src/views/project/Project_mapping.vue index 7aabdaf5..94e6d856 100644 --- a/src/views/project/Project_mapping.vue +++ b/src/views/project/Project_mapping.vue @@ -96,24 +96,30 @@ export default { }, saveChanges() { - // ToDo : check if values are filled if (this.checkTitles()) { this.$store .dispatch("map/SAVE_BASEMAPS", this.newBasemapIds) - .then((res) => { - console.log("res", res); + .then((response) => { + const errors = response.filter( + (res) => res.status !== 200 && res.status !== 204 + ); + if (errors.length === 0) { + this.newBasemapIds = []; + this.infoMessage = "Enregistrement effectué."; + document + .getElementById("message_info") + .scrollIntoView({ block: "end", inline: "nearest" }); + setTimeout( + function () { + this.infoMessage = ""; + }.bind(this), + 5000 + ); + } }) .catch((error) => { console.log(error); }); - this.newBasemapIds = []; - this.infoMessage = "Enregistrement effectué."; - setTimeout( - function () { - this.infoMessage = ""; - }.bind(this), - 5000 - ); } }, }, -- GitLab