Skip to content
Snippets Groups Projects
Commit b5ddb109 authored by Ron Lucke's avatar Ron Lucke Committed by Elmar Ludwig
Browse files

fixes #342

parent 4047f83c
No related branches found
No related tags found
No related merge requests found
...@@ -135,6 +135,7 @@ export default { ...@@ -135,6 +135,7 @@ export default {
userId: 'userId', userId: 'userId',
viewMode: 'viewMode', viewMode: 'viewMode',
getComments: 'courseware-block-comments/related', getComments: 'courseware-block-comments/related',
containerById: 'courseware-containers/byId',
}), }),
showEditMode() { showEditMode() {
let show = this.viewMode === 'edit' || this.blockedByThisUser; let show = this.viewMode === 'edit' || this.blockedByThisUser;
...@@ -179,6 +180,7 @@ export default { ...@@ -179,6 +180,7 @@ export default {
unlockObject: 'unlockObject', unlockObject: 'unlockObject',
loadComments: 'courseware-block-comments/loadRelated', loadComments: 'courseware-block-comments/loadRelated',
loadContainer: 'loadContainer', loadContainer: 'loadContainer',
updateContainer: 'updateContainer',
}), }),
async displayFeature(element) { async displayFeature(element) {
if (this.showEdit && element === 'Edit') { if (this.showEdit && element === 'Edit') {
...@@ -252,11 +254,36 @@ export default { ...@@ -252,11 +254,36 @@ export default {
} }
}, },
async executeDelete() { async executeDelete() {
await this.deleteBlock({ const containerId = this.block.relationships.container.data.id;
await this.loadContainer(containerId);
let container = this.containerById({id: containerId});
const structuralElementId = container.relationships['structural-element'].data.id;
let containerBlocks = container.relationships.blocks.data.map(block => {
return block.id;
});
let sections = container.attributes.payload.sections;
// lock parent container
await this.lockObject({ id: containerId, type: 'courseware-containers' });
// update container information
for (let i = 0; i < sections.length; i++) {
for (let j = 0; j < sections[i].blocks.length; j++) {
let blockId = sections[i].blocks[j];
if (!containerBlocks.includes(blockId) || blockId === this.block.id) {
sections[i].blocks.splice(j, 1);
j--;
}
}
}
// update container
await this.updateContainer({ container, structuralElementId });
// unlock container
await this.unlockObject({ id: containerId, type: 'courseware-containers' });
await this.loadContainer(containerId);
this.deleteBlock({
blockId: this.block.id, blockId: this.block.id,
containerId: this.block.relationships.container.data.id, containerId: containerId,
}); });
// this.showDeleteDialog = false;
}, },
async loadComments() { async loadComments() {
......
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