Skip to content
Snippets Groups Projects
Commit 5214a215 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add filter for incomplete substitutions

parent 27cec7b9
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
......@@ -41,6 +41,16 @@ import {
@input="changeSelection"
@click:clear="changeSelection"
/>
<v-switch
:loading="$apollo.queries.groups.loading"
:label="$t('chronos.substitutions.overview.filter.missing')"
v-model="incomplete"
dense
inset
hide-details
class="ml-6"
/>
<v-alert type="info" outlined dense class="full-width">
<v-row align="center" no-gutters>
<v-col class="grow">
......@@ -115,6 +125,7 @@ export default {
gqlQuery: amendedLessonsFromAbsences,
gqlPatchMutation: createOrUpdateSubstitutions,
groups: [],
incomplete: false,
};
},
methods: {
......@@ -136,6 +147,7 @@ export default {
gqlQueryArgs() {
return {
objId: this.objId ? Number(this.objId) : null,
incomplete: !!this.incomplete,
};
},
currentGroup() {
......
......@@ -172,11 +172,13 @@ query amendedLessonsFromAbsences(
$objId: ID
$dateStart: Date!
$dateEnd: Date!
$incomplete: Boolean
) {
items: amendedLessonsFromAbsences(
objId: $objId
dateStart: $dateStart
dateEnd: $dateEnd
incomplete: $incomplete
) {
id
oldId
......
......@@ -52,7 +52,8 @@
"button": "Manage absences"
},
"filter": {
"groups": "Filter by groups"
"groups": "Filter by groups",
"missing": "Only show incomplete lessons"
},
"cancel": {
"cancelled": "Cancelled",
......
......@@ -1584,6 +1584,7 @@ class LessonEvent(CalendarEvent):
request: HttpRequest,
obj_type: Optional[str],
obj_id: Optional[str],
incomplete: Optional[bool] = False,
) -> list:
"""Get all the amended lessons for an object and a time frame.
......@@ -1638,6 +1639,8 @@ class LessonEvent(CalendarEvent):
)
if existing_substitutions.exists():
if incomplete:
continue
substitution = existing_substitutions.first()
substitutions.append(substitution)
......
......@@ -268,6 +268,7 @@ class Query(graphene.ObjectType):
obj_id=graphene.ID(required=False),
date_start=graphene.Date(required=True),
date_end=graphene.Date(required=True),
incomplete=graphene.Boolean(required=False),
)
def resolve_timetable_teachers(self, info, **kwargs):
......@@ -311,7 +312,7 @@ class Query(graphene.ObjectType):
return all_timetables
def resolve_amended_lessons_from_absences(
root, info, date_start, date_end, obj_type="GROUP", obj_id=None, **kwargs
root, info, date_start, date_end, obj_type="GROUP", obj_id=None, incomplete=False, **kwargs
):
datetime_start = datetime.combine(date_start, datetime.min.time())
datetime_end = datetime.combine(date_end, datetime.max.time())
......@@ -327,7 +328,7 @@ class Query(graphene.ObjectType):
raise PermissionDenied()
return LessonEvent.get_for_substitution_overview(
datetime_start, datetime_end, info.context, obj_type, obj_id
datetime_start, datetime_end, info.context, obj_type, obj_id, incomplete
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment