Add filter attribute type "Alle Lehrjahre"
This commit is contained in:
parent
44f20c102b
commit
5cd1876f31
|
|
@ -63,6 +63,7 @@
|
||||||
moduleLevels {
|
moduleLevels {
|
||||||
name
|
name
|
||||||
id
|
id
|
||||||
|
filterAttributeType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
@ -70,19 +71,23 @@
|
||||||
const nullLevel = {
|
const nullLevel = {
|
||||||
name: '---',
|
name: '---',
|
||||||
id: null,
|
id: null,
|
||||||
|
filterAttributeType: 'ALL'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nullCategory = {
|
||||||
|
name: '---',
|
||||||
|
id: null,
|
||||||
|
filterAttributeType: 'ALL'
|
||||||
|
};
|
||||||
|
|
||||||
let defaultLevel = loadDefaultLevel(props.me);
|
let defaultLevel = loadDefaultLevel(props.me);
|
||||||
|
|
||||||
let selectedLevel = ref(defaultLevel);
|
let selectedLevel = ref(defaultLevel);
|
||||||
|
|
||||||
const levelOptions = computed(() => {
|
const levelOptions = computed(() => {
|
||||||
return [nullLevel, ...moduleLevelsResult.value?.moduleLevels || []];
|
return [...moduleLevelsResult.value?.moduleLevels || []];
|
||||||
});
|
});
|
||||||
|
|
||||||
const nullCategory = {
|
|
||||||
name: '---',
|
|
||||||
id: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedCategory = ref(nullCategory);
|
const selectedCategory = ref(nullCategory);
|
||||||
|
|
||||||
|
|
@ -91,12 +96,20 @@
|
||||||
moduleCategories {
|
moduleCategories {
|
||||||
name
|
name
|
||||||
id
|
id
|
||||||
|
filterAttributeType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
const categoryOptions = computed(() => {
|
const categoryOptions = computed(() => {
|
||||||
return [nullCategory, ...moduleCategoryResult.value?.moduleCategories || []];
|
if (moduleCategoryResult.value){
|
||||||
|
const moduleCategories = moduleCategoryResult.value?.moduleCategories;
|
||||||
|
|
||||||
|
// TODO: Fix this, computed must not have a sideeffect
|
||||||
|
selectedCategory.value = moduleCategories.find((category) => category.filterAttributeType === 'ALL');
|
||||||
|
return moduleCategories
|
||||||
|
}
|
||||||
|
return [...moduleCategoryResult.value?.moduleCategories || []];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -118,14 +131,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter by Lehrjahr (moduleLevel)
|
// filter by Lehrjahr (moduleLevel)
|
||||||
if (selectedLevel.value.name !== '---') {
|
if (selectedLevel.value.filterAttributeType !== 'ALL') {
|
||||||
filteredModules = filteredModules.filter((module) => {
|
filteredModules = filteredModules.filter((module) => {
|
||||||
return module.level?.id == selectedLevel.value.id;
|
return module.level?.id == selectedLevel.value.id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//filter by Lernfeld (Category)
|
//filter by Lernfeld (Category)
|
||||||
if (selectedCategory.value.name !== '---') {
|
if (selectedCategory.value.filterAttributeType !== 'ALL') {
|
||||||
filteredModules = filteredModules.filter((module) => {
|
filteredModules = filteredModules.filter((module) => {
|
||||||
return module.category?.id == selectedCategory.value.id;
|
return module.category?.id == selectedCategory.value.id;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,18 @@ from core.wagtail_utils import StrictHierarchyPage, get_default_settings
|
||||||
from users.models import SchoolClass
|
from users.models import SchoolClass
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
|
|
||||||
|
FILTER_ATTRIBUTE_TYPE = (
|
||||||
|
('all', 'All'),
|
||||||
|
('exact', 'Exact')
|
||||||
|
)
|
||||||
|
|
||||||
class ModuleLevel(models.Model):
|
class ModuleLevel(models.Model):
|
||||||
name = models.CharField(max_length=255, unique=True)
|
name = models.CharField(max_length=255, unique=True)
|
||||||
|
filter_attribute_type = models.CharField(
|
||||||
|
max_length=16,
|
||||||
|
choices=FILTER_ATTRIBUTE_TYPE,
|
||||||
|
default='exact'
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
@ -31,6 +41,11 @@ class ModuleCategory(models.Model):
|
||||||
ordering = ("name",)
|
ordering = ("name",)
|
||||||
|
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
filter_attribute_type = models.CharField(
|
||||||
|
max_length=16,
|
||||||
|
choices=FILTER_ATTRIBUTE_TYPE,
|
||||||
|
default='exact'
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}"
|
return f"{self.name}"
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ class ModuleCategoryNode(DjangoObjectType):
|
||||||
only_fields = [
|
only_fields = [
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
|
"filter_attribute_type",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,6 @@ class ModuleLevelNode(DjangoObjectType):
|
||||||
only_fields = [
|
only_fields = [
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
|
"filter_attribute_type",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -621,9 +621,15 @@ type ModuleBookmarkNode {
|
||||||
module: ModuleNode!
|
module: ModuleNode!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ModuleCategoryFilterAttributeType {
|
||||||
|
ALL
|
||||||
|
EXACT
|
||||||
|
}
|
||||||
|
|
||||||
type ModuleCategoryNode implements Node {
|
type ModuleCategoryNode implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
|
filterAttributeType: ModuleCategoryFilterAttributeType!
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModuleConnection {
|
type ModuleConnection {
|
||||||
|
|
@ -644,10 +650,23 @@ interface ModuleInterface {
|
||||||
topic: TopicNode
|
topic: TopicNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ModuleLevelFilterAttributeType {
|
||||||
|
ALL
|
||||||
|
EXACT
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModuleLevelNode implements Node {
|
||||||
|
id: ID!
|
||||||
|
name: String!
|
||||||
|
filterAttributeType: ModuleLevelFilterAttributeType!
|
||||||
|
}
|
||||||
|
|
||||||
type ModuleNode implements ModuleInterface {
|
type ModuleNode implements ModuleInterface {
|
||||||
title: String!
|
title: String!
|
||||||
slug: String!
|
slug: String!
|
||||||
metaTitle: String!
|
metaTitle: String!
|
||||||
|
level: ModuleLevelNode
|
||||||
|
category: ModuleCategoryNode
|
||||||
heroImage: String!
|
heroImage: String!
|
||||||
heroSource: String!
|
heroSource: String!
|
||||||
teaser: String!
|
teaser: String!
|
||||||
|
|
@ -665,8 +684,6 @@ type ModuleNode implements ModuleInterface {
|
||||||
myContentBookmarks(offset: Int, before: String, after: String, first: Int, last: Int): ContentBlockBookmarkNodeConnection
|
myContentBookmarks(offset: Int, before: String, after: String, first: Int, last: Int): ContentBlockBookmarkNodeConnection
|
||||||
myChapterBookmarks(offset: Int, before: String, after: String, first: Int, last: Int): ChapterBookmarkNodeConnection
|
myChapterBookmarks(offset: Int, before: String, after: String, first: Int, last: Int): ChapterBookmarkNodeConnection
|
||||||
snapshots: [SnapshotNode]
|
snapshots: [SnapshotNode]
|
||||||
categoryName: String
|
|
||||||
categoryTypeName: String
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModuleNodeConnection {
|
type ModuleNodeConnection {
|
||||||
|
|
@ -742,6 +759,7 @@ type Mutation {
|
||||||
updateSolutionVisibility(input: UpdateSolutionVisibilityInput!): UpdateSolutionVisibilityPayload
|
updateSolutionVisibility(input: UpdateSolutionVisibilityInput!): UpdateSolutionVisibilityPayload
|
||||||
updateLastModule(input: UpdateLastModuleInput!): UpdateLastModulePayload
|
updateLastModule(input: UpdateLastModuleInput!): UpdateLastModulePayload
|
||||||
updateLastTopic(input: UpdateLastTopicInput!): UpdateLastTopicPayload
|
updateLastTopic(input: UpdateLastTopicInput!): UpdateLastTopicPayload
|
||||||
|
updateLastModuleLevel(input: UpdateLastModuleLevelInput!): UpdateLastModuleLevelPayload
|
||||||
updateChapterVisibility(input: UpdateChapterVisibilityInput!): UpdateChapterVisibilityPayload
|
updateChapterVisibility(input: UpdateChapterVisibilityInput!): UpdateChapterVisibilityPayload
|
||||||
syncModuleVisibility(input: SyncModuleVisibilityInput!): SyncModuleVisibilityPayload
|
syncModuleVisibility(input: SyncModuleVisibilityInput!): SyncModuleVisibilityPayload
|
||||||
createSnapshot(input: CreateSnapshotInput!): CreateSnapshotPayload
|
createSnapshot(input: CreateSnapshotInput!): CreateSnapshotPayload
|
||||||
|
|
@ -854,6 +872,7 @@ type PrivateUserNode implements Node {
|
||||||
avatarUrl: String!
|
avatarUrl: String!
|
||||||
username: String!
|
username: String!
|
||||||
lastModule: ModuleNode
|
lastModule: ModuleNode
|
||||||
|
lastModuleLevel: ModuleLevelNode
|
||||||
lastTopic: TopicNode
|
lastTopic: TopicNode
|
||||||
email: String!
|
email: String!
|
||||||
onboardingVisited: Boolean!
|
onboardingVisited: Boolean!
|
||||||
|
|
@ -935,6 +954,8 @@ type Query {
|
||||||
topics(before: String, after: String, first: Int, last: Int): TopicConnection
|
topics(before: String, after: String, first: Int, last: Int): TopicConnection
|
||||||
modules(before: String, after: String, first: Int, last: Int): ModuleConnection
|
modules(before: String, after: String, first: Int, last: Int): ModuleConnection
|
||||||
chapters(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, title: String): ChapterNodeConnection
|
chapters(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, title: String): ChapterNodeConnection
|
||||||
|
moduleLevel(id: ID!): ModuleLevelNode
|
||||||
|
moduleLevels: [ModuleLevelNode]
|
||||||
moduleCategory(id: ID!): ModuleCategoryNode
|
moduleCategory(id: ID!): ModuleCategoryNode
|
||||||
moduleCategories: [ModuleCategoryNode]
|
moduleCategories: [ModuleCategoryNode]
|
||||||
objectiveGroup(id: ID!): ObjectiveGroupNode
|
objectiveGroup(id: ID!): ObjectiveGroupNode
|
||||||
|
|
@ -1315,6 +1336,16 @@ input UpdateLastModuleInput {
|
||||||
clientMutationId: String
|
clientMutationId: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input UpdateLastModuleLevelInput {
|
||||||
|
id: ID
|
||||||
|
clientMutationId: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateLastModuleLevelPayload {
|
||||||
|
user: PrivateUserNode
|
||||||
|
clientMutationId: String
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateLastModulePayload {
|
type UpdateLastModulePayload {
|
||||||
lastModule: ModuleNode
|
lastModule: ModuleNode
|
||||||
clientMutationId: String
|
clientMutationId: String
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue