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

Merge branch 'redmine-issue/13365' into 'develop'

REDMINE_ISSUE-13365 | Import/export CSV

See merge request geocontrib/geocontrib-frontend!375
parents 91c022b9 897e8a98
No related branches found
No related tags found
No related merge requests found
...@@ -24,14 +24,18 @@ export function csvToJson(csv, delimiter) { ...@@ -24,14 +24,18 @@ export function csvToJson(csv, delimiter) {
const [, ...lines] = allLines; const [, ...lines] = allLines;
for (const line of lines) { for (const line of lines) {
const obj = {}; if (line) {
const currentLine = line.split(delimiter); const obj = {};
const currentLine = line.split(delimiter).map(el => {
return el.replace('\r', '');
});
for (let i = 0; i < headers.length; i++) { for (let i = 0; i < headers.length; i++) {
obj[headers[i]] = currentLine[i]; obj[headers[i]] = currentLine[i];
} }
result.push(obj); result.push(obj);
}
} }
return JSON.parse(JSON.stringify(result)); return JSON.parse(JSON.stringify(result));
} }
...@@ -663,7 +663,8 @@ export default { ...@@ -663,7 +663,8 @@ export default {
//* if field type is list, it's not possible to guess from value type //* if field type is list, it's not possible to guess from value type
if (field_type === 'list') { if (field_type === 'list') {
//*then check if the value is an available option //*then check if the value is an available option
if (!options.includes(fieldInFeature)) { if (fieldInFeature && !options.includes(fieldInFeature)) {
this.importError = `Le champ ${name} contient une valeur invalide.`;
return false; return false;
} }
} else if (customType !== field_type) { } else if (customType !== field_type) {
...@@ -693,7 +694,7 @@ export default { ...@@ -693,7 +694,7 @@ export default {
reader.addEventListener('load', (e) => { reader.addEventListener('load', (e) => {
// bypass json check for files larger then 10 Mo // bypass json check for files larger then 10 Mo
let jsonValidity; let jsonValidity;
if (parseFloat(fileConvertSizeToMo(files[0])) <= 10) { if (parseFloat(fileConvertSizeToMo(files[0].size)) <= 10) {
jsonValidity = this.checkJsonValidity(JSON.parse(e.target.result)); jsonValidity = this.checkJsonValidity(JSON.parse(e.target.result));
} else { } else {
jsonValidity = true; jsonValidity = true;
......
...@@ -244,6 +244,7 @@ export default { ...@@ -244,6 +244,7 @@ export default {
slug: this.$route.params.slug, slug: this.$route.params.slug,
reservedKeywords: [ reservedKeywords: [
// todo : add keywords for mapstyle (strokewidth...) // todo : add keywords for mapstyle (strokewidth...)
'id',
'title', 'title',
'description', 'description',
'status', 'status',
......
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