Rename Highlight to Bookmark
This commit is contained in:
parent
4247164067
commit
5fd81a2bd6
|
|
@ -17,12 +17,11 @@
|
||||||
<h3 v-if="instrumentLabel !== ''" class="content-block__instrument-label">{{instrumentLabel}}</h3>
|
<h3 v-if="instrumentLabel !== ''" class="content-block__instrument-label">{{instrumentLabel}}</h3>
|
||||||
<h4 class="content-block__title" v-if="!contentBlock.indent">{{contentBlock.title}}</h4>
|
<h4 class="content-block__title" v-if="!contentBlock.indent">{{contentBlock.title}}</h4>
|
||||||
|
|
||||||
|
|
||||||
<content-component v-for="component in contentBlocksWithContentLists.contents"
|
<content-component v-for="component in contentBlocksWithContentLists.contents"
|
||||||
:key="component.id"
|
:key="component.id"
|
||||||
:component="component"
|
:component="component"
|
||||||
:parent="contentBlock.id"
|
:parent="contentBlock.id"
|
||||||
:highlights="contentBlock.highlights">
|
:bookmarks="contentBlock.bookmarks">
|
||||||
</content-component>
|
</content-component>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="content-component" :class="{'content-component--highlighted': highlighted}">
|
<div class="content-component" :class="{'content-component--bookmarked': bookmarked}">
|
||||||
{{component.id}}
|
{{component.id}}
|
||||||
<a @click="highlightContent(component.id, !highlighted)">Highlight</a>
|
<a @click="bookmarkContent(component.id, !bookmarked)">Bookmark</a>
|
||||||
<div>
|
<div>
|
||||||
Highlighted: {{highlighted}}
|
Bookmarked: {{bookmarked}}
|
||||||
</div>
|
</div>
|
||||||
<component
|
<component
|
||||||
:is="component.type"
|
:is="component.type"
|
||||||
|
|
@ -29,11 +29,11 @@
|
||||||
import Survey from '@/components/content-blocks/SurveyBlock';
|
import Survey from '@/components/content-blocks/SurveyBlock';
|
||||||
import Solution from '@/components/content-blocks/Solution';
|
import Solution from '@/components/content-blocks/Solution';
|
||||||
|
|
||||||
import UPDATE_CONTENT_HIGHLIGHT from '@/graphql/gql/mutations/updateContentHighlight.gql';
|
import UPDATE_CONTENT_BOOKMARK from '@/graphql/gql/mutations/updateContentBookmark.gql';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['component', 'parent', 'highlights'],
|
props: ['component', 'parent', 'bookmarks'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
'text_block': TextBlock,
|
'text_block': TextBlock,
|
||||||
|
|
@ -55,20 +55,20 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
highlighted() {
|
bookmarked() {
|
||||||
return this.highlights.indexOf(this.component.id) > -1;
|
return this.bookmarks.indexOf(this.component.id) > -1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
highlightContent(id, highlight) {
|
bookmarkContent(id, bookmarked) {
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: UPDATE_CONTENT_HIGHLIGHT,
|
mutation: UPDATE_CONTENT_BOOKMARK,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
id,
|
id,
|
||||||
contentBlock: this.parent,
|
contentBlock: this.parent,
|
||||||
highlight
|
bookmarked
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refetchQueries: [{
|
refetchQueries: [{
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.content-component {
|
.content-component {
|
||||||
&--highlighted {
|
&--bookmarked {
|
||||||
background-color: yellow;
|
background-color: yellow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ fragment ContentBlockParts on ContentBlockNode {
|
||||||
contents
|
contents
|
||||||
userCreated
|
userCreated
|
||||||
mine
|
mine
|
||||||
highlights
|
bookmarks
|
||||||
hiddenFor {
|
hiddenFor {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
mutation UpdateContentBookmark($input: UpdateContentBookmarkInput!) {
|
||||||
|
updateContentBookmark(input: $input) {
|
||||||
|
success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
mutation UpdateContentHighlight($input: UpdateContentHighlightInput!) {
|
|
||||||
updateContentHighlight(input: $input) {
|
|
||||||
success
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.0.6 on 2019-10-01 13:25
|
# Generated by Django 2.0.6 on 2019-10-07 14:53
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='contentblock',
|
model_name='contentblock',
|
||||||
name='highlights',
|
name='bookmarks',
|
||||||
field=models.ManyToManyField(related_name='highlighted_content_blocks', through='notes.ContentBlockHighlight', to=settings.AUTH_USER_MODEL),
|
field=models.ManyToManyField(related_name='bookmarked_content_blocks', through='notes.ContentBlockBookmark', to=settings.AUTH_USER_MODEL),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
@ -10,7 +10,7 @@ from books.blocks import TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock,
|
||||||
ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock, SurveyBlock, ModuleRoomSlugBlock
|
ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock, SurveyBlock, ModuleRoomSlugBlock
|
||||||
from books.utils import get_type_and_value
|
from books.utils import get_type_and_value
|
||||||
from core.wagtail_utils import StrictHierarchyPage
|
from core.wagtail_utils import StrictHierarchyPage
|
||||||
from notes.models import Highlight, ContentBlockHighlight
|
from notes.models import ContentBlockBookmark
|
||||||
from surveys.models import Survey
|
from surveys.models import Survey
|
||||||
from users.models import SchoolClass, User
|
from users.models import SchoolClass, User
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ContentBlock(StrictHierarchyPage):
|
||||||
visible_for = models.ManyToManyField(SchoolClass, related_name='visible_content_blocks')
|
visible_for = models.ManyToManyField(SchoolClass, related_name='visible_content_blocks')
|
||||||
user_created = models.BooleanField(default=False)
|
user_created = models.BooleanField(default=False)
|
||||||
|
|
||||||
highlights = models.ManyToManyField(User, through=ContentBlockHighlight, related_name='highlighted_content_blocks')
|
bookmarks = models.ManyToManyField(User, through=ContentBlockBookmark, related_name='bookmarked_content_blocks')
|
||||||
|
|
||||||
content_blocks = [
|
content_blocks = [
|
||||||
('text_block', TextBlock()),
|
('text_block', TextBlock()),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ from books.models import ContentBlock, Chapter, SchoolClass
|
||||||
from books.schema.inputs import ContentBlockInput
|
from books.schema.inputs import ContentBlockInput
|
||||||
from books.schema.queries import ContentBlockNode
|
from books.schema.queries import ContentBlockNode
|
||||||
from core.utils import set_hidden_for, set_visible_for
|
from core.utils import set_hidden_for, set_visible_for
|
||||||
from notes.models import ContentBlockHighlight
|
from notes.models import ContentBlockBookmark
|
||||||
from .utils import handle_content_block, set_user_defined_block_type
|
from .utils import handle_content_block, set_user_defined_block_type
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -148,11 +148,11 @@ class DeleteContentBlock(relay.ClientIDMutation):
|
||||||
return cls(success=False, errors='Content block not found')
|
return cls(success=False, errors='Content block not found')
|
||||||
|
|
||||||
|
|
||||||
class UpdateContentHighlight(relay.ClientIDMutation):
|
class UpdateContentBookmark(relay.ClientIDMutation):
|
||||||
class Input:
|
class Input:
|
||||||
id = graphene.String(required=True)
|
id = graphene.String(required=True)
|
||||||
content_block = graphene.ID(required=True)
|
content_block = graphene.ID(required=True)
|
||||||
highlight = graphene.Boolean(required=True)
|
bookmarked = graphene.Boolean(required=True)
|
||||||
|
|
||||||
success = graphene.Boolean()
|
success = graphene.Boolean()
|
||||||
errors = graphene.String()
|
errors = graphene.String()
|
||||||
|
|
@ -162,18 +162,18 @@ class UpdateContentHighlight(relay.ClientIDMutation):
|
||||||
id = kwargs.get('id')
|
id = kwargs.get('id')
|
||||||
user = info.context.user
|
user = info.context.user
|
||||||
content_block_id = kwargs.get('content_block')
|
content_block_id = kwargs.get('content_block')
|
||||||
highlight = kwargs.get('highlight')
|
bookmarked = kwargs.get('bookmarked')
|
||||||
|
|
||||||
content_block = get_object(ContentBlock, content_block_id)
|
content_block = get_object(ContentBlock, content_block_id)
|
||||||
|
|
||||||
if highlight:
|
if bookmarked:
|
||||||
ContentBlockHighlight.objects.create(
|
ContentBlockBookmark.objects.create(
|
||||||
content_block=content_block,
|
content_block=content_block,
|
||||||
id=id,
|
id=id,
|
||||||
user=user
|
user=user
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
ContentBlockHighlight.objects.get(
|
ContentBlockBookmark.objects.get(
|
||||||
content_block=content_block,
|
content_block=content_block,
|
||||||
id=id,
|
id=id,
|
||||||
user=user
|
user=user
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from books.schema.mutations.contentblock import MutateContentBlock, AddContentBlock, DeleteContentBlock, \
|
from books.schema.mutations.contentblock import MutateContentBlock, AddContentBlock, DeleteContentBlock, \
|
||||||
UpdateContentHighlight
|
UpdateContentBookmark
|
||||||
from books.schema.mutations.module import UpdateSolutionVisibility, UpdateLastModule
|
from books.schema.mutations.module import UpdateSolutionVisibility, UpdateLastModule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,4 +9,4 @@ class BookMutations(object):
|
||||||
delete_content_block = DeleteContentBlock.Field()
|
delete_content_block = DeleteContentBlock.Field()
|
||||||
update_solution_visibility = UpdateSolutionVisibility.Field()
|
update_solution_visibility = UpdateSolutionVisibility.Field()
|
||||||
update_last_module = UpdateLastModule.Field()
|
update_last_module = UpdateLastModule.Field()
|
||||||
update_content_highlight = UpdateContentHighlight.Field()
|
update_content_bookmark = UpdateContentBookmark.Field()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from graphene_django.filter import DjangoFilterConnectionField
|
||||||
|
|
||||||
from api.utils import get_object
|
from api.utils import get_object
|
||||||
from books.utils import are_solutions_enabled_for
|
from books.utils import are_solutions_enabled_for
|
||||||
from notes.models import ContentBlockHighlight
|
from notes.models import ContentBlockBookmark
|
||||||
from rooms.models import ModuleRoomSlug
|
from rooms.models import ModuleRoomSlug
|
||||||
from ..models import Book, Topic, Module, Chapter, ContentBlock
|
from ..models import Book, Topic, Module, Chapter, ContentBlock
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ def process_module_room_slug_block(content):
|
||||||
|
|
||||||
class ContentBlockNode(DjangoObjectType):
|
class ContentBlockNode(DjangoObjectType):
|
||||||
mine = graphene.Boolean()
|
mine = graphene.Boolean()
|
||||||
highlights = graphene.List(graphene.String)
|
bookmarks = graphene.List(graphene.String)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContentBlock
|
model = ContentBlock
|
||||||
|
|
@ -56,8 +56,8 @@ class ContentBlockNode(DjangoObjectType):
|
||||||
self.contents.stream_data = updated_stream_data
|
self.contents.stream_data = updated_stream_data
|
||||||
return self.contents
|
return self.contents
|
||||||
|
|
||||||
def resolve_highlights(self, info, **kwargs):
|
def resolve_bookmarks(self, info, **kwargs):
|
||||||
return [highlight.id for highlight in ContentBlockHighlight.objects.filter(
|
return [bookmark.id for bookmark in ContentBlockBookmark.objects.filter(
|
||||||
user=info.context.user,
|
user=info.context.user,
|
||||||
content_block=self
|
content_block=self
|
||||||
)]
|
)]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.0.6 on 2019-10-01 13:25
|
# Generated by Django 2.0.6 on 2019-10-07 14:53
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='ContentBlockHighlight',
|
name='ContentBlockBookmark',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.UUIDField(primary_key=True, serialize=False)),
|
('id', models.UUIDField(primary_key=True, serialize=False)),
|
||||||
('content_block', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='books.ContentBlock')),
|
('content_block', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='books.ContentBlock')),
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ from core.wagtail_utils import StrictHierarchyPage
|
||||||
from users.models import User
|
from users.models import User
|
||||||
|
|
||||||
|
|
||||||
# todo: change from Highlight to Bookmark / Note (tbd)
|
class Bookmark(models.Model):
|
||||||
class Highlight(models.Model):
|
|
||||||
id = models.UUIDField(primary_key=True)
|
id = models.UUIDField(primary_key=True)
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
@ -14,5 +13,5 @@ class Highlight(models.Model):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class ContentBlockHighlight(Highlight):
|
class ContentBlockBookmark(Bookmark):
|
||||||
content_block = models.ForeignKey('books.ContentBlock', on_delete=models.CASCADE)
|
content_block = models.ForeignKey('books.ContentBlock', on_delete=models.CASCADE)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue