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

Add success/error indicator for topic field

parent 150f199c
No related branches found
No related tags found
2 merge requests!352Draft: Resolve "Add dialog with each lesson's students",!350Resolve "Add simple course book list"
Pipeline #177454 failed
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<v-list max-width="100%" class="pt-0 mt-n1"> <v-list max-width="100%" class="pt-0 mt-n1">
<v-list-item <v-list-item
v-for="doc in day.slice(1)" v-for="doc in day.slice(1)"
:key="'documentation-' + doc.id" :key="'documentation-' + (doc.oldId || doc.id)"
> >
<documentation-modal <documentation-modal
:documentation="doc" :documentation="doc"
......
...@@ -58,6 +58,7 @@ query documentationsForCoursebook( ...@@ -58,6 +58,7 @@ query documentationsForCoursebook(
datetimeEnd datetimeEnd
dateStart dateStart
dateEnd dateEnd
oldId
canEdit canEdit
canDelete canDelete
} }
...@@ -70,6 +71,7 @@ mutation createOrUpdateDocumentations($input: [DocumentationInputType]!) { ...@@ -70,6 +71,7 @@ mutation createOrUpdateDocumentations($input: [DocumentationInputType]!) {
topic topic
homework homework
groupNote groupNote
oldId
} }
} }
} }
...@@ -16,7 +16,13 @@ ...@@ -16,7 +16,13 @@
@keydown.enter="saveAndBlur" @keydown.enter="saveAndBlur"
:loading="loading" :loading="loading"
:readonly="!documentation.canEdit" :readonly="!documentation.canEdit"
/> >
<template #append>
<v-scroll-x-transition>
<v-icon v-if="appendIcon" :color="appendIconColor">{{ appendIcon }}</v-icon>
</v-scroll-x-transition>
</template>
</v-text-field>
<div :class="{ 'flex-grow-1 max-width': true, 'full-width': $vuetify.breakpoint.mobile }"> <div :class="{ 'flex-grow-1 max-width': true, 'full-width': $vuetify.breakpoint.mobile }">
<v-card <v-card
v-bind="dialogActivator.attrs" v-bind="dialogActivator.attrs"
...@@ -90,6 +96,7 @@ export default { ...@@ -90,6 +96,7 @@ export default {
topic: null, topic: null,
homework: null, homework: null,
groupNote: null, groupNote: null,
appendIcon: null,
}; };
}, },
methods: { methods: {
...@@ -102,11 +109,16 @@ export default { ...@@ -102,11 +109,16 @@ export default {
(o) => o[itemId] === this.documentation.id, (o) => o[itemId] === this.documentation.id,
); );
// merged with the incoming partial documentation // merged with the incoming partial documentation
cached[index] = { ...this.documentation, ...object }; // set ID of documentation currently being edited as oldID so that key in coursebook doesn't change
cached[index] = { ...this.documentation, ...object, oldId: this.documentation.id };
} }
return cached; return cached;
}; };
}, },
handleAppendIconSuccess() {
this.appendIcon = "$success";
setTimeout(() => {this.appendIcon = ""}, 3000);
},
save() { save() {
if (this.topic !== null || this.homework !== null || this.groupNote !== null) { if (this.topic !== null || this.homework !== null || this.groupNote !== null) {
const topic = this.topic !== null ? { topic: this.topic } : {}; const topic = this.topic !== null ? { topic: this.topic } : {};
...@@ -131,6 +143,9 @@ export default { ...@@ -131,6 +143,9 @@ export default {
this.save(); this.save();
event.target.blur(); event.target.blur();
}, },
handleError() {
this.appendIcon = "$error";
},
}, },
computed: { computed: {
homeworkIcon() { homeworkIcon() {
...@@ -158,8 +173,14 @@ export default { ...@@ -158,8 +173,14 @@ export default {
}, },
maxWidth() { maxWidth() {
return this.$vuetify.breakpoint.mobile ? "100%" : "20ch"; return this.$vuetify.breakpoint.mobile ? "100%" : "20ch";
},
appendIconColor() {
return {"$success": "success", "$error": "error"}[this.appendIcon] || "primary";
} }
}, },
mounted() {
this.$on("save", this.handleAppendIconSuccess);
},
}; };
</script> </script>
......
...@@ -50,6 +50,8 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp ...@@ -50,6 +50,8 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp
course = graphene.Field(CourseType, required=False) course = graphene.Field(CourseType, required=False)
subject = graphene.Field(SubjectType, required=False) subject = graphene.Field(SubjectType, required=False)
old_id = graphene.ID(required=False)
@staticmethod @staticmethod
def resolve_teachers(root: Documentation, info, **kwargs): def resolve_teachers(root: Documentation, info, **kwargs):
if not str(root.pk).startswith("DUMMY") and hasattr(root, "teachers"): if not str(root.pk).startswith("DUMMY") and hasattr(root, "teachers"):
......
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