aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/mixins/courseware/import.js
diff options
context:
space:
mode:
authorRon Lucke <lucke@elan-ev.de>2024-07-23 09:29:13 +0000
committerMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2024-07-23 09:29:13 +0000
commitf3046f9af6aa3e352ef3deac3b5b81198011f4d2 (patch)
tree689f448a720993e067522f57156cf43a78b1b6f6 /resources/vue/mixins/courseware/import.js
parent3271f73e6ab7ef85519eb88d58ed914b655cd909 (diff)
evaluate image type of structural element on import and exportissue-4423-2
Closes #3743 Merge request studip/studip!3175
Diffstat (limited to 'resources/vue/mixins/courseware/import.js')
-rw-r--r--resources/vue/mixins/courseware/import.js38
1 files changed, 23 insertions, 15 deletions
diff --git a/resources/vue/mixins/courseware/import.js b/resources/vue/mixins/courseware/import.js
index 547280f..649a098 100644
--- a/resources/vue/mixins/courseware/import.js
+++ b/resources/vue/mixins/courseware/import.js
@@ -152,7 +152,7 @@ export default {
}
// compare image
if (element.imageId && root.relationships.image.data === null) {
- await this.setStructuralElementImage(root, element.imageId, files);
+ await this.setStructuralElementImage(root, element, files);
}
// add children
@@ -187,7 +187,7 @@ export default {
if (element[i].imageId) {
- await this.setStructuralElementImage(new_element, element[i].imageId, files);
+ await this.setStructuralElementImage(new_element, element[i], files);
}
@@ -205,19 +205,27 @@ export default {
}
},
- async setStructuralElementImage(new_element, imageId, files) {
- let imageFile = files.find((file) => { return file.id === imageId});
- let zip_filedata = await this.zip.file(imageFile.id).async('blob');
- // create new blob with correct type
- let filedata = zip_filedata.slice(0, zip_filedata.size, imageFile.attributes['mime-type']);
- this.setImportStructuresState(this.$gettext('Lade Vorschaubild hoch'));
- this.uploadImageForStructuralElement({
- structuralElement: new_element,
- file: filedata,
- }).catch((error) => {
- console.error(error);
- this.currentImportErrors.push(this.$gettext('Fehler beim Hochladen des Vorschaubildes.'));
- });
+ async setStructuralElementImage(new_element, element, files) {
+ const imageId = element.imageId;
+ const imageType = element.imageType ?? 'file-refs';
+ if (imageType === 'file-refs') {
+ const imageFile = files.find((file) => { return file.id === imageId});
+ if (!(imageFile)) {
+ this.currentImportErrors.push(this.$gettext('Fehler beim Laden des Vorschaubildes.'));
+ return;
+ }
+ let zip_filedata = await this.zip.file(imageFile.id).async('blob');
+ // create new blob with correct type
+ const filedata = zip_filedata.slice(0, zip_filedata.size, imageFile.attributes['mime-type']);
+ this.setImportStructuresState(this.$gettext('Lade Vorschaubild hoch'));
+ this.uploadImageForStructuralElement({
+ structuralElement: new_element,
+ file: filedata,
+ }).catch((error) => {
+ console.error(error);
+ this.currentImportErrors.push(this.$gettext('Fehler beim Hochladen des Vorschaubildes.'));
+ });
+ }
},
async importContainer(container, structuralElement, files) {