Skip to content
Snippets Groups Projects
Commit f0405b97 authored by Ron Lucke's avatar Ron Lucke Committed by Jan-Hendrik Willms
Browse files

fix #2565

Closes #2565

Merge request studip/studip!2463
parent a636dcb3
No related branches found
No related tags found
No related merge requests found
...@@ -130,7 +130,6 @@ export default { ...@@ -130,7 +130,6 @@ export default {
this.importZipFile = event.target.files[0]; this.importZipFile = event.target.files[0];
this.setImportFilesProgress(0); this.setImportFilesProgress(0);
this.setImportStructuresProgress(0); this.setImportStructuresProgress(0);
this.setImportErrors([]);
}, },
async importCoursewareArchiv() { async importCoursewareArchiv() {
this.importAborted = false; this.importAborted = false;
...@@ -199,6 +198,9 @@ export default { ...@@ -199,6 +198,9 @@ export default {
await this.importCourseware(courseware, this.currentElement, files, this.importBehavior, null); await this.importCourseware(courseware, this.currentElement, files, this.importBehavior, null);
} }
},
mounted() {
this.setImportErrors([]);
} }
} }
</script> </script>
...@@ -53,7 +53,6 @@ export default { ...@@ -53,7 +53,6 @@ export default {
this.elementCounter = await this.countImportElements([element]); this.elementCounter = await this.countImportElements([element]);
this.setImportStructuresState(''); this.setImportStructuresState('');
this.importElementCounter = 0; this.importElementCounter = 0;
this.setImportErrors([]);
if (importBehavior === 'default') { if (importBehavior === 'default') {
await this.importStructuralElement([element], rootId, files); await this.importStructuralElement([element], rootId, files);
...@@ -286,8 +285,14 @@ export default { ...@@ -286,8 +285,14 @@ export default {
let new_file = this.file_mapping[files[i].id].new; let new_file = this.file_mapping[files[i].id].new;
let payload = JSON.stringify(block.attributes.payload); let payload = JSON.stringify(block.attributes.payload);
payload = payload.replaceAll(old_file.id, new_file.id); if (new_file) {
payload = payload.replaceAll(old_file.folder.id, new_file.relationships.parent.data.id); payload = payload.replaceAll(old_file.id, new_file.id);
payload = payload.replaceAll(old_file.folder.id, new_file.relationships.parent.data.id);
} else {
payload = payload.replaceAll(old_file.id, '');
payload = payload.replaceAll(old_file.folder.id, '');
}
block.attributes.payload = JSON.parse(payload); block.attributes.payload = JSON.parse(payload);
} }
...@@ -395,13 +400,20 @@ export default { ...@@ -395,13 +400,20 @@ export default {
// create new blob with correct type // create new blob with correct type
let filedata = zip_filedata.slice(0, zip_filedata.size, files[i].attributes['mime-type']); let filedata = zip_filedata.slice(0, zip_filedata.size, files[i].attributes['mime-type']);
let file = null;
let file = await this.createFile({ try {
file: files[i], file = await this.createFile({
filedata: filedata, file: files[i],
folder: folders[files[i].folder.id] filedata: filedata,
}); folder: folders[files[i].folder.id]
this.setImportFilesState(this.$gettext('Erzeuge Datei') + ': ' + files[i].attributes.name); });
} catch (error) {
this.currentImportErrors.push(this.$gettext('Import einer Datei fehlgeschlagen.'));
this.setImportFilesState(this.$gettext('Fehler beim Anlegen der Datei'));
}
if (file !== null) {
this.setImportFilesState(this.$gettext('Erzeuge Datei') + ': ' + files[i].attributes.name);
}
this.setImportFilesProgress(parseInt(i / files.length * 100)); this.setImportFilesProgress(parseInt(i / files.length * 100));
//file mapping //file mapping
......
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