Skip to content
Snippets Groups Projects
Commit 5c55e982 authored by Julian's avatar Julian
Browse files

Update LessonDocumentations using mutation

parent 0d344581
No related branches found
No related tags found
No related merge requests found
...@@ -6,112 +6,158 @@ export default { ...@@ -6,112 +6,158 @@ export default {
valid: false, valid: false,
showPicker: false, showPicker: false,
dateAndPeriodEditable: false, dateAndPeriodEditable: false,
// We use reactive properties and set the values *once*.
// Otherwise Vue won't allow this, as we aren't allowed to edit props via v-model.
editTopic: "",
editHomework: "",
editGroupNote: "",
}
},
created() {
this.editTopic = this.topic;
this.editHomework = this.homework;
this.editGroupNote = this.groupNote;
},
computed: {
lessonDocumentationMutationInputObject() {
return {
id: this.id,
topic: this.editTopic,
groupNote: this.editGroupNote,
homework: this.editHomework,
}
}
},
methods: {
onDone(data) {
console.log("Hello")
console.log(data)
} }
}, },
template: ` template: `
<v-card elevation="2"> <ApolloMutation
<v-form v-model="valid"> :mutation="gql => gql\`
<v-row class="ma-0"> mutation UpdateLessonDocumentation($input: LessonDocumentationMutationInput!) {
<v-col cols="12" md="4" lg="3" xl="2"> updateLessonDocumentation(input: $input) {
<v-hover v-slot="{ hover }"> lessonDocumentation {
<div> id
<v-menu topic
v-model="showPicker" groupNote
:close-on-content-click="false" homework
transition="scale-transition" }
offset-y }
min-width="auto" }
> \`"
<template v-slot:activator="{ on, attrs }"> :variables="{ input: lessonDocumentationMutationInputObject }"
<v-card-title> @done="onDone"
<span v-text="new Date(date).toLocaleDateString($root.languageCode)" class="ma-1"></span> >
<v-btn right v-bind="attrs" v-on="on" icon v-if="hover && dateAndPeriodEditable"> <template v-slot="{ mutate, loading, error }">
<v-icon>mdi-pencil-outline</v-icon> <v-card elevation="2" :loading="loading">
</v-btn> <v-form v-model="valid">
</v-card-title> <v-row class="ma-0">
</template> <v-col cols="12" md="4" lg="3" xl="2">
<v-date-picker <v-hover v-slot="{ hover }">
scrollable <div>
no-title <v-menu
@input="showPicker = false; $emit('change-date', $event)" v-model="showPicker"
v-model="date" :close-on-content-click="false"
></v-date-picker> transition="scale-transition"
</v-menu> offset-y
</div> min-width="auto"
</v-hover>
<v-hover v-slot="{ hover }">
<div>
<v-menu offset-y>
<template v-slot:activator="{ on, attrs }">
<v-card-title>
<span v-text="period" class="ma-1"></span>
<!-- (this.$root.django.gettext('%s. Period'), period)-->
<v-btn
right
v-bind="attrs"
v-on="on"
icon
v-if="hover && dateAndPeriodEditable"
>
<v-icon>mdi-pencil-outline</v-icon>
</v-btn>
</v-card-title>
</template>
<v-list>
<!-- Fixme: load valid lessons -->
<v-list-item
v-for="(item, index) in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
:key="index"
> >
<v-list-item-title>{{ item }}</v-list-item-title> <template v-slot:activator="{ on, attrs }">
</v-list-item> <v-card-title>
</v-list> <span v-text="new Date(date).toLocaleDateString($root.languageCode)" class="ma-1"></span>
</v-menu> <v-btn right v-bind="attrs" v-on="on" icon v-if="hover && dateAndPeriodEditable">
</div> <v-icon>mdi-pencil-outline</v-icon>
</v-hover> </v-btn>
</v-col> </v-card-title>
<v-col cols="12" md="4" lg="6" xl="7"> </template>
<v-textarea <v-date-picker
name="input-7-1" scrollable
:label="this.$root.django.gettext('Topic')" no-title
rows="1" @input="showPicker = false; $emit('change-date', $event)"
auto-grow v-model="date"
required ></v-date-picker>
</v-menu>
:value="topic" </div>
@input="$emit('change-topic', $event)" </v-hover>
></v-textarea> <v-hover v-slot="{ hover }">
<v-textarea <div>
name="input-7-1" <v-menu offset-y>
:label="this.$root.django.gettext('Homework')" <template v-slot:activator="{ on, attrs }">
rows="1" <v-card-title>
auto-grow <span v-text="period" class="ma-1"></span>
<v-btn
:value="homework" right
@input="$emit('change-homework', $event)" v-bind="attrs"
></v-textarea> v-on="on"
<v-textarea icon
name="input-7-1" v-if="hover && dateAndPeriodEditable"
:label="this.$root.django.gettext('Group note')" >
rows="1" <v-icon>mdi-pencil-outline</v-icon>
auto-grow </v-btn>
</v-card-title>
:value="groupNote" </template>
@input="$emit('change-group-note', $event)" <v-list>
></v-textarea> <!-- Fixme: load valid lessons -->
</v-col> <v-list-item
<v-col cols="12" md="4" lg="3"> v-for="(item, index) in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
<personal-notes :key="index"
:groups="groups" >
:excuse-types="excuseTypes" <v-list-item-title>{{ item }}</v-list-item-title>
:extra-marks="extraMarks" </v-list-item>
</v-list>
v-model="personalNotes" </v-menu>
@change="$emit('change-personal-notes', $event)" </div>
></personal-notes> </v-hover>
</v-col> </v-col>
</v-row> <v-col cols="12" md="4" lg="6" xl="7">
</v-form> <message-box type="error" v-if="error">Error updating data</message-box>
</v-card> <v-textarea
name="input-7-1"
:label="$root.django.gettext('Topic')"
rows="1"
auto-grow
required
v-model="editTopic"
@change="mutate()"
></v-textarea>
<v-textarea
name="input-7-1"
:label="$root.django.gettext('Homework')"
rows="1"
auto-grow
v-model="editHomework"
@change="mutate()"
></v-textarea>
<v-textarea
name="input-7-1"
:label="$root.django.gettext('Group note')"
rows="1"
auto-grow
v-model="editGroupNote"
@change="mutate()"
></v-textarea>
</v-col>
<v-col cols="12" md="4" lg="3">
<personal-notes
:groups="groups"
:excuse-types="excuseTypes"
:extra-marks="extraMarks"
v-model="personalNotes"
@change="$emit('change-personal-notes', $event)"
></personal-notes>
</v-col>
</v-row>
</v-form>
</v-card>
</template>
</ApolloMutation>
` `
} }
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