diff --git a/client/src/components/content-blocks/ContentComponent.vue b/client/src/components/content-blocks/ContentComponent.vue index 61fd6e28..e255f1b3 100644 --- a/client/src/components/content-blocks/ContentComponent.vue +++ b/client/src/components/content-blocks/ContentComponent.vue @@ -92,6 +92,10 @@ export default { methods: { addNote(id) { + if (!this.parent.hasOwnProperty('__typename')) { + this.parent.__typename = 'ContentBlockNode'; + } + this.$store.dispatch('addNote', { content: id, type: this.parent.__typename, diff --git a/client/src/components/instruments/FilterEntry.vue b/client/src/components/instruments/FilterEntry.vue index 8f0a56e6..5044520e 100644 --- a/client/src/components/instruments/FilterEntry.vue +++ b/client/src/components/instruments/FilterEntry.vue @@ -124,11 +124,11 @@ } &--language-communication { - @include filter-block($color-accent-2-dark); + @include filter-block($color-accent-1-dark); } &--society { - @include filter-block($color-accent-1-dark); + @include filter-block($color-accent-2-dark); } &--interdisciplinary { diff --git a/client/src/components/instruments/InstrumentEntry.vue b/client/src/components/instruments/InstrumentEntry.vue index ea127195..2650816c 100644 --- a/client/src/components/instruments/InstrumentEntry.vue +++ b/client/src/components/instruments/InstrumentEntry.vue @@ -56,19 +56,19 @@ $root: &; &__language-communication { - background-color: $color-accent-2-light; - - #{$root}__category { - color: $color-accent-2-dark; - } - } - - &__society { background-color: $color-accent-1-light; #{$root}__category { color: $color-accent-1-dark; } + } + + &__society { + background-color: $color-accent-2-light; + + #{$root}__category { + color: $color-accent-2-dark; + } } diff --git a/client/src/graphql/gql/queries/myActivity.gql b/client/src/graphql/gql/queries/myActivity.gql index 46201edc..e4ec9313 100644 --- a/client/src/graphql/gql/queries/myActivity.gql +++ b/client/src/graphql/gql/queries/myActivity.gql @@ -5,7 +5,11 @@ query MyActivityQuery { id title contents - type + type { + id + type + category + } slug bookmarks { id @@ -13,11 +17,6 @@ query MyActivityQuery { note { id text - } - instrument { - id - type - contents } } } diff --git a/client/src/helpers/update-content-bookmark-mutation.js b/client/src/helpers/update-content-bookmark-mutation.js index cedf0214..51b75574 100644 --- a/client/src/helpers/update-content-bookmark-mutation.js +++ b/client/src/helpers/update-content-bookmark-mutation.js @@ -8,56 +8,7 @@ const compareUuid = uuid => element => element.uuid === uuid; export const constructContentComponentBookmarkMutation = (uuid, bookmarked, parent, root) => { let mutation = {}; - if (parent.__typename === 'ContentBlockNode') { - mutation = { - mutation: UPDATE_CONTENT_BOOKMARK, - variables: { - input: { - uuid, - contentBlock: root, - bookmarked - } - }, - update: (store, response) => { - const query = CONTENT_BLOCK_QUERY; - const variables = {id: root}; - const data = store.readQuery({ - query, - variables - }); - - const bookmarks = data.contentBlock.bookmarks; - - if (bookmarked) { - bookmarks.push({ - note: null, - uuid, - __typename: 'ContentBlockBookmarkNode' - }); - } else { - let index = bookmarks.findIndex(compareUuid(uuid)); - if (index > -1) { - bookmarks.splice(index, 1); - } - } - - data.contentBlock.bookmarks = bookmarks; - - store.writeQuery({ - data, - query, - variables - }); - }, - optimisticResponse: { - __typename: 'Mutation', - updateContentBookmark: { - __typename: 'UpdateContentBookmarkPayload', - success: true - } - } - }; - } else { + if (parent.__typename === 'InstrumentNode') { mutation = { mutation: UPDATE_INSTRUMENT_BOOKMARK, variables: { @@ -106,6 +57,55 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare } } }; + } else { + mutation = { + mutation: UPDATE_CONTENT_BOOKMARK, + variables: { + input: { + uuid, + contentBlock: root, + bookmarked + } + }, + update: (store, response) => { + const query = CONTENT_BLOCK_QUERY; + const variables = {id: root}; + const data = store.readQuery({ + query, + variables + }); + + const bookmarks = data.contentBlock.bookmarks; + + if (bookmarked) { + bookmarks.push({ + note: null, + uuid, + __typename: 'ContentBlockBookmarkNode' + }); + } else { + let index = bookmarks.findIndex(compareUuid(uuid)); + if (index > -1) { + bookmarks.splice(index, 1); + } + } + + data.contentBlock.bookmarks = bookmarks; + + store.writeQuery({ + data, + query, + variables + }); + }, + optimisticResponse: { + __typename: 'Mutation', + updateContentBookmark: { + __typename: 'UpdateContentBookmarkPayload', + success: true + } + } + }; } return mutation; }; diff --git a/server/assignments/schema/queries.py b/server/assignments/schema/queries.py index ae25ddf2..83c12822 100644 --- a/server/assignments/schema/queries.py +++ b/server/assignments/schema/queries.py @@ -1,7 +1,6 @@ from graphene import relay from graphene_django.filter import DjangoFilterConnectionField -from assignments.models import StudentSubmission from assignments.schema.types import AssignmentNode, StudentSubmissionNode diff --git a/server/assignments/tests/test_myassignments.py b/server/assignments/tests/test_myassignments.py index ff9399fe..b7a4e205 100644 --- a/server/assignments/tests/test_myassignments.py +++ b/server/assignments/tests/test_myassignments.py @@ -1,12 +1,3 @@ -# -*- coding: utf-8 -*- -# -# ITerativ GmbH -# http://www.iterativ.ch/ -# -# Copyright (c) 2019 ITerativ GmbH. All rights reserved. -# -# Created on 2019-04-11 -# @author: chrigu from django.conf import settings import json @@ -119,6 +110,29 @@ class MyAssignemntsText(DefaultUserTestCase): } } } + myInstrumentActivity { + edges { + node { + id + title + contents + type { + id + type + category + } + slug + bookmarks { + id + uuid + note { + id + text + } + } + } + } + } } ''' diff --git a/server/notes/mutations.py b/server/notes/mutations.py index f6ec80ef..91da6a30 100644 --- a/server/notes/mutations.py +++ b/server/notes/mutations.py @@ -80,7 +80,7 @@ class AddNote(relay.ClientIDMutation): user=user ) else: - instrument = BasicKnowledge.objects.get(slug=content_block_id) + instrument = BasicKnowledge.objects.get(slug=content_block_id) bookmark = InstrumentBookmark.objects.get( instrument=instrument, uuid=content_uuid,