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 !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) {
const [, ...lines] = allLines;
for (const line of lines) {
const obj = {};
const currentLine = line.split(delimiter);
if (line) {
const obj = {};
const currentLine = line.split(delimiter).map(el => {
return el.replace('\r', '');
});
for (let i = 0; i < headers.length; i++) {
obj[headers[i]] = currentLine[i];
}
for (let i = 0; i < headers.length; i++) {
obj[headers[i]] = currentLine[i];
}
result.push(obj);
result.push(obj);
}
}
return JSON.parse(JSON.stringify(result));
}
......@@ -663,7 +663,8 @@ export default {
//* 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 (fieldInFeature && !options.includes(fieldInFeature)) {
this.importError = `Le champ ${name} contient une valeur invalide.`;
return false;
}
} else if (customType !== field_type) {
......@@ -693,7 +694,7 @@ export default {
reader.addEventListener('load', (e) => {
// bypass json check for files larger then 10 Mo
let jsonValidity;
if (parseFloat(fileConvertSizeToMo(files[0])) <= 10) {
if (parseFloat(fileConvertSizeToMo(files[0].size)) <= 10) {
jsonValidity = this.checkJsonValidity(JSON.parse(e.target.result));
} else {
jsonValidity = true;
......
......@@ -244,6 +244,7 @@ export default {
slug: this.$route.params.slug,
reservedKeywords: [
// todo : add keywords for mapstyle (strokewidth...)
'id',
'title',
'description',
'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