Skip to content
Snippets Groups Projects
Commit d2757abc authored by Ron Lucke's avatar Ron Lucke
Browse files

fix #1454

Closes #1454

Merge request studip/studip!961
parent 2e2497d7
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</template> </template>
<template v-slot:containerEditDialog> <template v-slot:containerEditDialog>
<form class="default cw-container-dialog-edit-form" @submit.prevent=""> <form class="default cw-container-dialog-edit-form" @submit.prevent="">
<fieldset v-for="(section, index) in currentContainer.attributes.payload.sections" :key="index"> <fieldset v-for="(section, index) in currentContainer.attributes.payload.sections.filter(section => !section.locked)" :key="index">
<label> <label>
<translate>Title</translate> <translate>Title</translate>
<input type="text" v-model="section.name" /> <input type="text" v-model="section.name" />
...@@ -116,6 +116,7 @@ export default { ...@@ -116,6 +116,7 @@ export default {
return { return {
currentContainer: {}, currentContainer: {},
currentSections: [], currentSections: [],
unallocatedBlocks: [],
sortMode: false, sortMode: false,
isDragging: false, isDragging: false,
dragOptions: { dragOptions: {
...@@ -158,10 +159,25 @@ export default { ...@@ -158,10 +159,25 @@ export default {
let view = this; let view = this;
let sections = this.currentContainer.attributes.payload.sections; let sections = this.currentContainer.attributes.payload.sections;
const unallocated = new Set(this.blocks.map(({ id }) => id));
sections.forEach(section => { sections.forEach(section => {
section.blocks = section.blocks.map((id) => view.blockById({id})).filter((a) => a); section.locked = false;
section.blocks = section.blocks.map((id) => view.blockById({id})).filter(Boolean);
section.blocks.forEach(({ id }) => unallocated.delete(id));
}); });
if (unallocated.size > 0) {
this.unallocatedBlocks = [...unallocated].map((id) => view.blockById({ id }));
sections.push({
blocks: this.unallocatedBlocks,
name: this.$gettext('nicht zugewiesene Inhalte'),
icon: 'decline',
locked: true
});
}
this.currentSections = sections; this.currentSections = sections;
}, },
addSection() { addSection() {
...@@ -189,8 +205,10 @@ export default { ...@@ -189,8 +205,10 @@ export default {
this.currentContainer.attributes.payload.sections.splice(index, 1); this.currentContainer.attributes.payload.sections.splice(index, 1);
}, },
async storeContainer() { async storeContainer() {
this.currentContainer.attributes.payload.sections = this.currentContainer.attributes.payload.sections.filter(section => !section.locked);
this.currentContainer.attributes.payload.sections.forEach(section => { this.currentContainer.attributes.payload.sections.forEach(section => {
section.blocks = section.blocks.map((block) => {return block.id;}); section.blocks = section.blocks.map((block) => {return block.id;});
delete section.locked;
}); });
await this.updateContainer({ await this.updateContainer({
container: this.currentContainer, container: this.currentContainer,
......
<template> <template>
<section class="cw-block-edit" @click="deactivateToolbar"> <section class="cw-block-edit">
<header><translate>Bearbeiten</translate></header> <header><translate>Bearbeiten</translate></header>
<div class="cw-block-features-content"> <div class="cw-block-features-content">
<div @click="deactivateToolbar(); exitHandler = true;">
<slot name="edit" /> <slot name="edit" />
</div>
<div class="cw-button-box"> <div class="cw-button-box">
<button class="button accept" @click="$emit('store'); exitHandler = false;"><translate>Speichern</translate></button> <button class="button accept" @click="$emit('store'); exitHandler = false;"><translate>Speichern</translate></button>
<button class="button cancel" @click="$emit('close'); exitHandler = false;"><translate>Abbrechen</translate></button> <button class="button cancel" @click="$emit('close'); exitHandler = false;"><translate>Abbrechen</translate></button>
...@@ -20,7 +22,7 @@ export default { ...@@ -20,7 +22,7 @@ export default {
data() { data() {
return { return {
originalBlock: Object, originalBlock: Object,
exitHandler: true exitHandler: false
}; };
}, },
beforeMount() { beforeMount() {
......
...@@ -80,7 +80,7 @@ export default { ...@@ -80,7 +80,7 @@ export default {
return []; return [];
} }
return this.container.attributes.payload.sections[0].blocks.map((id) => this.blockById({ id })).filter((a) => a); return this.container.relationships.blocks.data.map(({ id }) => this.blockById({ id })).filter(Boolean);
}, },
showEditMode() { showEditMode() {
return this.$store.getters.viewMode === 'edit'; return this.$store.getters.viewMode === 'edit';
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</template> </template>
<template v-slot:containerEditDialog> <template v-slot:containerEditDialog>
<form class="default cw-container-dialog-edit-form" @submit.prevent=""> <form class="default cw-container-dialog-edit-form" @submit.prevent="">
<fieldset v-for="(section, index) in currentContainer.attributes.payload.sections" :key="index"> <fieldset v-for="(section, index) in currentContainer.attributes.payload.sectionsfilter(section => !section.locked)" :key="index">
<label> <label>
<translate>Title</translate> <translate>Title</translate>
<input type="text" v-model="section.name" /> <input type="text" v-model="section.name" />
...@@ -131,6 +131,7 @@ export default { ...@@ -131,6 +131,7 @@ export default {
return { return {
currentContainer: null, currentContainer: null,
currentSections: [], currentSections: [],
unallocatedBlocks: [],
textDeleteSection: this.$gettext('Sektion entfernen'), textDeleteSection: this.$gettext('Sektion entfernen'),
selectAttributes: {'ref': 'openIndicator', 'role': 'presentation', 'class': 'vs__open-indicator'}, selectAttributes: {'ref': 'openIndicator', 'role': 'presentation', 'class': 'vs__open-indicator'},
sortMode: false, sortMode: false,
...@@ -175,10 +176,25 @@ export default { ...@@ -175,10 +176,25 @@ export default {
let view = this; let view = this;
let sections = this.currentContainer.attributes.payload.sections; let sections = this.currentContainer.attributes.payload.sections;
const unallocated = new Set(this.blocks.map(({ id }) => id));
sections.forEach(section => { sections.forEach(section => {
section.locked = false;
section.blocks = section.blocks.map((id) => view.blockById({id})).filter((a) => a); section.blocks = section.blocks.map((id) => view.blockById({id})).filter((a) => a);
section.blocks.forEach(({ id }) => unallocated.delete(id));
}); });
if (unallocated.size > 0) {
this.unallocatedBlocks = [...unallocated].map((id) => view.blockById({ id }));
sections.push({
blocks: this.unallocatedBlocks,
name: this.$gettext('nicht zugewiesene Inhalte'),
icon: 'decline',
locked: true
});
}
this.currentSections = sections; this.currentSections = sections;
}, },
addSection() { addSection() {
...@@ -206,8 +222,10 @@ export default { ...@@ -206,8 +222,10 @@ export default {
this.currentContainer.attributes.payload.sections.splice(index, 1); this.currentContainer.attributes.payload.sections.splice(index, 1);
}, },
async storeContainer() { async storeContainer() {
this.currentContainer.attributes.payload.sections = this.currentContainer.attributes.payload.sections.filter(section => !section.locked);
this.currentContainer.attributes.payload.sections.forEach(section => { this.currentContainer.attributes.payload.sections.forEach(section => {
section.blocks = section.blocks.map((block) => {return block.id;}); section.blocks = section.blocks.map((block) => {return block.id;});
delete section.locked;
}); });
await this.updateContainer({ await this.updateContainer({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment