accompanying course comment: tentative to delete the comment

This commit is contained in:
nobohan
2022-03-04 13:56:03 +01:00
parent cde6e8f368
commit f04118218d
2 changed files with 14 additions and 41 deletions

View File

@@ -14,7 +14,7 @@
<ckeditor
name="content"
v-bind:placeholder="$t('comment.content')"
:placeholder="$t('comment.content')"
:editor="editor"
v-model="content"
@input="onContentChange"
@@ -23,16 +23,14 @@
<div v-if="pinnedComment" class="metadata">
{{ $t('comment.created_by', [
pinnedComment.creator.text,
$d(pinnedComment.createdAt.datetime, 'long')
]) }}
pinnedComment.creator.text,
$d(pinnedComment.createdAt.datetime, 'long')
])
}}
</div>
<div>
<!-- <div> //DOES NOT WORk
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-save">{{ $t('action.save') }}</button>
</li>
<li v-if="pinnedComment !== null">
<a class="btn btn-delete"
@click="removeComment">
@@ -40,7 +38,7 @@
</a>
</li>
</ul>
</div>
</div> -->
</form>
</div>
@@ -60,7 +58,7 @@ export default {
data() {
return {
editor: ClassicEditor,
formdata: {
formData: {
type: "accompanying_period_comment",
content: ''
}
@@ -72,7 +70,7 @@ export default {
},
content: {
set(value) {
this.formdata.content = value;
this.formData.content = value;
},
get() {
return (this.pinnedComment)? this.pinnedComment.content : {};
@@ -87,7 +85,7 @@ export default {
console.log('content changed');
console.log(this.pinnedComment)
if (this.pinnedComment) {
let body = this.formdata;
let body = this.formData;
Object.assign(body, {id: this.pinnedComment.id})
this.$store.dispatch('updatePinnedComment', body)
.catch(({name, violations}) => {
@@ -98,7 +96,7 @@ export default {
}
});
} else {
this.$store.dispatch('addPinnedComment', this.formdata)
this.$store.dispatch('addPinnedComment', this.formData)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
@@ -108,27 +106,8 @@ export default {
});
}
},
submitform() { //TODO deprecated, to remove
console.log(this.formdata)
this.$store.dispatch('addPinnedComment', this.formdata)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
// this.$store.dispatch('postFirstComment', this.formdata)
// .catch(({name, violations}) => {
// if (name === 'ValidationException' || name === 'AccessException') {
// violations.forEach((violation) => this.$toast.open({message: violation}));
// } else {
// this.$toast.open({message: 'An error occurred'})
// }
// });
},
removeComment() {
this.$store.dispatch('postFirstComment', {})
this.$store.dispatch('removePinnedComment', {})
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
@@ -139,11 +118,6 @@ export default {
}
}
}
/*
* TODO
* - [x] delete button in ul record_actions, but not in form
* - [ ] display updatedAt => pinnedComment fetch PATCH content changes MUST NOT change object id !!
*/
</script>
<style lang="scss">