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