Skip to content
Snippets Groups Projects
Commit f78ca96a authored by DESPRES Damien's avatar DESPRES Damien
Browse files

fix #12560

parent 285391d6
No related branches found
No related tags found
No related merge requests found
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment