Skip to content
Snippets Groups Projects
Commit 9c889303 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmine-issues/12449' into 'develop'

REDMINE_ISSUE-12449 | Import - Impossible d'importer le fichier qui a permis de créer le type de signalement

See merge request geocontrib/geocontrib-frontend!163
parents 8f5f69ff cd7f78ec
No related branches found
No related tags found
No related merge requests found
......@@ -160,12 +160,13 @@ const feature_type = {
},
SEND_FEATURES_FROM_GEOJSON({ state, dispatch }, payload) {
const { feature_type_slug } = payload
console.log(payload);
const { feature_type_slug } = payload;
if (state.fileToImport.size > 0) {
let formData = new FormData();
formData.append("json_file", state.fileToImport);
formData.append("feature_type_slug", feature_type_slug);
formData.append('json_file', state.fileToImport);
formData.append('feature_type_slug', feature_type_slug);
let url =
this.state.configuration.VUE_APP_DJANGO_API_BASE +
'import-tasks/'
......
......@@ -267,6 +267,7 @@ export default {
return "integer";
} else if (
type === "string" &&
['/', ':', '-'].some(el => prop.includes(el)) && // check for chars found in datestring
date instanceof Date &&
!isNaN(date.valueOf())
) {
......@@ -288,24 +289,22 @@ export default {
});
for (const feature of json.features) {
for (const { name, field_type, options } of fields) {
//* check if custom field is present
if (!(name in feature.properties)) {
return false;
}
const fieldInFeature = feature.properties[name];
const customType = this.transformProperties(fieldInFeature);
//* if custom field value is not null, then check validity of field
if (fieldInFeature !== null) {
//* if field type is list, it's not possible to guess from value type
if (field_type === "list") {
//*then check if the value is an available option
if (!options.includes(fieldInFeature)) {
if (name in feature.properties) {
const fieldInFeature = feature.properties[name];
const customType = this.transformProperties(fieldInFeature);
//* if custom field value is not null, then check validity of field
if (fieldInFeature !== null) {
//* if field type is list, it's not possible to guess from value type
if (field_type === "list") {
//*then check if the value is an available option
if (!options.includes(fieldInFeature)) {
return false;
}
} else if (customType !== field_type) {
//* check if custom field value match
this.importError = `Le fichier est invalide: Un champ de type ${field_type} ne peut pas avoir la valeur [ ${fieldInFeature} ]`;
return false;
}
} else if (customType !== field_type) {
//* check if custom field value match
this.importError = `Le fichier est invalide: Un champ de type ${field_type} ne peut pas avoir la valeur [ ${fieldInFeature} ]`;
return false;
}
}
}
......@@ -331,7 +330,7 @@ export default {
},
importGeoJson() {
this.$store.dispatch("feature_type/SEND_FEATURES_FROM_GEOJSON", {
this.$store.dispatch('feature_type/SEND_FEATURES_FROM_GEOJSON', {
slug: this.$route.params.slug,
feature_type_slug: this.$route.params.feature_type_slug,
fileToImport: this.fileToImport,
......
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