Display snapshot module detail
This commit is contained in:
parent
ca549e93e5
commit
70e7dc39a9
|
|
@ -62,7 +62,7 @@ import VisibilityAction from '@/components/visibility/VisibilityAction';
|
||||||
|
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
import {hidden} from '@/helpers/visibility';
|
import {hidden} from '@/helpers/visibility';
|
||||||
import {CONTENT_TYPE, CHAPTER_DESCRIPTION_TYPE, CHAPTER_TITLE_TYPE} from '@/consts/types';
|
import {CHAPTER_DESCRIPTION_TYPE, CHAPTER_TITLE_TYPE, CONTENT_TYPE} from '@/consts/types';
|
||||||
|
|
||||||
import UPDATE_CHAPTER_BOOKMARK_MUTATION from '@/graphql/gql/mutations/updateChapterBookmark.gql';
|
import UPDATE_CHAPTER_BOOKMARK_MUTATION from '@/graphql/gql/mutations/updateChapterBookmark.gql';
|
||||||
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
||||||
|
|
@ -78,7 +78,7 @@ export default {
|
||||||
BookmarkActions,
|
BookmarkActions,
|
||||||
VisibilityAction,
|
VisibilityAction,
|
||||||
ContentBlock,
|
ContentBlock,
|
||||||
AddContentButton
|
AddContentButton,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -93,7 +93,7 @@ export default {
|
||||||
return this.chapter.contentBlocks.filter(contentBlock => !hidden({
|
return this.chapter.contentBlocks.filter(contentBlock => !hidden({
|
||||||
block: contentBlock,
|
block: contentBlock,
|
||||||
schoolClass: this.schoolClass,
|
schoolClass: this.schoolClass,
|
||||||
type: CONTENT_TYPE
|
type: CONTENT_TYPE,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
note() {
|
note() {
|
||||||
|
|
@ -106,6 +106,9 @@ export default {
|
||||||
},
|
},
|
||||||
// never hidden when editing the module
|
// never hidden when editing the module
|
||||||
titleHidden() {
|
titleHidden() {
|
||||||
|
if (this.chapter.titleHidden === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return this.textHidden(CHAPTER_TITLE_TYPE) && !this.editModule;
|
return this.textHidden(CHAPTER_TITLE_TYPE) && !this.editModule;
|
||||||
},
|
},
|
||||||
descriptionGreyedOut() {
|
descriptionGreyedOut() {
|
||||||
|
|
@ -113,8 +116,11 @@ export default {
|
||||||
},
|
},
|
||||||
// never hidden when editing the module
|
// never hidden when editing the module
|
||||||
descriptionHidden() {
|
descriptionHidden() {
|
||||||
return this.textHidden(CHAPTER_DESCRIPTION_TYPE) && !this.editModule;
|
if (this.chapter.descriptionHidden === true) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return this.textHidden(CHAPTER_DESCRIPTION_TYPE) && !this.editModule;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -125,15 +131,15 @@ export default {
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
chapter: id,
|
chapter: id,
|
||||||
bookmarked
|
bookmarked,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
update: (store, response) => {
|
update: (store, response) => {
|
||||||
const query = CHAPTER_QUERY;
|
const query = CHAPTER_QUERY;
|
||||||
const variables = {id};
|
const variables = {id};
|
||||||
const data = store.readQuery({
|
const data = store.readQuery({
|
||||||
query,
|
query,
|
||||||
variables
|
variables,
|
||||||
});
|
});
|
||||||
|
|
||||||
const chapter = data.chapter;
|
const chapter = data.chapter;
|
||||||
|
|
@ -141,7 +147,7 @@ export default {
|
||||||
if (bookmarked) {
|
if (bookmarked) {
|
||||||
chapter.bookmark = {
|
chapter.bookmark = {
|
||||||
__typename: 'ChapterBookmarkNode',
|
__typename: 'ChapterBookmarkNode',
|
||||||
note: null
|
note: null,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
chapter.bookmark = null;
|
chapter.bookmark = null;
|
||||||
|
|
@ -152,22 +158,22 @@ export default {
|
||||||
store.writeQuery({
|
store.writeQuery({
|
||||||
data,
|
data,
|
||||||
query,
|
query,
|
||||||
variables
|
variables,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
optimisticResponse: {
|
optimisticResponse: {
|
||||||
__typename: 'Mutation',
|
__typename: 'Mutation',
|
||||||
updateChapterBookmark: {
|
updateChapterBookmark: {
|
||||||
__typename: 'UpdateChapterBookmarkPayload',
|
__typename: 'UpdateChapterBookmarkPayload',
|
||||||
success: true
|
success: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addNote(id) {
|
addNote(id) {
|
||||||
this.$store.dispatch('addNote', {
|
this.$store.dispatch('addNote', {
|
||||||
content: id,
|
content: id,
|
||||||
parent: this.chapter.id
|
parent: this.chapter.id,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
editNote() {
|
editNote() {
|
||||||
|
|
@ -177,9 +183,9 @@ export default {
|
||||||
return hidden({
|
return hidden({
|
||||||
block: this.chapter,
|
block: this.chapter,
|
||||||
schoolClass: this.schoolClass,
|
schoolClass: this.schoolClass,
|
||||||
type
|
type,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,14 @@ export const hidden = ({
|
||||||
visibleFor,
|
visibleFor,
|
||||||
hiddenFor,
|
hiddenFor,
|
||||||
titleHiddenFor,
|
titleHiddenFor,
|
||||||
descriptionHiddenFor
|
descriptionHiddenFor,
|
||||||
|
hidden
|
||||||
},
|
},
|
||||||
schoolClass
|
schoolClass
|
||||||
}) => {
|
}) => {
|
||||||
|
if (hidden === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CONTENT_TYPE:
|
case CONTENT_TYPE:
|
||||||
case OBJECTIVE_TYPE:
|
case OBJECTIVE_TYPE:
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
|
||||||
Hello
|
|
||||||
{{ id }}
|
|
||||||
<module :module="snapshot"/>
|
<module :module="snapshot"/>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -20,7 +16,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
Module
|
Module,
|
||||||
},
|
},
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
|
|
@ -28,9 +24,9 @@
|
||||||
query: SNAPSHOT_DETAIL_QUERY,
|
query: SNAPSHOT_DETAIL_QUERY,
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
id: this.id
|
id: this.id,
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,7 @@ class ContentBlockInterface(relay.Node):
|
||||||
title = graphene.String()
|
title = graphene.String()
|
||||||
contents = GenericStreamFieldType()
|
contents = GenericStreamFieldType()
|
||||||
type = graphene.String()
|
type = graphene.String()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_type(parent, info, **kwargs):
|
||||||
|
return parent.type
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from graphene import relay
|
||||||
|
|
||||||
class ModuleInterface(relay.Node):
|
class ModuleInterface(relay.Node):
|
||||||
pk = graphene.Int()
|
pk = graphene.Int()
|
||||||
hero_image = graphene.String()
|
hero_image = graphene.String(required=True)
|
||||||
topic = graphene.Field('books.schema.nodes.TopicNode')
|
topic = graphene.Field('books.schema.nodes.TopicNode')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
import graphene
|
import graphene
|
||||||
from graphene import relay, ObjectType
|
|
||||||
from graphene_django import DjangoObjectType
|
from graphene_django import DjangoObjectType
|
||||||
|
|
||||||
from books.models import ContentBlock
|
from books.models import ContentBlock
|
||||||
from books.schema.interfaces.contentblock import ContentBlockInterface
|
from books.schema.interfaces.contentblock import ContentBlockInterface
|
||||||
from books.utils import are_solutions_enabled_for
|
from books.utils import are_solutions_enabled_for
|
||||||
|
from core.logger import get_logger
|
||||||
from notes.models import ContentBlockBookmark
|
from notes.models import ContentBlockBookmark
|
||||||
from notes.schema import ContentBlockBookmarkNode
|
from notes.schema import ContentBlockBookmarkNode
|
||||||
from rooms.models import ModuleRoomSlug
|
from rooms.models import ModuleRoomSlug
|
||||||
|
|
||||||
from core.logger import get_logger
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -39,6 +37,8 @@ def is_solution_and_hidden_for_user(type, user, module):
|
||||||
class ContentBlockNode(DjangoObjectType):
|
class ContentBlockNode(DjangoObjectType):
|
||||||
mine = graphene.Boolean()
|
mine = graphene.Boolean()
|
||||||
bookmarks = graphene.List(ContentBlockBookmarkNode)
|
bookmarks = graphene.List(ContentBlockBookmarkNode)
|
||||||
|
hidden_for = graphene.List('users.schema.SchoolClassNode')
|
||||||
|
visible_for = graphene.List('users.schema.SchoolClassNode')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContentBlock
|
model = ContentBlock
|
||||||
|
|
@ -54,10 +54,6 @@ class ContentBlockNode(DjangoObjectType):
|
||||||
def resolve_mine(parent, info, **kwargs):
|
def resolve_mine(parent, info, **kwargs):
|
||||||
return parent.owner is not None and parent.owner.pk == info.context.user.pk
|
return parent.owner is not None and parent.owner.pk == info.context.user.pk
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def resolve_type(parent, info, **kwargs):
|
|
||||||
return parent.type
|
|
||||||
|
|
||||||
def resolve_contents(self, info, **kwargs):
|
def resolve_contents(self, info, **kwargs):
|
||||||
updated_stream_data = []
|
updated_stream_data = []
|
||||||
for content in self.contents.stream_data:
|
for content in self.contents.stream_data:
|
||||||
|
|
@ -82,6 +78,11 @@ class ContentBlockNode(DjangoObjectType):
|
||||||
content_block=self
|
content_block=self
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def resolve_hidden_for(parent, info, **kwargs):
|
||||||
|
return parent.hidden_for.all()
|
||||||
|
|
||||||
|
def resolve_visible_for(parent, info, **kwargs):
|
||||||
|
return parent.visible_for.all()
|
||||||
|
|
||||||
|
|
||||||
def process_module_room_slug_block(content):
|
def process_module_room_slug_block(content):
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ class ModuleNode(DjangoObjectType):
|
||||||
}
|
}
|
||||||
interfaces = (ModuleInterface,)
|
interfaces = (ModuleInterface,)
|
||||||
|
|
||||||
|
|
||||||
chapters = DjangoFilterConnectionField(ChapterNode)
|
chapters = DjangoFilterConnectionField(ChapterNode)
|
||||||
solutions_enabled = graphene.Boolean()
|
solutions_enabled = graphene.Boolean()
|
||||||
bookmark = graphene.Field(ModuleBookmarkNode)
|
bookmark = graphene.Field(ModuleBookmarkNode)
|
||||||
|
|
@ -36,7 +35,6 @@ class ModuleNode(DjangoObjectType):
|
||||||
my_chapter_bookmarks = DjangoFilterConnectionField(ChapterBookmarkNode)
|
my_chapter_bookmarks = DjangoFilterConnectionField(ChapterBookmarkNode)
|
||||||
snapshots = graphene.List('books.schema.nodes.SnapshotNode')
|
snapshots = graphene.List('books.schema.nodes.SnapshotNode')
|
||||||
|
|
||||||
|
|
||||||
def resolve_chapters(self, info, **kwargs):
|
def resolve_chapters(self, info, **kwargs):
|
||||||
return Chapter.get_by_parent(self)
|
return Chapter.get_by_parent(self)
|
||||||
|
|
||||||
|
|
@ -88,6 +86,7 @@ class ModuleNode(DjangoObjectType):
|
||||||
def resolve_snapshots(parent, info, **kwargs):
|
def resolve_snapshots(parent, info, **kwargs):
|
||||||
return parent.snapshots.all()
|
return parent.snapshots.all()
|
||||||
|
|
||||||
|
|
||||||
class RecentModuleNode(DjangoObjectType):
|
class RecentModuleNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RecentModule
|
model = RecentModule
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class SnapshotContentBlock:
|
||||||
self.id = content_block.id
|
self.id = content_block.id
|
||||||
self.pk = content_block.pk
|
self.pk = content_block.pk
|
||||||
self.title = content_block.title
|
self.title = content_block.title
|
||||||
self.contents = content_block.title
|
self.contents = content_block.contents
|
||||||
self.type = content_block.type
|
self.type = content_block.type
|
||||||
self.hidden = snapshot.hidden_content_blocks.filter(id=content_block.id).exists()
|
self.hidden = snapshot.hidden_content_blocks.filter(id=content_block.id).exists()
|
||||||
|
|
||||||
|
|
@ -61,21 +61,18 @@ class SnapshotChapterNode(ObjectType):
|
||||||
title_hidden = graphene.Boolean()
|
title_hidden = graphene.Boolean()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SnapshotNode(DjangoObjectType):
|
class SnapshotNode(DjangoObjectType):
|
||||||
title = graphene.String()
|
title = graphene.String()
|
||||||
# chapters = graphene.Field(SnapshotChapterNode)
|
|
||||||
snapshot_chapters = DjangoFilterConnectionField(ChapterInSnapshotNode)
|
|
||||||
chapters = graphene.List(SnapshotChapterNode)
|
chapters = graphene.List(SnapshotChapterNode)
|
||||||
|
meta_title = graphene.String()
|
||||||
|
hero_image = graphene.String()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Snapshot
|
model = Snapshot
|
||||||
interfaces = (relay.Node,)
|
interfaces = (relay.Node,)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def resolve_snapshot_chapters(parent, info, **kwargs):
|
|
||||||
# return Chapter.objects.filter(chapter_snapshots__snapshot=self)
|
|
||||||
return parent.chapters.through.objects.all()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_chapters(parent, info, **kwargs):
|
def resolve_chapters(parent, info, **kwargs):
|
||||||
return [
|
return [
|
||||||
|
|
@ -85,9 +82,19 @@ class SnapshotNode(DjangoObjectType):
|
||||||
title_hidden=chapter_snapshot.title_hidden,
|
title_hidden=chapter_snapshot.title_hidden,
|
||||||
description_hidden=chapter_snapshot.description_hidden
|
description_hidden=chapter_snapshot.description_hidden
|
||||||
)
|
)
|
||||||
for chapter_snapshot in parent.chapters.through.objects.all()
|
for chapter_snapshot in parent.chapters.through.objects.filter(snapshot=parent)
|
||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_title(parent, info, **kwargs):
|
def resolve_title(parent, info, **kwargs):
|
||||||
return parent.__str__()
|
return parent.__str__()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_meta_title(parent, info, **kwargs):
|
||||||
|
return parent.module.meta_title
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_hero_image(parent, info, **kwargs):
|
||||||
|
if parent.module.hero_image:
|
||||||
|
return parent.module.hero_image.file.url
|
||||||
|
return ''
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ type ChapterNode implements ChapterInterface {
|
||||||
descriptionHiddenFor(offset: Int, before: String, after: String, first: Int, last: Int, name: String): SchoolClassNodeConnection!
|
descriptionHiddenFor(offset: Int, before: String, after: String, first: Int, last: Int, name: String): SchoolClassNodeConnection!
|
||||||
id: ID!
|
id: ID!
|
||||||
bookmark: ChapterBookmarkNode
|
bookmark: ChapterBookmarkNode
|
||||||
contentBlocks(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, title: String): ContentBlockNodeConnection
|
contentBlocks: [ContentBlockNode]
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChapterNodeConnection {
|
type ChapterNodeConnection {
|
||||||
|
|
@ -309,8 +309,8 @@ interface ContentBlockInterface {
|
||||||
type ContentBlockNode implements ContentBlockInterface {
|
type ContentBlockNode implements ContentBlockInterface {
|
||||||
title: String
|
title: String
|
||||||
slug: String!
|
slug: String!
|
||||||
hiddenFor(offset: Int, before: String, after: String, first: Int, last: Int, name: String): SchoolClassNodeConnection!
|
hiddenFor: [SchoolClassNode]
|
||||||
visibleFor(offset: Int, before: String, after: String, first: Int, last: Int, name: String): SchoolClassNodeConnection!
|
visibleFor: [SchoolClassNode]
|
||||||
userCreated: Boolean!
|
userCreated: Boolean!
|
||||||
contents: GenericStreamFieldType
|
contents: GenericStreamFieldType
|
||||||
type: String
|
type: String
|
||||||
|
|
@ -659,7 +659,7 @@ type ModuleEdge {
|
||||||
interface ModuleInterface {
|
interface ModuleInterface {
|
||||||
id: ID!
|
id: ID!
|
||||||
pk: Int
|
pk: Int
|
||||||
heroImage: String
|
heroImage: String!
|
||||||
topic: TopicNode
|
topic: TopicNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -667,7 +667,7 @@ type ModuleNode implements ModuleInterface {
|
||||||
title: String!
|
title: String!
|
||||||
slug: String!
|
slug: String!
|
||||||
metaTitle: String!
|
metaTitle: String!
|
||||||
heroImage: String
|
heroImage: String!
|
||||||
teaser: String!
|
teaser: String!
|
||||||
intro: String!
|
intro: String!
|
||||||
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection!
|
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection!
|
||||||
|
|
@ -929,7 +929,8 @@ type SnapshotNode implements Node {
|
||||||
creator: UserNode
|
creator: UserNode
|
||||||
chapterSnapshots(offset: Int, before: String, after: String, first: Int, last: Int, id: ID): ChapterInSnapshotNodeConnection!
|
chapterSnapshots(offset: Int, before: String, after: String, first: Int, last: Int, id: ID): ChapterInSnapshotNodeConnection!
|
||||||
title: String
|
title: String
|
||||||
snapshotChapters(offset: Int, before: String, after: String, first: Int, last: Int, id: ID): ChapterInSnapshotNodeConnection
|
metaTitle: String
|
||||||
|
heroImage: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input SpellCheckInput {
|
input SpellCheckInput {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue