diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue
index cbd5d9a8..f51c210b 100644
--- a/client/src/components/ContentBlock.vue
+++ b/client/src/components/ContentBlock.vue
@@ -2,7 +2,7 @@
-
+
Löschen
Bearbeiten
@@ -122,7 +122,7 @@
},
contentBlocksWithContentLists() {
/*
- collects all conent_list_items in content_lists:
+ collects all content_list_items in content_lists:
{
text_block,
content_list_item: [contents...],
@@ -146,18 +146,21 @@
}
*/
let contentList = [];
+ let startingIndex = 0;
let newContent = this.contentBlock.contents.reduce((newContents, content, index) => {
// collect content_list_items
if (content.type === 'content_list_item') {
contentList = [...contentList, content]
if (index === this.contentBlock.contents.length - 1) { // content is last element of contents array
- return [...newContents, ...this.createContentListOrBlocks(contentList)];
+ startingIndex = this.updateStartingIndex(startingIndex, contentList);
+ return [...newContents, ...this.createContentListOrBlocks(contentList, startingIndex)];
}
- return newContents
+ return newContents;
} else {
// handle all other items and reset current content_list if necessary
if (contentList.length !== 0) {
- newContents = [...newContents, ...this.createContentListOrBlocks(contentList), content];
+ newContents = [...newContents, ...this.createContentListOrBlocks(contentList, startingIndex), content];
+ startingIndex = this.updateStartingIndex(startingIndex, contentList);
contentList = [];
return newContents;
} else {
@@ -165,9 +168,8 @@
}
}
}, []);
-
return Object.assign({}, this.contentBlock, {
- contents: newContent
+ contents: this.removeSingleContentListItem(newContent, startingIndex)
});
},
schoolClass() {
@@ -209,18 +211,29 @@
}
});
},
- createContentListOrBlocks(contentList) {
- // if list contains only one item, return blocks
- if (contentList.length === 1) {
- return contentList[0].value;
- }
-
+ createContentListOrBlocks(contentList, startingIndex) {
return [{
type: 'content_list',
contents: contentList,
- id: contentList[0].id
+ id: contentList[0].id,
+ startingIndex
}];
},
+ updateStartingIndex(startingIndex, contentList) {
+ return contentList.length > 1 ? startingIndex + contentList.length : startingIndex;
+ },
+ removeSingleContentListItem(content, index) {
+ // just handle the case where we have one contentlistItem ( no index like "a)"" will be shown)
+ if (index > 0) {
+ return content;
+ };
+
+ let contentListIndex = content.findIndex(contentItem => contentItem.type === 'content_list');
+ if (contentListIndex < 0) {
+ return content;
+ }
+ return [...content.slice(0, contentListIndex), ...content[contentListIndex].contents[0].value, ...content.slice(contentListIndex + 1)];
+ }
},
data() {
return {
diff --git a/client/src/components/UserWidget.vue b/client/src/components/UserWidget.vue
index a8224a46..dfddf48e 100644
--- a/client/src/components/UserWidget.vue
+++ b/client/src/components/UserWidget.vue
@@ -1,27 +1,28 @@
-