Merged in feature/colors (pull request #3)
Feature/colors Approved-by: Ramon Wenger <ramon.wenger@iterativ.ch>
This commit is contained in:
commit
13a9812ba0
|
|
@ -137,6 +137,7 @@
|
|||
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_variables.scss";
|
||||
@import "@/styles/_mixins.scss";
|
||||
|
||||
.content-block {
|
||||
margin-bottom: 2.5em;
|
||||
|
|
@ -167,14 +168,16 @@
|
|||
top: 40px;
|
||||
}
|
||||
|
||||
&--yellow {
|
||||
background-color: rgba($color-accent-1, 0.15);
|
||||
border: 1px solid $color-accent-1;
|
||||
padding: 15px;
|
||||
&--base_communication {
|
||||
@include content-box($color-accent-1);
|
||||
}
|
||||
|
||||
/deep/ .button {
|
||||
border-color: $color-accent-1;
|
||||
}
|
||||
&--task {
|
||||
@include content-box($color-brand);
|
||||
}
|
||||
|
||||
&--base_society {
|
||||
@include content-box($color-accent-2);
|
||||
}
|
||||
|
||||
/deep/ p {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@
|
|||
:placeholder="titlePlaceholder"
|
||||
:value="localContentBlock.title"
|
||||
:error="error"></modal-input>
|
||||
|
||||
<checkbox :checked="localContentBlock.isAssignment"
|
||||
:item="localContentBlock"
|
||||
:label="'Aufgabe'"
|
||||
@input="setContentBlockType"
|
||||
class="contents-form__task"
|
||||
></checkbox>
|
||||
<modal-input v-if="blockType === 'RoomEntry'"
|
||||
placeholder="Untertitel für Raumeintrag erfassen"
|
||||
v-model="localContentBlock.subtitle"></modal-input>
|
||||
|
|
@ -68,6 +73,7 @@
|
|||
import AssignmentForm from '@/components/content-forms/AssignmentForm';
|
||||
import TextForm from '@/components/content-forms/TextForm';
|
||||
import TrashIcon from '@/components/icons/TrashIcon';
|
||||
import Checkbox from '@/components/Checkbox';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
|
@ -89,7 +95,8 @@
|
|||
DocumentForm,
|
||||
AssignmentForm,
|
||||
TextForm,
|
||||
TrashIcon
|
||||
TrashIcon,
|
||||
Checkbox
|
||||
},
|
||||
|
||||
data() {
|
||||
|
|
@ -99,7 +106,8 @@
|
|||
title: this.contentBlock.title,
|
||||
contents: [...this.contentBlock.contents],
|
||||
id: this.contentBlock.id || undefined,
|
||||
subtitle: this.contentBlock.subtitle
|
||||
subtitle: this.contentBlock.subtitle,
|
||||
isAssignment: this.contentBlock.type && this.contentBlock.type === 'TASK'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
@ -229,6 +237,9 @@
|
|||
return false;
|
||||
}
|
||||
this.$emit('save', this.localContentBlock);
|
||||
},
|
||||
setContentBlockType(checked, localContentBlock) {
|
||||
this.localContentBlock.isAssignment = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -274,5 +285,9 @@
|
|||
&__add {
|
||||
grid-column: 1 / span 2;
|
||||
}
|
||||
|
||||
&__task {
|
||||
margin: 15px 0 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
import EDIT_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/mutateContentBlock.gql';
|
||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
||||
import CONTENT_BLOCK_QUERY from '@/graphql/gql/contentBlockQuery.gql';
|
||||
import { setUserBlockType } from '@/helpers/content-block'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
|
@ -32,7 +33,8 @@
|
|||
input: {
|
||||
contentBlock: {
|
||||
title: contentBlock.title,
|
||||
contents: contentBlock.contents.filter(value => Object.keys(value).length > 0)
|
||||
contents: contentBlock.contents.filter(value => Object.keys(value).length > 0),
|
||||
type: setUserBlockType(contentBlock.isAssignment)
|
||||
},
|
||||
id: contentBlock.id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
<script>
|
||||
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
||||
|
||||
import store from '@/store/index';
|
||||
|
||||
import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql';
|
||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
||||
import { setUserBlockType } from '@/helpers/content-block'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
|
@ -31,7 +31,8 @@
|
|||
input: {
|
||||
contentBlock: {
|
||||
title: contentBlock.title,
|
||||
contents: contentBlock.contents.filter(value => Object.keys(value).length > 0)
|
||||
contents: contentBlock.contents.filter(value => Object.keys(value).length > 0),
|
||||
type: setUserBlockType(contentBlock.isAssignment)
|
||||
},
|
||||
after: this.$store.state.contentBlockPosition.after,
|
||||
parent: this.$store.state.contentBlockPosition.parent
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
margin-bottom: 30px;
|
||||
align-items: start;
|
||||
background-color: $color-brand-light;
|
||||
padding: 20px;
|
||||
padding: 20px, 0;
|
||||
border-radius: $default-border-radius;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -177,9 +177,6 @@
|
|||
|
||||
.assignment {
|
||||
margin-bottom: 2em;
|
||||
padding: 20px;
|
||||
border-radius: $default-border-radius;
|
||||
background-color: $color-brand-light;
|
||||
|
||||
&__title {
|
||||
font-size: toRem(17px);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#import "../fragments/contentBlockParts.gql"
|
||||
|
||||
mutation AddContentBlock($input: AddContentBlockInput!) {
|
||||
addContentBlock(input: $input) {
|
||||
newContentBlock {
|
||||
id
|
||||
title
|
||||
slug
|
||||
contents
|
||||
...ContentBlockParts
|
||||
}
|
||||
errors
|
||||
clientMutationId
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#import "../fragments/contentBlockParts.gql"
|
||||
|
||||
mutation MutateContentBlock($input: MutateContentBlockInput!) {
|
||||
mutateContentBlock(input: $input) {
|
||||
contentBlock {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export function setUserBlockType(isAssignment) {
|
||||
return isAssignment ? 'TASK' : 'NORMAL';
|
||||
}
|
||||
|
|
@ -32,3 +32,15 @@
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@mixin content-box($main-color) {
|
||||
background-color: rgba($main-color, 0.15);
|
||||
padding: 15px;
|
||||
align-items: start;
|
||||
border-radius: $default-border-radius;
|
||||
|
||||
/deep/ .button {
|
||||
border-color: $main-color;
|
||||
background-color: $color-white;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
class Meta:
|
||||
model = ContentBlock
|
||||
|
||||
type = factory.LazyAttribute(lambda x: random.choice(['plain', 'yellow', 'green', 'blue']))
|
||||
type = factory.LazyAttribute(lambda x: random.choice(['normal', 'base_communication', 'task', 'base_society']))
|
||||
|
||||
contents = wagtail_factories.StreamFieldFactory({
|
||||
'text_block': TextBlockFactory,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-15 12:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('books', '0002_auto_20181011_1345'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='contentblock',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('normal', 'Normal'), ('base_communication', 'Basiswissen Sprache & Kommunikation'), ('task', 'Aufgabe'), ('base_society', 'Basiswissen Gesellschaft')], default='normal', max_length=100),
|
||||
),
|
||||
]
|
||||
|
|
@ -19,16 +19,16 @@ class ContentBlock(StrictHierarchyPage):
|
|||
verbose_name = 'Inhaltsblock'
|
||||
verbose_name_plural = 'Inhaltsblöcke'
|
||||
|
||||
PLAIN = 'plain'
|
||||
YELLOW = 'yellow'
|
||||
GREEN = 'green'
|
||||
BLUE = 'blue'
|
||||
NORMAL = 'normal'
|
||||
BASE_COMMUNICATION = 'base_communication'
|
||||
TASK = 'task'
|
||||
BASE_SOCIETY = 'base_society'
|
||||
|
||||
TYPE_CHOICES = (
|
||||
(PLAIN, 'Normal'),
|
||||
(YELLOW, 'Gelb'),
|
||||
(GREEN, 'Grün'),
|
||||
(BLUE, 'Blau'),
|
||||
(NORMAL, 'Normal'),
|
||||
(BASE_COMMUNICATION, 'Basiswissen Sprache & Kommunikation'),
|
||||
(TASK, 'Aufgabe'),
|
||||
(BASE_SOCIETY, 'Basiswissen Gesellschaft'),
|
||||
)
|
||||
|
||||
hidden_for = models.ManyToManyField(SchoolClass, related_name='hidden_content_blocks')
|
||||
|
|
@ -50,7 +50,7 @@ class ContentBlock(StrictHierarchyPage):
|
|||
type = models.CharField(
|
||||
max_length=100,
|
||||
choices=TYPE_CHOICES,
|
||||
default=PLAIN
|
||||
default=NORMAL
|
||||
)
|
||||
|
||||
content_panels = [
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from api.utils import get_object, get_errors
|
|||
from books.models import ContentBlock, Chapter, SchoolClass
|
||||
from books.schema.inputs import ContentBlockInput
|
||||
from books.schema.queries import ContentBlockNode
|
||||
from .utils import handle_content_block
|
||||
from .utils import handle_content_block, set_user_defined_block_type
|
||||
|
||||
|
||||
class MutateContentBlock(relay.ClientIDMutation):
|
||||
|
|
@ -29,6 +29,7 @@ class MutateContentBlock(relay.ClientIDMutation):
|
|||
title = content_block_data.get('title', None)
|
||||
contents = content_block_data.get('contents', None)
|
||||
visibility_list = content_block_data.get('visibility', None)
|
||||
block_type = content_block_data.get('type', ContentBlock.NORMAL)
|
||||
|
||||
content_block = get_object(ContentBlock, id_param)
|
||||
|
||||
|
|
@ -46,6 +47,8 @@ class MutateContentBlock(relay.ClientIDMutation):
|
|||
if contents is not None:
|
||||
content_block.contents = json.dumps([handle_content_block(c, info.context) for c in contents])
|
||||
|
||||
content_block.type = set_user_defined_block_type(block_type)
|
||||
|
||||
content_block.save()
|
||||
|
||||
return cls(content_block=content_block)
|
||||
|
|
@ -74,8 +77,9 @@ class AddContentBlock(relay.ClientIDMutation):
|
|||
|
||||
title = content_block_data.get('title')
|
||||
contents = content_block_data.get('contents')
|
||||
block_type = set_user_defined_block_type(content_block_data.get('type', ContentBlock.NORMAL))
|
||||
|
||||
new_content_block = ContentBlock(title=title, user_created=True, owner=context.user)
|
||||
new_content_block = ContentBlock(title=title, user_created=True, owner=context.user, type=block_type)
|
||||
|
||||
if parent is not None:
|
||||
parent_chapter = get_object(Chapter, parent).specific
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import bleach
|
|||
import re
|
||||
|
||||
from assignments.models import Assignment
|
||||
from books.models import ContentBlock
|
||||
|
||||
|
||||
def newlines_to_paragraphs(text):
|
||||
|
|
@ -83,3 +84,10 @@ def handle_content_block(content, context, allowed_blocks=ALLOWED_BLOCKS):
|
|||
}}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def set_user_defined_block_type(block_type):
|
||||
if block_type == ContentBlock.TASK.upper():
|
||||
return ContentBlock.TASK
|
||||
else:
|
||||
return ContentBlock.NORMAL
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class ContentBlockNode(DjangoObjectType):
|
|||
def resolve_mine(self, info, **kwargs):
|
||||
return self.owner is not None and self.owner.pk == info.context.user.pk
|
||||
|
||||
|
||||
class ChapterNode(DjangoObjectType):
|
||||
content_blocks = DjangoFilterConnectionField(ContentBlockNode)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,21 @@ class NewContentBlockMutationTest(TestCase):
|
|||
def test_add_new_content_block(self):
|
||||
self.assertEqual(ContentBlock.objects.count(), 1)
|
||||
|
||||
mutation = get_graphql_mutation('addContentBlock.gql')
|
||||
mutation = """
|
||||
mutation AddContentBlock($input: AddContentBlockInput!) {
|
||||
addContentBlock(input: $input) {
|
||||
newContentBlock {
|
||||
id
|
||||
title
|
||||
slug
|
||||
contents
|
||||
type
|
||||
}
|
||||
errors
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
title = "Hello World"
|
||||
|
||||
|
|
@ -59,7 +73,21 @@ class NewContentBlockMutationTest(TestCase):
|
|||
def test_addNewContentBlock_withImageUrlBlock(self):
|
||||
self.assertEqual(ContentBlock.objects.count(), 1)
|
||||
|
||||
mutation = get_graphql_mutation('addContentBlock.gql')
|
||||
mutation = """
|
||||
mutation AddContentBlock($input: AddContentBlockInput!) {
|
||||
addContentBlock(input: $input) {
|
||||
newContentBlock {
|
||||
id
|
||||
title
|
||||
slug
|
||||
contents
|
||||
type
|
||||
}
|
||||
errors
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
title = "Hello World"
|
||||
|
||||
|
|
@ -67,6 +95,7 @@ class NewContentBlockMutationTest(TestCase):
|
|||
'input': {
|
||||
"contentBlock": {
|
||||
"title": title,
|
||||
"type": "NORMAL",
|
||||
"contents": [
|
||||
{
|
||||
"type": "image_url_block",
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ data = [
|
|||
'title': '1.1 Lehrbeginn',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 1',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -102,7 +102,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 2',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -139,7 +139,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'yellow',
|
||||
'type': 'base_communication',
|
||||
'title': 'Das Interview',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -151,7 +151,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 3',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -175,7 +175,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 4',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -199,7 +199,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'normal',
|
||||
'title': 'Tipp',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -216,7 +216,7 @@ data = [
|
|||
'title': '1.2 Die drei Lernorte',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'blue',
|
||||
'type': 'base_society',
|
||||
'title': 'Das Berufsbildungssystem',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -246,7 +246,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 5',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -271,7 +271,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 6',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -283,7 +283,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 7',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -325,7 +325,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 8',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -381,7 +381,7 @@ data = [
|
|||
'title': '2.1 Eine Welt ohne Geld?',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 1',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -433,7 +433,7 @@ data = [
|
|||
'title': '2.2 Geld regiert die Welt',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 2',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -493,7 +493,7 @@ data = [
|
|||
'title': '2.3 Funktionen der Geschäftsbanken',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'yellow',
|
||||
'type': 'base_communication',
|
||||
'title': 'Basiswissen: Notizen',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -505,7 +505,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 3',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -535,7 +535,7 @@ data = [
|
|||
'title': '2.4 Geld aufbewahren',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'yellow',
|
||||
'type': 'base_communication',
|
||||
'title': 'Basiswissen: Geldanlage',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -547,7 +547,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'yellow',
|
||||
'type': 'base_communication',
|
||||
'title': 'Basiswissen: Anlageformen',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -559,7 +559,7 @@ data = [
|
|||
]
|
||||
},
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 4',
|
||||
'contents': [
|
||||
{
|
||||
|
|
@ -608,7 +608,7 @@ data = [
|
|||
'title': '2.5 Geldinstitute im Vergleich',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'plain',
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 5',
|
||||
'contents': [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue