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

fix #2619

Closes #2619

Merge request studip/studip!1770
parent 72b851c4
No related branches found
No related tags found
No related merge requests found
...@@ -115,7 +115,9 @@ ...@@ -115,7 +115,9 @@
{{ importStructuresState }} {{ importStructuresState }}
</div> </div>
</fieldset> </fieldset>
<fieldset v-show="importErrors.length > 0"> </form>
<form v-if="importErrors.length > 0" class="default" @submit.prevent="">
<fieldset>
<legend>{{$gettext('Fehlermeldungen')}}</legend> <legend>{{$gettext('Fehlermeldungen')}}</legend>
<ul> <ul>
<li v-for="(error, index) in importErrors" :key="index"> {{error}} </li> <li v-for="(error, index) in importErrors" :key="index"> {{error}} </li>
......
...@@ -61,7 +61,9 @@ ...@@ -61,7 +61,9 @@
{{ importStructuresState }} {{ importStructuresState }}
</div> </div>
</fieldset> </fieldset>
<fieldset v-show="importErrors.length > 0"> </form>
<form v-if="importErrors.length > 0" class="default" @submit.prevent="">
<fieldset>
<legend>{{$gettext('Fehlermeldungen')}}</legend> <legend>{{$gettext('Fehlermeldungen')}}</legend>
<ul> <ul>
<li v-for="(error, index) in importErrors" :key="index"> {{error}} </li> <li v-for="(error, index) in importErrors" :key="index"> {{error}} </li>
......
...@@ -168,22 +168,24 @@ export default { ...@@ -168,22 +168,24 @@ export default {
if (element.length) { if (element.length) {
for (var i = 0; i < element.length; i++) { for (var i = 0; i < element.length; i++) {
this.setImportStructuresState(this.$gettext('Lege Seite an:') + ' ' + element[i].attributes.title); this.setImportStructuresState(this.$gettext('Lege Seite an:') + ' ' + element[i].attributes.title);
let new_element = null;
try { try {
await this.createStructuralElement({ await this.createStructuralElement({
attributes: element[i].attributes, attributes: element[i].attributes,
parentId: parent_id, parentId: parent_id,
currentId: parent_id, currentId: parent_id,
}); });
new_element = this.lastCreatedElements;
} catch(error) { } catch(error) {
this.currentImportErrors.push(this.$gettext('Seite konnte nicht erstellt werden') + ': ' this.currentImportErrors.push(this.$gettext('Seite konnte nicht erstellt werden') + ': '
+ element.attributes.title); + element.attributes.title);
continue;
} }
this.importElementCounter++; this.importElementCounter++;
if (new_element === null) {
let new_element = this.lastCreatedElements; continue;
}
if (element[i].imageId) { if (element[i].imageId) {
await this.setStructuralElementImage(new_element, element[i].imageId, files); await this.setStructuralElementImage(new_element, element[i].imageId, files);
...@@ -221,30 +223,32 @@ export default { ...@@ -221,30 +223,32 @@ export default {
async importContainer(container, structuralElement, files) { async importContainer(container, structuralElement, files) {
this.setImportStructuresState(this.$gettext('Lege Abschnitt an:') + ' ' + container.attributes.title); this.setImportStructuresState(this.$gettext('Lege Abschnitt an:') + ' ' + container.attributes.title);
let new_container = null;
try { try {
await this.createContainer({ await this.createContainer({
attributes: container.attributes, attributes: container.attributes,
structuralElementId: structuralElement.id, structuralElementId: structuralElement.id,
}); });
new_container = this.lastCreatedContainers;
} catch(error) { } catch(error) {
this.currentImportErrors.push(this.$gettext('Abschnitt konnte nicht erstellt werden') + ': ' this.currentImportErrors.push(this.$gettext('Abschnitt konnte nicht erstellt werden') + ': '
+ structuralElement.attributes.title + '' + structuralElement.attributes.title + ''
+ container.attributes.title); + container.attributes.title);
return null;
} }
this.importElementCounter++; this.importElementCounter++;
let new_container = this.lastCreatedContainers; if (new_container === null) {
return null;
}
await this.unlockObject({ id: new_container.id, type: 'courseware-containers' }); await this.unlockObject({ id: new_container.id, type: 'courseware-containers' });
if (container.blocks?.length) { if (container.blocks?.length) {
let new_block = null; let new_block = null;
for (var k = 0; k < container.blocks.length; k++) { for (var k = 0; k < container.blocks.length; k++) {
new_block = await this.importBlock(container.blocks[k], new_container, files, structuralElement); new_block = await this.importBlock(container.blocks[k], new_container, files, structuralElement);
this.importElementCounter++;
if (new_block !== null) { if (new_block !== null) {
this.importElementCounter++;
try { try {
await this.updateContainerPayload(new_container, structuralElement.id, container.blocks[k].id, new_block.id); await this.updateContainerPayload(new_container, structuralElement.id, container.blocks[k].id, new_block.id);
} catch(error) { } catch(error) {
......
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