mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
accompanying course: allow PATCH on a comment entity
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
v-bind:placeholder="$t('comment.content')"
|
||||
:editor="editor"
|
||||
v-model="content"
|
||||
@input="onContentChange"
|
||||
tag-name="textarea">
|
||||
</ckeditor>
|
||||
|
||||
@@ -82,8 +83,34 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitform() {
|
||||
this.$store.dispatch('postFirstComment', this.formdata)
|
||||
onContentChange() {
|
||||
console.log('content changed');
|
||||
console.log(this.pinnedComment)
|
||||
if (this.pinnedComment) {
|
||||
let body = this.formdata;
|
||||
Object.assign(body, {id: this.pinnedComment.id})
|
||||
this.$store.dispatch('updatePinnedComment', body)
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
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'})
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
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}));
|
||||
@@ -91,6 +118,14 @@ export default {
|
||||
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', {})
|
||||
|
Reference in New Issue
Block a user