Fix a bug with module bookmarks and one with instrument bookmarks

This commit is contained in:
Ramon Wenger 2023-09-21 14:42:56 +02:00
parent c721dc26aa
commit 4667465b9c
3 changed files with 38 additions and 9 deletions

View File

@ -1,5 +1,8 @@
<template>
<div class="content-bookmark module-activity-entry" v-if="content">
<div
class="content-bookmark module-activity-entry"
v-if="content"
>
<!-- eslint-disable vue/no-v-html -->
<div
v-if="content.type === 'text_block'"
@ -19,9 +22,7 @@
<script>
import { defineAsyncComponent } from 'vue';
const LinkBlock = defineAsyncComponent(() =>
import('@/components/content-blocks/LinkBlock.vue')
);
const LinkBlock = defineAsyncComponent(() => import('@/components/content-blocks/LinkBlock.vue'));
export default {
props: ['bookmark'],
@ -30,7 +31,7 @@ export default {
content() {
return this.bookmark.contentBlock
? this.bookmark.contentBlock.contents.find((e) => e.id === this.bookmark.uuid)
: this.bookmark.instrument?.find((e) => e.id === this.bookmark.uuid);
: this.bookmark.instrument?.contents.find((e) => e.id === this.bookmark.uuid);
},
text() {
return this.content.value.text ? this.content.value.text : 'TO BE DEFINED';

View File

@ -46,13 +46,22 @@
>
{{ bookmark.chapter.description }}
</activity-entry>
<activity-entry
title="Lesezeichen"
class="module-activity__entry"
:bookmark="moduleBookmark"
v-if="moduleBookmark"
@link="goTo('module', module.slug)"
>
<div v-html="moduleBookmark.module.intro"></div>
</activity-entry>
<activity-entry
title="Notiz"
class="module-activity__entry"
:bookmark="noteBookmark"
v-for="noteBookmark in notes"
:key="noteBookmark.note.id"
@link="goTo('content', noteBookmark.contentBlock ? noteBookmark.contentBlock.id : noteBookmark.chapter.id)"
@link="goToNote(noteBookmark)"
>
{{ noteBookmark.note.text }}
</activity-entry>
@ -80,7 +89,8 @@ export default {
this.answers.length ||
this.submissions.length ||
this.contentBookmarks.length ||
this.chapterBookmarks.length
this.chapterBookmarks.length ||
this.moduleBookmark
);
},
notes() {
@ -101,7 +111,10 @@ export default {
return this.applyFilter('bookmarks') ? this.module.myContentBookmarks : [];
},
chapterBookmarks() {
return this.applyFilter('bookmarks') ? this.module.myChapterBookmarks : []
return this.applyFilter('bookmarks') ? this.module.myChapterBookmarks : [];
},
moduleBookmark() {
return this.applyFilter('bookmarks') ? this.module.bookmark : undefined;
},
},
methods: {
@ -116,6 +129,15 @@ export default {
});
this.$router.push(url);
},
goToNote(bookmark) {
if (bookmark.module) {
this.goTo('module', bookmark.module.slug);
} else if (bookmark.chapter) {
this.goTo('content', bookmark.chapter.id);
} else {
this.goTo('content', bookmark.contentBlock.id);
}
},
applyFilter(filterCriteria) {
return !this.filter || this.filter === filterCriteria;
@ -151,7 +173,7 @@ export default {
&__title {
@include heading-2;
}
&__meta-title {
&__meta-title {
@include regular-text;
margin-bottom: $small-spacing;
}

View File

@ -19,6 +19,11 @@ query MyActivityQuery {
bookmarks {
id
uuid
instrument {
id
slug
contents
}
note {
id
text
@ -102,6 +107,7 @@ query MyActivityQuery {
text
}
module {
slug
id
teaser
metaTitle