From 3b5897e52212879d3e7e94d2538aa566a53224db Mon Sep 17 00:00:00 2001
From: Julian Leucker <leuckerj@gmail.com>
Date: Wed, 6 Jul 2022 13:07:52 +0200
Subject: [PATCH] Use two-way data binding with lesson documentations

---
 .../js/vue/components/alsijil/CourseBook.js   | 26 ++++++++++++++++---
 .../components/alsijil/LessonDocumentation.js |  7 +++--
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/aleksis/apps/alsijil/static/js/vue/components/alsijil/CourseBook.js b/aleksis/apps/alsijil/static/js/vue/components/alsijil/CourseBook.js
index deedc2f0b..2d175ba22 100644
--- a/aleksis/apps/alsijil/static/js/vue/components/alsijil/CourseBook.js
+++ b/aleksis/apps/alsijil/static/js/vue/components/alsijil/CourseBook.js
@@ -1,6 +1,9 @@
 export default {
     methods: {
-
+        notifyChange(event) {
+          alert("Probably save the data");
+          console.log(event);
+        },
     },
     props: [],
     name: "course-book",
@@ -151,9 +154,24 @@ export default {
       <v-subheader>{{ lesson.subject.name }}</v-subheader>
       <v-row>
         <v-col v-for="item in lesson_documentations" cols="12" v-bind:key="item.id">
-          <lesson-documentation v-bind:key="item.id" :groups="lesson.groups" :excuse-types="excuse_types" :extra-marks="extra_marks"
-             :period="item.period_formatted" :personal-notes="item.personal_notes"
-            :date="item.date" :topic="item.topic" :homework="item.homework" :group-note="item.group_note"
+          <lesson-documentation
+            v-bind:key="item.id" :groups="lesson.groups" :excuse-types="excuse_types" :extra-marks="extra_marks"
+             :period="item.period_formatted"
+             
+             :personal-notes="item.personal_notes"
+             @change-personal-notes="notifyChange"
+             
+             :date="item.date"
+             @change-date="notifyChange"
+             
+             :topic="item.topic"
+             @change-topic="notifyChange"
+             
+             :homework="item.homework"
+             @change-homework="notifyChange"
+             
+             :group-note="item.group_note"
+             @change-group-note="createNotification('course-book');"
           ></lesson-documentation>
         </v-col>
       </v-row>
diff --git a/aleksis/apps/alsijil/static/js/vue/components/alsijil/LessonDocumentation.js b/aleksis/apps/alsijil/static/js/vue/components/alsijil/LessonDocumentation.js
index 21ac8b843..548bd7a50 100644
--- a/aleksis/apps/alsijil/static/js/vue/components/alsijil/LessonDocumentation.js
+++ b/aleksis/apps/alsijil/static/js/vue/components/alsijil/LessonDocumentation.js
@@ -1,5 +1,4 @@
 export default {
-    methods: {},
     props: ["date", "period", "topic", "homework", "groupNote", "personalNotes", "groups", "excuseTypes", "extraMarks"],
     name: "lesson-documentation",
     data: () => {
@@ -33,7 +32,7 @@ export default {
                   <v-date-picker
                   scrollable
                   no-title 
-                  @input="showPicker = false"
+                  @input="showPicker = false; $emit('change-date', $event)"
                   v-model="datePick"
                   ></v-date-picker>
                 </v-menu>
@@ -73,7 +72,9 @@ export default {
               rows="1"
               auto-grow
               required
+              
               :value="topic"
+              @input="$emit('change-topic', $event)"
             ></v-textarea>
             <v-textarea
               name="input-7-1"
@@ -82,6 +83,7 @@ export default {
               auto-grow
               
               :value="homework"
+              @input="$emit('change-homework', $event)"
             ></v-textarea>
             <v-textarea
               name="input-7-1"
@@ -90,6 +92,7 @@ export default {
               auto-grow
               
               :value="groupNote"
+              @input="$emit('change-group-note', $event)"
             ></v-textarea>
           </v-col>
           <v-col sm="12" md="4" lg="3">
-- 
GitLab