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

adapt csv import/export for non geographical features

parent 2ca3398d
No related branches found
No related tags found
1 merge request!735REDMINE_ISSUE-19119 | Permettre la gestion de signalements non-géographiques (REDMINE_ISSUE-19667 | La recherche de doublon à l'import de signalement s'applique sur les signalements supprimés)
......@@ -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);
......
......@@ -551,6 +551,7 @@ export default {
this.loading = false;
});
},
postCSVFeatures(feature_type_slug) {
this.$store
.dispatch('feature-type/SEND_FEATURES_FROM_CSV', {
......
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