From 2e589ca56c374b29e38e873c1e7c03465c79cc18 Mon Sep 17 00:00:00 2001 From: Michael Bauer <michael-bauer@posteo.de> Date: Sat, 16 Mar 2024 11:42:44 +0100 Subject: [PATCH] Enable emptying of documentation fields Previously empty strings where not properly handled and the previous value persisted. --- .../documentation/LessonSummary.vue | 20 +++++++++---------- aleksis/apps/alsijil/schema/documentation.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue index 49eb534e2..3e4d21877 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue @@ -92,9 +92,9 @@ export default { emits: ["open"], data() { return { - topic: "", - homework: "", - groupNote: "", + topic: null, + homework: null, + groupNote: null, }; }, methods: { @@ -113,10 +113,10 @@ export default { }; }, save() { - if (this.topic || this.homework || this.groupNote) { - const topic = this.topic ? { topic: this.topic } : {}; - const homework = this.homework ? { homework: this.homework } : {}; - const groupNote = this.groupNote ? { groupNote: this.groupNote } : {}; + if (this.topic !== null || this.homework !== null || this.groupNote !== null) { + const topic = this.topic !== null ? { topic: this.topic } : {}; + const homework = this.homework !== null ? { homework: this.homework } : {}; + const groupNote = this.groupNote !== null ? { groupNote: this.groupNote } : {}; this.createOrPatch([ { @@ -127,9 +127,9 @@ export default { }, ]); - this.topic = ""; - this.homework = ""; - this.groupNote = ""; + this.topic = null; + this.homework = null; + this.groupNote = null; } }, saveAndBlur(event) { diff --git a/aleksis/apps/alsijil/schema/documentation.py b/aleksis/apps/alsijil/schema/documentation.py index c528540ca..71ad9c468 100644 --- a/aleksis/apps/alsijil/schema/documentation.py +++ b/aleksis/apps/alsijil/schema/documentation.py @@ -175,11 +175,11 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation): if not info.context.user.has_perm("alsijil.edit_documentation_rule", obj): raise PermissionDenied() - if doc.topic: + if doc.topic is not None: obj.topic = doc.topic - if doc.homework: + if doc.homework is not None: obj.homework = doc.homework - if doc.group_note: + if doc.group_note is not None: obj.group_note = doc.group_note obj.save() -- GitLab