Add instrument activities
This commit is contained in:
parent
cca1f8f1ac
commit
0e5eb0af0e
|
|
@ -58,3 +58,4 @@ export interface ActionOptions {
|
|||
}
|
||||
|
||||
export type ActivityProperty = 'myHighlights' | 'myBookmarks' | 'mySubmissions' | 'myAnswers';
|
||||
export type InstrumentActivityProperty = 'highlights' | 'bookmarks';
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const documents = {
|
|||
"\n fragment ContentBlockHighlightsWithIdOnlyFragment on ContentBlockNode {\n highlights {\n id\n }\n }\n ": types.ContentBlockHighlightsWithIdOnlyFragmentFragmentDoc,
|
||||
"\n mutation UpdateInstrumentBookmark($input: UpdateInstrumentBookmarkInput!) {\n updateInstrumentBookmark(input: $input) {\n success\n }\n }\n ": types.UpdateInstrumentBookmarkDocument,
|
||||
"\n mutation UpdateContentBookmark($input: UpdateContentBookmarkInput!) {\n updateContentBookmark(input: $input) {\n success\n }\n }\n ": types.UpdateContentBookmarkDocument,
|
||||
"\n query MyActivitiesQuery {\n myActivities {\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n ": types.MyActivitiesQueryDocument,
|
||||
"\n query MyActivitiesQuery {\n myActivities {\n instruments {\n id\n slug\n title\n path\n highlights {\n ...HighlightParts\n }\n bookmarks {\n ... on InstrumentBookmarkNode {\n path\n }\n }\n }\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n ": types.MyActivitiesQueryDocument,
|
||||
"\n query ChapterQuery($id: ID!) {\n chapter(id: $id) {\n path\n }\n }\n ": types.ChapterQueryDocument,
|
||||
"\n query ContentBlockQuery($id: ID!) {\n contentBlock(id: $id) {\n path\n }\n }\n ": types.ContentBlockQueryDocument,
|
||||
"\n fragment InstrumentParts on InstrumentNode {\n id\n title\n intro\n slug\n language\n bookmarks {\n uuid\n note {\n id\n text\n }\n }\n type {\n id\n name\n category {\n id\n name\n foreground\n background\n }\n type\n }\n contents\n highlights {\n ...HighlightParts\n }\n }\n": types.InstrumentPartsFragmentDoc,
|
||||
|
|
@ -156,7 +156,7 @@ export function graphql(source: "\n mutation UpdateContentBookmark($input
|
|||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query MyActivitiesQuery {\n myActivities {\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n "): (typeof documents)["\n query MyActivitiesQuery {\n myActivities {\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n "];
|
||||
export function graphql(source: "\n query MyActivitiesQuery {\n myActivities {\n instruments {\n id\n slug\n title\n path\n highlights {\n ...HighlightParts\n }\n bookmarks {\n ... on InstrumentBookmarkNode {\n path\n }\n }\n }\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n "): (typeof documents)["\n query MyActivitiesQuery {\n myActivities {\n instruments {\n id\n slug\n title\n path\n highlights {\n ...HighlightParts\n }\n bookmarks {\n ... on InstrumentBookmarkNode {\n path\n }\n }\n }\n topics {\n id\n title\n modules {\n id\n slug\n title\n metaTitle\n myHighlights {\n ...HighlightParts\n }\n myBookmarks {\n ... on ChapterBookmarkNode {\n chapter {\n path\n }\n path\n note {\n id\n text\n }\n }\n ... on ContentBlockBookmarkNode {\n id\n uuid\n path\n contentBlock {\n id\n path\n }\n note {\n id\n text\n }\n }\n ... on ModuleBookmarkNode {\n path\n note {\n id\n text\n }\n }\n }\n mySubmissions {\n id\n text\n assignment {\n id\n title\n path\n module {\n slug\n }\n }\n }\n myAnswers {\n id\n survey {\n path\n id\n title\n }\n }\n }\n }\n }\n }\n "];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,9 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-for="topic in topics"
|
||||
:key="topic.id"
|
||||
>
|
||||
<div class="activity-list">
|
||||
<template v-for="topic in topics">
|
||||
<template v-for="module in topic.modules">
|
||||
<div
|
||||
class="activity__module"
|
||||
|
|
@ -11,17 +8,16 @@
|
|||
:key="module.id"
|
||||
>
|
||||
<h4 class="heading-4">Thema: {{ topic.title }} - {{ module.metaTitle }}: {{ module.title }}</h4>
|
||||
<div
|
||||
<activity-entry
|
||||
:to="`/${path(item)}`"
|
||||
v-for="item in module[property]"
|
||||
:key="item.id"
|
||||
>
|
||||
<activity-entry :to="`/${path(item)}`">
|
||||
<slot :item="item"></slot>
|
||||
</activity-entry>
|
||||
</div>
|
||||
<slot :item="item"></slot>
|
||||
</activity-entry>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<template>
|
||||
<div class="activity-list">
|
||||
<template v-for="instrument in instruments">
|
||||
<div
|
||||
class="activity__module"
|
||||
v-if="instrument[property].length"
|
||||
:key="instrument.id"
|
||||
>
|
||||
<h4 class="heading-4">{{ instrument.title }}</h4>
|
||||
<activity-entry
|
||||
:to="`/${instrument.path}`"
|
||||
v-for="item in instrument[property]"
|
||||
:key="item.id"
|
||||
><slot :item="item"></slot
|
||||
></activity-entry>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { InstrumentActivityProperty } from '@/@types';
|
||||
import { InstrumentNode } from '@/__generated__/graphql';
|
||||
import ActivityEntry from '@/components/profile/ActivityEntry.vue';
|
||||
|
||||
export interface Props {
|
||||
instruments: InstrumentNode[];
|
||||
property: InstrumentActivityProperty;
|
||||
}
|
||||
defineProps<Props>();
|
||||
</script>
|
||||
|
|
@ -32,7 +32,19 @@
|
|||
>
|
||||
</div>
|
||||
<div class="activity__activities">
|
||||
<h2>Activities go here</h2>
|
||||
<instrument-activity-list
|
||||
property="highlights"
|
||||
:instruments="instruments"
|
||||
v-if="selectedCategory === HIGHLIGHTS"
|
||||
v-slot="{ item }"
|
||||
>
|
||||
<mark
|
||||
class="highlight"
|
||||
:class="[`highlight--${item?.color}`]"
|
||||
>{{ item?.text }}</mark
|
||||
>
|
||||
<div v-if="item.note">Notiz: {{ item.note.text }}</div>
|
||||
</instrument-activity-list>
|
||||
<activity-list
|
||||
:topics="highlightTopics"
|
||||
property="myHighlights"
|
||||
|
|
@ -46,6 +58,15 @@
|
|||
>
|
||||
<div v-if="item.note">Notiz: {{ item.note.text }}</div>
|
||||
</activity-list>
|
||||
<instrument-activity-list
|
||||
property="bookmarks"
|
||||
:instruments="instruments"
|
||||
v-if="selectedCategory === BOOKMARKS"
|
||||
v-slot="{ item }"
|
||||
>
|
||||
<div>Lesezeichen: {{ item.id }}</div>
|
||||
<div v-if="item.note">Notiz: {{ item.note.text }}</div>
|
||||
</instrument-activity-list>
|
||||
<activity-list
|
||||
:topics="bookmarkTopics"
|
||||
property="myBookmarks"
|
||||
|
|
@ -71,105 +92,6 @@
|
|||
>
|
||||
Übung: {{ item.survey.title }}
|
||||
</activity-list>
|
||||
<!-- <div -->
|
||||
<!-- v-for="topic in highlightTopics" -->
|
||||
<!-- :key="topic?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <h4>{{ topic?.title }}</h4> -->
|
||||
<!-- <template v-for="module in topic?.modules"> -->
|
||||
<!-- <div -->
|
||||
<!-- class="activity__module" -->
|
||||
<!-- v-if="module?.myHighlights?.length" -->
|
||||
<!-- :key="module?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="highlight in module.myHighlights" -->
|
||||
<!-- :key="highlight.id" -->
|
||||
<!-- > -->
|
||||
<!-- <activity-entry :to="`/${highlight.page.path}`"> -->
|
||||
<!-- <mark -->
|
||||
<!-- class="highlight" -->
|
||||
<!-- :class="[`highlight--${highlight?.color}`]" -->
|
||||
<!-- >{{ highlight?.text }}</mark -->
|
||||
<!-- > -->
|
||||
<!-- </activity-entry> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </template> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div v-if="selectedCategory === BOOKMARKS"> -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="topic in bookmarkTopics" -->
|
||||
<!-- :key="topic?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <h4>{{ topic?.title }}</h4> -->
|
||||
<!-- <template v-for="module in topic?.modules"> -->
|
||||
<!-- <div -->
|
||||
<!-- class="activity__module" -->
|
||||
<!-- v-if="module?.myBookmarks?.length" -->
|
||||
<!-- :key="module?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="bookmark in module?.myBookmarks" -->
|
||||
<!-- :key="bookmark?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <pre>{{ bookmark }}</pre> -->
|
||||
<!-- <activity-entry :to="`/${bookmark.path}`"> > Lesezeichen: {{ bookmark.id }} </activity-entry> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </template> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div v-if="selectedCategory === ASSIGNMENTS"> -->
|
||||
<!-- <h3>ASSIGNMENTS</h3> -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="topic in submissionsTopics" -->
|
||||
<!-- :key="topic?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <h4>{{ topic?.title }}</h4> -->
|
||||
<!-- <template v-for="module in topic?.modules"> -->
|
||||
<!-- <div -->
|
||||
<!-- class="activity__module" -->
|
||||
<!-- v-if="module?.mySubmissions?.length" -->
|
||||
<!-- :key="module.id" -->
|
||||
<!-- > -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="submission in module?.mySubmissions" -->
|
||||
<!-- :key="submission?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <pre>{{ submission }}</pre> -->
|
||||
<!-- <activity-entry :to="`/module/${submission.assignment.module.slug}#${submission.assignment.id}`"> -->
|
||||
<!-- Submission {{ submission?.text }}</activity-entry -->
|
||||
<!-- > -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </template> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div v-if="selectedCategory === SURVEYS"> -->
|
||||
<!-- <h3>SURVEYS</h3> -->
|
||||
<!-- <div -->
|
||||
<!-- v-for="topic in answersTopics" -->
|
||||
<!-- :key="topic?.id" -->
|
||||
<!-- > -->
|
||||
<!-- <h4>{{ topic?.title }}</h4> -->
|
||||
<!-- <template v-for="module in topic?.modules"> -->
|
||||
<!-- <div -->
|
||||
<!-- v-if="module?.myAnswers?.length" -->
|
||||
<!-- :key="module.id" -->
|
||||
<!-- > -->
|
||||
<!-- <div -->
|
||||
<!-- class="activity__module" -->
|
||||
<!-- v-for="answer in module?.myAnswers" -->
|
||||
<!-- :key="answer.id" -->
|
||||
<!-- > -->
|
||||
<!-- <pre>{{ answer }}</pre> -->
|
||||
<!-- <activity-entry :to="{ name: 'profile' }"> Übung: {{ answer?.survey.title }}</activity-entry> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </template> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -179,6 +101,7 @@ import { graphql } from '@/__generated__';
|
|||
import { useQuery } from '@vue/apollo-composable';
|
||||
import { ref, computed } from 'vue';
|
||||
import ActivityList from '@/components/profile/ActivityList.vue';
|
||||
import InstrumentActivityList from '@/components/profile/InstrumentActivityList.vue';
|
||||
import { TopicNode } from '@/__generated__/graphql';
|
||||
|
||||
const HIGHLIGHTS = 'highlights';
|
||||
|
|
@ -188,10 +111,25 @@ const SURVEYS = 'surveys';
|
|||
|
||||
const selectedCategory = ref(HIGHLIGHTS);
|
||||
|
||||
// todo: use fragments to simplify cache updates
|
||||
const { result } = useQuery(
|
||||
graphql(`
|
||||
query MyActivitiesQuery {
|
||||
myActivities {
|
||||
instruments {
|
||||
id
|
||||
slug
|
||||
title
|
||||
path
|
||||
highlights {
|
||||
...HighlightParts
|
||||
}
|
||||
bookmarks {
|
||||
... on InstrumentBookmarkNode {
|
||||
path
|
||||
}
|
||||
}
|
||||
}
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
|
@ -262,6 +200,7 @@ const { result } = useQuery(
|
|||
`)
|
||||
);
|
||||
const topics = computed(() => result.value?.myActivities?.topics || []);
|
||||
const instruments = computed(() => result.value?.myActivities?.instruments || []);
|
||||
const highlightTopics = computed(() => {
|
||||
return topics.value.filter((topic: TopicNode) => topic.modules?.some((module) => module?.myHighlights?.length));
|
||||
});
|
||||
|
|
@ -278,6 +217,10 @@ const answersTopics = computed(() => {
|
|||
|
||||
<style lang="postcss">
|
||||
.activity {
|
||||
&__activities {
|
||||
padding-top: var(--section-spacing);
|
||||
}
|
||||
|
||||
&__heading {
|
||||
margin-bottom: var(--section-spacing);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ class BasicKnowledge(StrictHierarchyPage):
|
|||
|
||||
parent_page_types = ["books.book"]
|
||||
|
||||
intro = RichTextField(
|
||||
features=DEFAULT_RICH_TEXT_FEATURES, default="", blank=True)
|
||||
intro = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES, default="", blank=True)
|
||||
|
||||
contents = StreamField(
|
||||
[
|
||||
|
|
@ -116,3 +115,7 @@ class BasicKnowledge(StrictHierarchyPage):
|
|||
FieldPanel("intro"),
|
||||
FieldPanel("contents"),
|
||||
]
|
||||
|
||||
@property
|
||||
def route(self):
|
||||
return f"instrument/{self.slug}"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class InstrumentNode(DjangoObjectType):
|
|||
contents = GenericStreamFieldType()
|
||||
language = graphene.String()
|
||||
highlights = graphene.List("notes.schema.HighlightNode")
|
||||
path = graphene.String(required=True)
|
||||
|
||||
class Meta:
|
||||
model = BasicKnowledge
|
||||
|
|
@ -73,6 +74,10 @@ class InstrumentNode(DjangoObjectType):
|
|||
def resolve_highlights(root: BasicKnowledge, info, **kwargs):
|
||||
return root.highlights.filter(user=info.context.user)
|
||||
|
||||
@staticmethod
|
||||
def resolve_path(root: BasicKnowledge, info, **kwargs):
|
||||
return root.route
|
||||
|
||||
|
||||
class InstrumentQuery(object):
|
||||
instrument = graphene.Field(
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class ChapterBookmarkNode(DjangoObjectType):
|
|||
class InstrumentBookmarkNode(DjangoObjectType):
|
||||
uuid = graphene.UUID()
|
||||
note = graphene.Field(NoteNode)
|
||||
path = graphene.String(required=True)
|
||||
|
||||
class Meta:
|
||||
model = InstrumentBookmark
|
||||
|
|
@ -83,6 +84,10 @@ class InstrumentBookmarkNode(DjangoObjectType):
|
|||
filter_fields = []
|
||||
interfaces = (relay.Node,)
|
||||
|
||||
@staticmethod
|
||||
def resolve_path(root: InstrumentBookmark, info, **kwargs):
|
||||
return root.instrument.route
|
||||
|
||||
|
||||
class BookmarkNode(graphene.Union):
|
||||
class Meta:
|
||||
|
|
|
|||
|
|
@ -425,6 +425,7 @@ type InstrumentBookmarkNode implements Node {
|
|||
note: NoteNode
|
||||
uuid: UUID
|
||||
instrument: InstrumentNode!
|
||||
path: String!
|
||||
}
|
||||
|
||||
"""
|
||||
|
|
@ -450,6 +451,7 @@ type InstrumentNode implements Node {
|
|||
type: InstrumentTypeNode
|
||||
language: String
|
||||
highlights: [HighlightNode]
|
||||
path: String!
|
||||
}
|
||||
|
||||
type InstrumentTypeNode implements Node {
|
||||
|
|
@ -969,7 +971,8 @@ type InstrumentNodeEdge {
|
|||
}
|
||||
|
||||
type ActivityNode {
|
||||
topics: [TopicNode!]
|
||||
topics: [TopicNode!]!
|
||||
instruments: [InstrumentNode!]!
|
||||
}
|
||||
|
||||
"""Debugging information for the current query."""
|
||||
|
|
|
|||
|
|
@ -33,8 +33,9 @@ class UsersQuery(object):
|
|||
return BasicKnowledge.objects.filter(instrumentbookmark__user=info.context.user)
|
||||
|
||||
def resolve_my_activities(self, info, **kwargs):
|
||||
topics = Topic.objects.all()
|
||||
return {"topics": topics}
|
||||
topics = Topic.objects.live()
|
||||
instruments = BasicKnowledge.objects.live()
|
||||
return {"topics": topics, "instruments": instruments}
|
||||
|
||||
|
||||
class AllUsersQuery(object):
|
||||
|
|
|
|||
|
|
@ -242,4 +242,9 @@ class UpdateError(graphene.ObjectType):
|
|||
|
||||
|
||||
class ActivityNode(graphene.ObjectType):
|
||||
topics = graphene.List(graphene.NonNull("books.schema.nodes.TopicNode"))
|
||||
topics = graphene.List(
|
||||
graphene.NonNull("books.schema.nodes.TopicNode"), required=True
|
||||
)
|
||||
instruments = graphene.List(
|
||||
graphene.NonNull("basicknowledge.queries.InstrumentNode"), required=True
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue