Add instruments to the my activity page
This commit is contained in:
parent
d829d898b8
commit
66842ac1d8
|
|
@ -12,12 +12,15 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LinkBlock from '@/components/content-blocks/LinkBlock';
|
import LinkBlock from '@/components/content-blocks/LinkBlock';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {LinkBlock},
|
components: {LinkBlock},
|
||||||
props: ['bookmark'],
|
props: ['bookmark'],
|
||||||
computed: {
|
computed: {
|
||||||
content() {
|
content() {
|
||||||
return this.bookmark.contentBlock.contents.find(e => e.id === this.bookmark.uuid)
|
return this.bookmark.contentBlock
|
||||||
|
? this.bookmark.contentBlock.contents.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'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
<template>
|
||||||
|
<div class="instrument-activity" v-if="!empty">
|
||||||
|
<h3 class="instrument-activity__module-name">{{type}}</h3>
|
||||||
|
<h2 class="instrument-activity__title">{{instrument.title}}</h2>
|
||||||
|
<div class="instrument-activity__tasks activity-tasks">
|
||||||
|
<activity-entry title="Lesezeichen" class="instrument-activity__entry"
|
||||||
|
v-for="bookmark in instrument.bookmarks"
|
||||||
|
:key="bookmark.id"
|
||||||
|
v-if="applyFilter('bookmarks')"
|
||||||
|
@link="goTo(bookmark.uuid)">
|
||||||
|
<content-bookmark :bookmark="bookmark"></content-bookmark>
|
||||||
|
</activity-entry>
|
||||||
|
<activity-entry title="Notiz" class="instrument-activity__entry"
|
||||||
|
v-if="applyFilter('notes')"
|
||||||
|
v-for="note in notes"
|
||||||
|
:key="note.id"
|
||||||
|
@link="goTo(note.id)">
|
||||||
|
{{note.text}}
|
||||||
|
</activity-entry>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import {mapActions} from 'vuex'
|
||||||
|
import ContentBookmark from '@/components/profile/ContentBookmark';
|
||||||
|
import ActivityEntry from '@/components/profile/ActivityEntry';
|
||||||
|
|
||||||
|
import SCROLL_TO_MUTATION from '@/graphql/gql/local/mutations/scrollTo.gql';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['instrument', 'filter'],
|
||||||
|
components: {
|
||||||
|
ContentBookmark,
|
||||||
|
ActivityEntry
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
empty() {
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
notes() {
|
||||||
|
return this.instrument.bookmarks
|
||||||
|
.filter(b => b.note)
|
||||||
|
.map(b => b.note);
|
||||||
|
},
|
||||||
|
type() {
|
||||||
|
if (this.instrument.type === 'LANGUAGE_COMMUNICATION') {
|
||||||
|
return 'Sprache & Kommunikation';
|
||||||
|
} else {
|
||||||
|
return 'Gesellschaft';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(['scrollToAssignmentId']),
|
||||||
|
goTo(scrollTo) {
|
||||||
|
const url = `/instrument/${this.instrument.slug}/`;
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: SCROLL_TO_MUTATION,
|
||||||
|
variables: {
|
||||||
|
scrollTo
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$router.push(url);
|
||||||
|
},
|
||||||
|
applyFilter(filterCriteria) {
|
||||||
|
return !this.filter || this.filter === filterCriteria;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
@import "@/styles/_variables.scss";
|
||||||
|
@import "@/styles/_mixins.scss";
|
||||||
|
|
||||||
|
.instrument-activity {
|
||||||
|
max-width: 640px;
|
||||||
|
|
||||||
|
@include desktop {
|
||||||
|
max-width: 1020px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 639px) {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 401px) {
|
||||||
|
max-width: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
margin-bottom: 2*$large-spacing;
|
||||||
|
|
||||||
|
&__module-name {
|
||||||
|
@include regular-text;
|
||||||
|
margin-bottom: $small-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
@include heading-2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__entry {
|
||||||
|
&:first-of-type {
|
||||||
|
|
||||||
|
border-top: 1px solid $color-silver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -1,4 +1,28 @@
|
||||||
query MyActivityQuery {
|
query MyActivityQuery {
|
||||||
|
myInstrumentActivity {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
contents
|
||||||
|
type
|
||||||
|
slug
|
||||||
|
bookmarks {
|
||||||
|
id
|
||||||
|
uuid
|
||||||
|
note {
|
||||||
|
id
|
||||||
|
text
|
||||||
|
}
|
||||||
|
instrument {
|
||||||
|
id
|
||||||
|
type
|
||||||
|
contents
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
myActivity {
|
myActivity {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,26 @@
|
||||||
:key="id"
|
:key="id"
|
||||||
class="activity"></module-activity>
|
class="activity"></module-activity>
|
||||||
</div>
|
</div>
|
||||||
|
<instrument-activity
|
||||||
|
v-for="(instrument, id) in instruments"
|
||||||
|
:key="id"
|
||||||
|
:filter="filter"
|
||||||
|
:instrument="instrument">
|
||||||
|
</instrument-activity>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ModuleActivity from '@/components/profile/ModuleActivity';
|
import ModuleActivity from '@/components/profile/ModuleActivity';
|
||||||
|
import InstrumentActivity from '@/components/profile/InstrumentActivity';
|
||||||
import ActivityFilter from '@/components/profile/ActivityFilter';
|
import ActivityFilter from '@/components/profile/ActivityFilter';
|
||||||
import MY_ACTIVITY_QUERY from '@/graphql/gql/myActivity.gql'
|
import MY_ACTIVITY_QUERY from '@/graphql/gql/myActivity.gql'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ModuleActivity,
|
ModuleActivity,
|
||||||
|
InstrumentActivity,
|
||||||
ActivityFilter
|
ActivityFilter
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -34,12 +43,20 @@
|
||||||
return this.$getRidOfEdges(data).myActivity;
|
return this.$getRidOfEdges(data).myActivity;
|
||||||
},
|
},
|
||||||
pollInterval: 5000,
|
pollInterval: 5000,
|
||||||
|
},
|
||||||
|
instruments: {
|
||||||
|
query: MY_ACTIVITY_QUERY,
|
||||||
|
update(data) {
|
||||||
|
return this.$getRidOfEdges(data).myInstrumentActivity;
|
||||||
|
},
|
||||||
|
pollInterval: 5000,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
modules: [],
|
modules: [],
|
||||||
|
instruments: [],
|
||||||
filter: ''
|
filter: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ class InstrumentNode(DjangoObjectType):
|
||||||
instrument=self
|
instrument=self
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class BasicKnowledgeQuery(object):
|
class BasicKnowledgeQuery(object):
|
||||||
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
||||||
instruments = DjangoFilterConnectionField(InstrumentNode)
|
instruments = DjangoFilterConnectionField(InstrumentNode)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ from graphene_django.filter import DjangoFilterConnectionField
|
||||||
|
|
||||||
from assignments.models import StudentSubmission
|
from assignments.models import StudentSubmission
|
||||||
from assignments.schema.types import StudentSubmissionNode
|
from assignments.schema.types import StudentSubmissionNode
|
||||||
|
from basicknowledge.models import BasicKnowledge
|
||||||
|
from basicknowledge.queries import InstrumentNode
|
||||||
from books.models import Module
|
from books.models import Module
|
||||||
from books.schema.queries import ModuleNode
|
from books.schema.queries import ModuleNode
|
||||||
from users.models import User, SchoolClass
|
from users.models import User, SchoolClass
|
||||||
|
|
@ -48,6 +50,7 @@ class UsersQuery(object):
|
||||||
me = graphene.Field(UserNode)
|
me = graphene.Field(UserNode)
|
||||||
all_users = DjangoFilterConnectionField(UserNode)
|
all_users = DjangoFilterConnectionField(UserNode)
|
||||||
my_activity = DjangoFilterConnectionField(ModuleNode)
|
my_activity = DjangoFilterConnectionField(ModuleNode)
|
||||||
|
my_instrument_activity = DjangoFilterConnectionField(InstrumentNode)
|
||||||
|
|
||||||
def resolve_me(self, info, **kwargs):
|
def resolve_me(self, info, **kwargs):
|
||||||
return info.context.user
|
return info.context.user
|
||||||
|
|
@ -61,6 +64,9 @@ class UsersQuery(object):
|
||||||
def resolve_my_activity(self, info, **kwargs):
|
def resolve_my_activity(self, info, **kwargs):
|
||||||
return Module.objects.all()
|
return Module.objects.all()
|
||||||
|
|
||||||
|
def resolve_my_instrument_activity(self, info, **kwargs):
|
||||||
|
return BasicKnowledge.objects.all()
|
||||||
|
|
||||||
|
|
||||||
class AllUsersQuery(object):
|
class AllUsersQuery(object):
|
||||||
me = graphene.Field(UserNode)
|
me = graphene.Field(UserNode)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue