diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index cf87d50e56980912ecd3737fd11667eae63c8470..309f641b47d5ec1aaf6ffaaee4dd250cf8401c22 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -580,6 +580,7 @@ export default { return { infoMessage: "", arraysOffline: [], + arraysOfflineErrors: [], geojsonImport: [], fileToImport: { name: "", size: 0 }, slug: this.$route.params.slug, @@ -629,20 +630,25 @@ export default { sendOfflineFeatures() { var promises = []; - this.arraysOffline.forEach((feature, index, object) => { + let self = this; + this.arraysOfflineErrors = []; + this.arraysOffline.forEach((feature) => { console.log(feature); if (feature.type === "post") { promises.push( axios .post(`${this.API_BASE_URL}features/`, feature.geojson) .then((response) => { - console.log(response); if (response.status === 201 && response.data) { - object.splice(index, 1); + return "OK" + } + else{ + self.arraysOfflineErrors.push(feature); } }) .catch((error) => { console.log(error); + self.arraysOfflineErrors.push(feature); }) ); } else if (feature.type === "put") { @@ -655,11 +661,15 @@ export default { .then((response) => { console.log(response); if (response.status === 200 && response.data) { - object.splice(index, 1); + return "OK" + } + else{ + self.arraysOfflineErrors.push(feature); } }) .catch((error) => { console.log(error); + self.arraysOfflineErrors.push(feature); }) ); } @@ -679,12 +689,12 @@ export default { let arraysOfflineOtherProject = arraysOffline.filter( (x) => x.project !== this.project.slug ); - arraysOffline = arraysOfflineOtherProject.concat(this.arraysOffline); + this.arraysOffline = []; + arraysOffline = arraysOfflineOtherProject.concat(this.arraysOfflineErrors); localStorage.setItem("geocontrib_offline", JSON.stringify(arraysOffline)); }, toNewFeatureType() { - console.log('prout'); this.featureTypeImporting = true; this.$router.push({ name: "ajouter-type-signalement",