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

View File

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

View File

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