diff --git a/src/store/modules/feature_type.js b/src/store/modules/feature_type.js index cfc3c0ddb6f6d5d20bd0133ac18b4c046ee99b9a..612c4140631d3e8990f056d995417a9bf0bdb12f 100644 --- a/src/store/modules/feature_type.js +++ b/src/store/modules/feature_type.js @@ -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/' diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index 80e1e6eb516e735b21fd0cabc7c7ed37f8fd5b91..b872358948af2d14266505ad65aa954b9ecbe9ab 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -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,