Skip to content
Snippets Groups Projects
Commit 8802d017 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

fix features import in projects without moderation(undefined value without error log)

parent 9bdff72b
No related branches found
No related tags found
2 merge requests!295Version 3.0.0,!233REDMINE_ISSUE-12378
This commit is part of merge request !233. Comments created here will be created in the context of that merge request.
......@@ -167,13 +167,12 @@ const feature_type = {
let { feature_type_slug, geojson } = payload;
//* check if geojson then build a file
if(!geojson && !state.fileToImport && state.fileToImport.size === 0 ) return
let formData = new FormData();
let fileToImport;
const {name, type} = geojson || state.fileToImport;
if (!rootGetters.project.moderation) {
if (state.fileToImport.size > 0) { //* if data in a binary file, read it as text
if (state.fileToImport && state.fileToImport.size > 0) { //* if data in a binary file, read it as text
const textFile = await state.fileToImport.text();
geojson = JSON.parse(textFile);
}
......@@ -183,7 +182,7 @@ const feature_type = {
};
}
fileToImport = new File([JSON.stringify(geojson)], name, {type});
formData.append('json_file', geojson ? fileToImport : state.fileToImport);
formData.append('feature_type_slug', feature_type_slug);
let url =
......@@ -206,7 +205,6 @@ const feature_type = {
.catch((error) => {
throw (error);
});
// }
},
GET_IMPORTS({ commit }, { project_slug, feature_type }) {
......
......@@ -359,7 +359,7 @@ export default {
importFeatureTypeData: {
deep: true,
handler(newValue) {
handler(newValue, oldValue) {
if (newValue && newValue.some(el => el.status === 'pending')) {
setTimeout(() => {
this.reloadingImport = true;
......@@ -371,6 +371,8 @@ export default {
}, 1000);
})
}, this.$store.state.configuration.VUE_APP_RELOAD_INTERVAL);
} else if (oldValue && oldValue.some(el => el.status === 'pending')) {
this.getFeatures();
}
}
},
......@@ -503,8 +505,11 @@ export default {
}
if (this.$route.params.geojson) {
payload["geojson"] = this.$route.params.geojson
} else {
} else if (this.fileToImport && !this.fileToImport.name) {
payload["fileToImport"] = this.fileToImport;
} else {
this.importError = "La ressource n'a pas pu être récupéré."
return
}
this.$store.dispatch('feature_type/SEND_FEATURES_FROM_GEOJSON', payload)
.then(() => {
......
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