Skip to content

Commit

Permalink
Switch back to txt
Browse files Browse the repository at this point in the history
  • Loading branch information
marode-cap committed Feb 24, 2025
1 parent c4a4ab9 commit 372f77d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/views/admin/PersonImportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@
}
function downloadFileContent(fileContent: string): void {
const blob: Blob = new Blob([fileContent], { type: 'text/csv' });
const blob: Blob = new Blob([fileContent], { type: 'text/txt' });
const url: string = window.URL.createObjectURL(blob);
const link: HTMLAnchorElement = document.createElement('a');
link.href = url;
link.setAttribute('download', `${t('admin.import.fileName.person')}.csv`);
link.setAttribute('download', `${t('admin.import.fileName.person')}.txt`);
document.body.appendChild(link);
link.click();
link.remove();
Expand All @@ -307,20 +307,24 @@
(user: ImportedUserResponse) => user.status === ImportDataItemStatus.Failed,
);
let fileContent: string = `Schule; ${importStore.importResponse?.organisationsname}; Rolle; ${importStore.importResponse?.rollenname}`;
fileContent += `\n\n${t('admin.import.successfullyImportedUsersNotice')}\n\n`;
/**
* make sure every (non-empty) line contains the correct amount of semicolons, otherwise the excel-data-import will not recognize the format
*/
let fileContent: string = `Schule:; ${importStore.importResponse?.organisationsname}; Rolle; ${importStore.importResponse?.rollenname};`;
fileContent += `\n\n${t('admin.import.successfullyImportedUsersNotice')};;;;\n\n`;
fileContent += 'Klasse; Vorname; Nachname; Benutzername; Passwort\n';
successfulUsers.forEach((user: ImportedUserResponse) => {
fileContent += `${user.klasse}; ${user.vorname}; ${user.nachname}; ${user.benutzername}; ${user.startpasswort}\n`;
});
if (failedUsers.length > 0) {
fileContent += `\n\n${t('admin.import.failedToImportUsersNotice')}\n\n`;
fileContent += 'Klasse; Vorname; Nachname; Benutzername\n';
fileContent += `\n\n${t('admin.import.failedToImportUsersNotice')};;;;\n\n`;
fileContent += 'Klasse; Vorname; Nachname; Benutzername;\n';
failedUsers.forEach((user: ImportedUserResponse) => {
fileContent += `${user.klasse}; ${user.vorname}; ${user.nachname}; ${user.benutzername}\n`;
fileContent += `${user.klasse}; ${user.vorname}; ${user.nachname}; ${user.benutzername};\n`;
});
}
Expand Down

0 comments on commit 372f77d

Please sign in to comment.