Add entry count, start working on dynamic room color

This commit is contained in:
Pawel Kowalski 2018-08-23 22:14:01 +02:00
parent eee12f5871
commit 087e8ce252
5 changed files with 23 additions and 79 deletions

View File

@ -19,7 +19,7 @@
import RoomEntryCountWidget from '@/components/rooms/RoomEntryCountWidget';
export default {
props: ['title', 'appearance', 'slug', 'userGroup'],
props: ['slug', 'title', 'entryCount', 'appearance', 'userGroup'],
components: {
RoomEntryCountWidget,
@ -28,9 +28,6 @@
},
computed: {
entryCount() {
return 6 // TODO: this.entries.length
},
roomClass() {
return `room-widget--${this.appearance}`
},

View File

@ -5,6 +5,11 @@ query RoomEntriesQuery($slug: String!) {
slug
appearance
pk
userGroup {
id
name
year
}
roomentrySet {
edges {
node {

View File

@ -3,9 +3,10 @@ query RoomsQuery {
edges {
node {
id
title
appearance
slug
title
entryCount
appearance
userGroup {
id
name

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ from graphene_django import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField
from rooms.models import Room, RoomEntry
from user.schema import UserGroupNode, UserType
from user.schema import UserType
class RoomEntryType(DjangoObjectType):
@ -22,7 +22,7 @@ class RoomEntryType(DjangoObjectType):
class RoomType(DjangoObjectType):
pk = graphene.Int()
user_group = UserGroupNode()
entry_count = graphene.Int()
class Meta:
model = Room
@ -32,6 +32,9 @@ class RoomType(DjangoObjectType):
def resolve_pk(self, *args, **kwargs):
return self.id
def resolve_entry_count(self, *args, **kwargs):
return self.roomentry_set.count()
class RoomsQuery(object):
room = graphene.Field(RoomType, slug=graphene.String(), id=graphene.Int(), appearance=graphene.String())