diff --git a/src/views/FeatureType/FeatureTypeDetail.vue b/src/views/FeatureType/FeatureTypeDetail.vue index d6acca8f9b47e9e11f9c0db4596b6dab7dfcdc09..22c6b22cb6ce59c775ad090d7885aafedb26a416 100644 --- a/src/views/FeatureType/FeatureTypeDetail.vue +++ b/src/views/FeatureType/FeatureTypeDetail.vue @@ -222,7 +222,7 @@ GeoJSON </option> <option - v-if="structure.geom_type === 'point'" + v-if="structure.geom_type === 'point' || structure.geom_type === 'none'" value="CSV" > CSV @@ -679,12 +679,22 @@ export default { // Parse the CSV string into rows const rows = parseCSV(csvString, delimiter); - // Extract headers and check for required fields 'lat' and 'lon' + // Extract headers const headers = rows.shift(); - if (!headers.includes('lat') || !headers.includes('lon')) { - this.importError = 'Les champs obligatoires "lat" et "lon" sont absents.'; - return false; - } + if (this.structure.geom_type !== 'none') { + // Check for required fields 'lat' and 'lon' in headers + if (!headers.includes('lat') || !headers.includes('lon')) { + this.importError = 'Les champs obligatoires "lat" et "lon" sont absents des headers.'; + return false; + } + // Verify the presence and validity of coordinate values + const hasCoordValues = checkLonLatValues(headers, rows); + if (!hasCoordValues) { + this.importError = 'Les valeurs de "lon" et "lat" ne sont pas valides ou absentes.'; + return false; + } + + } // Ensure there are data rows after the headers if (rows.length === 0) { @@ -698,13 +708,6 @@ export default { return false; } - // Verify the presence and validity of coordinate values - const hasCoordValues = checkLonLatValues(headers, rows); - if (!hasCoordValues) { - this.importError = 'Les valeurs de "lon" et "lat" ne sont pas valides.'; - return false; - } - // Convert the CSV string to a JSON object for further processing const jsonFromCsv = await csv({ delimiter }).fromString(csvString); diff --git a/src/views/FeatureType/FeatureTypeEdit.vue b/src/views/FeatureType/FeatureTypeEdit.vue index 9871f0e109af5ded8bba445e0103f9571ac11f2d..aa003072382a3d99cff4a1997335f7a98a099cd3 100644 --- a/src/views/FeatureType/FeatureTypeEdit.vue +++ b/src/views/FeatureType/FeatureTypeEdit.vue @@ -551,6 +551,7 @@ export default { this.loading = false; }); }, + postCSVFeatures(feature_type_slug) { this.$store .dispatch('feature-type/SEND_FEATURES_FROM_CSV', {