Add instrument type query
This commit is contained in:
parent
66a0427183
commit
ac6c60f8c3
|
|
@ -23,6 +23,8 @@
|
||||||
import Checkbox from '@/components/ui/Checkbox';
|
import Checkbox from '@/components/ui/Checkbox';
|
||||||
import FilterGroup from '@/components/instruments/FilterGroup';
|
import FilterGroup from '@/components/instruments/FilterGroup';
|
||||||
|
|
||||||
|
import INSTRUMENT_TYPES_QUERY from 'gql/queries/instrumentTypesQuery';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -55,6 +57,12 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
apollo: {
|
||||||
|
instrumentTypes: {
|
||||||
|
query: INSTRUMENT_TYPES_QUERY
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
change(enabled, index) {
|
change(enabled, index) {
|
||||||
let type = this.types[index];
|
let type = this.types[index];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
query InstrumentTypesQuery {
|
||||||
|
instrumentTypes {
|
||||||
|
name
|
||||||
|
category
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
query InstrumentsQuery($type: String!){
|
|
||||||
instruments(type: $type) {
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
contents
|
|
||||||
slug
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,5 +5,6 @@ query InstrumentsQuery {
|
||||||
contents
|
contents
|
||||||
slug
|
slug
|
||||||
type
|
type
|
||||||
|
category
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.24 on 2021-10-30 20:04
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('basicknowledge', '0009_auto_20211020_1213'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='basicknowledge',
|
||||||
|
old_name='type',
|
||||||
|
new_name='old_type',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -6,12 +6,21 @@ from graphene_django.filter import DjangoFilterConnectionField
|
||||||
from api.utils import get_object
|
from api.utils import get_object
|
||||||
from notes.models import InstrumentBookmark
|
from notes.models import InstrumentBookmark
|
||||||
from notes.schema import InstrumentBookmarkNode
|
from notes.schema import InstrumentBookmarkNode
|
||||||
from .models import BasicKnowledge
|
from .models import BasicKnowledge, InstrumentType
|
||||||
|
|
||||||
|
|
||||||
|
class InstrumentTypeNode(DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = InstrumentType
|
||||||
|
only_fields = [
|
||||||
|
'name', 'category'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class InstrumentNode(DjangoObjectType):
|
class InstrumentNode(DjangoObjectType):
|
||||||
bookmarks = graphene.List(InstrumentBookmarkNode)
|
bookmarks = graphene.List(InstrumentBookmarkNode)
|
||||||
type = graphene.String()
|
type = graphene.String()
|
||||||
|
category = graphene.String()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BasicKnowledge
|
model = BasicKnowledge
|
||||||
|
|
@ -25,6 +34,10 @@ class InstrumentNode(DjangoObjectType):
|
||||||
def resolve_type(root: BasicKnowledge, info, **kwargs):
|
def resolve_type(root: BasicKnowledge, info, **kwargs):
|
||||||
return root.new_type.name
|
return root.new_type.name
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_category(root: BasicKnowledge, info, **kwargs):
|
||||||
|
return root.new_type.category
|
||||||
|
|
||||||
def resolve_bookmarks(self, info, **kwargs):
|
def resolve_bookmarks(self, info, **kwargs):
|
||||||
return InstrumentBookmark.objects.filter(
|
return InstrumentBookmark.objects.filter(
|
||||||
user=info.context.user,
|
user=info.context.user,
|
||||||
|
|
@ -34,6 +47,7 @@ class InstrumentNode(DjangoObjectType):
|
||||||
class InstrumentQuery(object):
|
class InstrumentQuery(object):
|
||||||
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
instrument = graphene.Field(InstrumentNode, slug=graphene.String(), id=graphene.ID())
|
||||||
instruments = graphene.List(InstrumentNode)
|
instruments = graphene.List(InstrumentNode)
|
||||||
|
instrument_types = graphene.List(InstrumentTypeNode)
|
||||||
|
|
||||||
def resolve_instrument(self, info, **kwargs):
|
def resolve_instrument(self, info, **kwargs):
|
||||||
slug = kwargs.get('slug')
|
slug = kwargs.get('slug')
|
||||||
|
|
@ -47,3 +61,6 @@ class InstrumentQuery(object):
|
||||||
|
|
||||||
def resolve_instruments(self, info, **kwargs):
|
def resolve_instruments(self, info, **kwargs):
|
||||||
return BasicKnowledge.objects.all().live()
|
return BasicKnowledge.objects.all().live()
|
||||||
|
|
||||||
|
def resolve_instrument_types(self, info, **kwargs):
|
||||||
|
return InstrumentType.objects.all()
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,6 @@ type AssignmentNodeEdge {
|
||||||
cursor: String!
|
cursor: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BasicKnowledgeType {
|
|
||||||
LANGUAGE_COMMUNICATION
|
|
||||||
SOCIETY
|
|
||||||
INTERDISCIPLINARY
|
|
||||||
}
|
|
||||||
|
|
||||||
type ChapterBookmarkNode implements Node {
|
type ChapterBookmarkNode implements Node {
|
||||||
user: PrivateUserNode!
|
user: PrivateUserNode!
|
||||||
note: NoteNode
|
note: NoteNode
|
||||||
|
|
@ -462,6 +456,7 @@ type CustomQuery {
|
||||||
projects: [ProjectNode]
|
projects: [ProjectNode]
|
||||||
instrument(slug: String, id: ID): InstrumentNode
|
instrument(slug: String, id: ID): InstrumentNode
|
||||||
instruments: [InstrumentNode]
|
instruments: [InstrumentNode]
|
||||||
|
instrumentTypes: [InstrumentTypeNode]
|
||||||
studentSubmission(id: ID!): StudentSubmissionNode
|
studentSubmission(id: ID!): StudentSubmissionNode
|
||||||
assignment(id: ID!): AssignmentNode
|
assignment(id: ID!): AssignmentNode
|
||||||
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection
|
assignments(offset: Int, before: String, after: String, first: Int, last: Int): AssignmentNodeConnection
|
||||||
|
|
@ -484,7 +479,7 @@ type CustomQuery {
|
||||||
me: PrivateUserNode
|
me: PrivateUserNode
|
||||||
allUsers(offset: Int, before: String, after: String, first: Int, last: Int, username: String, email: String): PrivateUserNodeConnection
|
allUsers(offset: Int, before: String, after: String, first: Int, last: Int, username: String, email: String): PrivateUserNodeConnection
|
||||||
myActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, slug_Icontains: String, slug_In: [String], title: String, title_Icontains: String, title_In: [String]): ModuleNodeConnection
|
myActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, slug_Icontains: String, slug_In: [String], title: String, title_Icontains: String, title_In: [String]): ModuleNodeConnection
|
||||||
myInstrumentActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, type: String): InstrumentNodeConnection
|
myInstrumentActivity(offset: Int, before: String, after: String, first: Int, last: Int, slug: String): InstrumentNodeConnection
|
||||||
_debug: DjangoDebug
|
_debug: DjangoDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -609,9 +604,10 @@ type InstrumentNode implements Node {
|
||||||
slug: String!
|
slug: String!
|
||||||
intro: String!
|
intro: String!
|
||||||
contents: GenericStreamFieldType
|
contents: GenericStreamFieldType
|
||||||
type: BasicKnowledgeType!
|
|
||||||
id: ID!
|
id: ID!
|
||||||
bookmarks: [InstrumentBookmarkNode]
|
bookmarks: [InstrumentBookmarkNode]
|
||||||
|
type: String
|
||||||
|
category: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstrumentNodeConnection {
|
type InstrumentNodeConnection {
|
||||||
|
|
@ -624,6 +620,17 @@ type InstrumentNodeEdge {
|
||||||
cursor: String!
|
cursor: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum InstrumentTypeCategory {
|
||||||
|
LANGUAGE_COMMUNICATION
|
||||||
|
SOCIETY
|
||||||
|
INTERDISCIPLINARY
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstrumentTypeNode {
|
||||||
|
name: String!
|
||||||
|
category: InstrumentTypeCategory!
|
||||||
|
}
|
||||||
|
|
||||||
scalar JSONString
|
scalar JSONString
|
||||||
|
|
||||||
input JoinClassInput {
|
input JoinClassInput {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue