comment in accompanying course: add loader + fix when resetting to empty string

This commit is contained in:
nobohan 2022-03-10 18:12:42 +01:00
parent ded2ac7d48
commit a8b6609dbf

View File

@ -21,6 +21,7 @@
tag-name="textarea"> tag-name="textarea">
</ckeditor> </ckeditor>
<div class="sub-comment">
<div v-if="pinnedComment" class="metadata"> <div v-if="pinnedComment" class="metadata">
{{ $t('comment.created_by', [ {{ $t('comment.created_by', [
pinnedComment.creator.text, pinnedComment.creator.text,
@ -28,6 +29,10 @@
]) ])
}} }}
</div> </div>
<div class="loading">
<i v-if="loading" class="fa fa-circle-o-notch fa-spin" :title="$t('loading')"></i>
</div>
</div>
<div> <div>
<ul class="record_actions"> <ul class="record_actions">
@ -62,7 +67,8 @@ export default {
formData: { formData: {
type: "accompanying_period_comment", type: "accompanying_period_comment",
content: '' content: ''
} },
loading: false
} }
}, },
computed: { computed: {
@ -83,8 +89,10 @@ export default {
}, },
methods: { methods: {
onContentChange() { onContentChange() {
this.loading = true;
let lastRecordedContent = this.formData.content; let lastRecordedContent = this.formData.content;
setTimeout(() => { setTimeout(() => {
if (this.formData.content !== '') {
if (lastRecordedContent === this.formData.content) { if (lastRecordedContent === this.formData.content) {
if (this.pinnedComment) { if (this.pinnedComment) {
let body = this.formData; let body = this.formData;
@ -110,6 +118,8 @@ export default {
} }
lastRecordedContent = null; lastRecordedContent = null;
} }
}
this.loading = false;
}, 3000); }, 3000);
}, },
removeComment() { removeComment() {
@ -130,4 +140,12 @@ export default {
div.ck-editor.ck-reset { div.ck-editor.ck-reset {
margin: 0.6em 0; margin: 0.6em 0;
} }
div.sub-comment {
display: flex;
justify-content: space-between;
div.loading {
margin-right: 6px;
margin-left: 6px;
}
}
</style> </style>