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

Patch substitutions directly after change

parent c21bb4cd
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
Pipeline #185448 failed
......@@ -87,6 +87,7 @@ mutation createOrUpdateSubstitutions($input: [SubstitutionInputType]!) {
createOrUpdateSubstitutions(input: $input) {
items: substitutions {
id
oldId
subject {
id
shortName
......@@ -163,6 +164,7 @@ query amendedLessonsFromAbsences(
dateEnd: $dateEnd
) {
id
oldId
subject {
id
shortName
......
......@@ -118,6 +118,28 @@ export default {
},
},
methods: {
handleUpdateAfterCreateOrPatch(itemId) {
return (cached, incoming) => {
for (const object of incoming) {
console.log("summary: handleUpdateAfterCreateOrPatch", object);
// Replace the current substitution
const index = cached.findIndex(
(o) => o[itemId] === this.substitution.id,
);
// merged with the incoming partial substitution
// if creation of proper substitution from dummy one, set ID of substitution currently being edited as oldID so that key in overview doesn't change
cached[index] = {
...this.substitution,
...object,
oldId:
this.substitution.id !== object.id
? this.substitution.id
: this.substitution.oldId,
};
}
return cached;
};
},
getTeacherStatus(teacher) {
return this.teachersWithStatus.find((t) => t.id === teacher.id)?.status;
},
......
......@@ -68,7 +68,7 @@ export default {
},
},
watch: {
documentation: {
substitution: {
handler() {
this.updateStatus();
},
......
......@@ -63,6 +63,7 @@ class LessonEventType(DjangoObjectType):
}
amends = graphene.Field(lambda: LessonEventType, required=False)
old_id = graphene.ID(required=False)
@staticmethod
def resolve_teachers(root: LessonEvent, info, **kwargs):
......
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