Skip to content
Snippets Groups Projects
Commit f3872997 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #14458 TIME 0:15 fix mime type (windows) + remove limit min col

parent 541c3b8b
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ export class ContactImportComponent implements OnInit { ...@@ -150,7 +150,7 @@ export class ContactImportComponent implements OnInit {
map((data: any) => { map((data: any) => {
data = data.customFields.map(custom => { data = data.customFields.map(custom => {
return { return {
id : `contactCustomField_${custom.id}`, id: `contactCustomField_${custom.id}`,
label: custom.label label: custom.label
}; };
}); });
...@@ -190,7 +190,7 @@ export class ContactImportComponent implements OnInit { ...@@ -190,7 +190,7 @@ export class ContactImportComponent implements OnInit {
} }
uploadCsv(fileInput: any) { uploadCsv(fileInput: any) {
if (fileInput.target.files && fileInput.target.files[0] && fileInput.target.files[0].type === 'text/csv') { if (fileInput.target.files && fileInput.target.files[0] && (fileInput.target.files[0].type === 'text/csv' || fileInput.target.files[0].type === 'application/vnd.ms-excel')) {
this.loading = true; this.loading = true;
let rawCsv = []; let rawCsv = [];
...@@ -202,29 +202,26 @@ export class ContactImportComponent implements OnInit { ...@@ -202,29 +202,26 @@ export class ContactImportComponent implements OnInit {
rawCsv = value.target.result.split('\n'); rawCsv = value.target.result.split('\n');
rawCsv = rawCsv.filter(data => data !== ''); rawCsv = rawCsv.filter(data => data !== '');
if (rawCsv[0].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim()).length >= this.contactColumns.length - 1) { let dataCol = [];
let dataCol = []; let objData = {};
let objData = {}; this.setCsvColumns(rawCsv[0].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim()));
this.setCsvColumns(rawCsv[0].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim()));
this.countAll = this.hasHeader ? rawCsv.length - 1 : rawCsv.length; this.countAll = this.hasHeader ? rawCsv.length - 1 : rawCsv.length;
for (let index = 0; index < rawCsv.length; index++) { for (let index = 0; index < rawCsv.length; index++) {
objData = {}; objData = {};
dataCol = rawCsv[index].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim()); dataCol = rawCsv[index].split(this.currentDelimiter).map(s => s.replace(/"/gi, '').trim());
dataCol.forEach((element: any, index2: number) => { dataCol.forEach((element: any, index2: number) => {
objData[this.csvColumns[index2]] = element; objData[this.csvColumns[index2]] = element;
}); });
this.csvData.push(objData); this.csvData.push(objData);
}
this.initData();
this.countAdd = this.csvData.filter((data: any, index: number) => index > 0 && this.functionsService.empty(data[this.associatedColmuns['id']])).length;
this.countUp = this.csvData.filter((data: any, index: number) => index > 0 && !this.functionsService.empty(data[this.associatedColmuns['id']])).length;
this.localStorage.save(`importContactFields_${this.headerService.user.id}`, this.currentDelimiter);
} else {
this.notify.error(this.translate.instant('lang.mustAtLeastMinValues'));
} }
this.initData();
this.countAdd = this.csvData.filter((data: any, index: number) => index > 0 && this.functionsService.empty(data[this.associatedColmuns['id']])).length;
this.countUp = this.csvData.filter((data: any, index: number) => index > 0 && !this.functionsService.empty(data[this.associatedColmuns['id']])).length;
this.localStorage.save(`importContactFields_${this.headerService.user.id}`, this.currentDelimiter);
this.loading = false; this.loading = false;
}; };
} else { } else {
......
...@@ -88,7 +88,7 @@ export class UsersImportComponent implements OnInit { ...@@ -88,7 +88,7 @@ export class UsersImportComponent implements OnInit {
} }
uploadCsv(fileInput: any) { uploadCsv(fileInput: any) {
if (fileInput.target.files && fileInput.target.files[0] && fileInput.target.files[0].type === 'text/csv') { if (fileInput.target.files && fileInput.target.files[0] && (fileInput.target.files[0].type === 'text/csv' || fileInput.target.files[0].type === 'application/vnd.ms-excel')) {
this.loading = true; this.loading = true;
let rawCsv = []; let rawCsv = [];
......
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