mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
add Comment component, make POST comment request
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="vue-component">
|
||||
<h3>{{ $t('comment.title') }}</h3>
|
||||
|
||||
<div class="error flash_message" v-if="errors.length > 0">
|
||||
{{ errors[0] }}
|
||||
</div>
|
||||
|
||||
<div v-if="firstComment">
|
||||
créé par {{ firstComment.creator.text }}
|
||||
le {{ $d(firstComment.createdAt.datetime, 'long') }}
|
||||
<div v-if="firstComment.updatedAt.datetime !== firstComment.createdAt.datetime">
|
||||
modifié par {{ firstComment.updatedBy.text }}
|
||||
le {{ $d(firstComment.updatedAt.datetime, 'long') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="submitform">
|
||||
<textarea
|
||||
name="content"
|
||||
v-bind:placeholder="$t('comment.content')"
|
||||
rows="8"
|
||||
cols="80"
|
||||
ckeditor="ckeditor"
|
||||
v-model="content">
|
||||
</textarea>
|
||||
<button type="submit" class="sc-button bt-save">{{ $t('action.save') }}</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Comment",
|
||||
data() {
|
||||
return {
|
||||
formdata: {
|
||||
content: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
comments() {
|
||||
return this.$store.state.accompanyingCourse.comments;
|
||||
},
|
||||
firstComment() {
|
||||
return this.comments[0];
|
||||
},
|
||||
content: {
|
||||
set(value) {
|
||||
this.formdata.content = value;
|
||||
},
|
||||
get() {
|
||||
return (this.comments.length > 0) ? this.comments[0].content : null ;
|
||||
}
|
||||
},
|
||||
errors() {
|
||||
return this.$store.state.errorMsg;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitform() {
|
||||
this.formdata['method'] = (!this.firstComment)? 'POST' : 'PATCH';
|
||||
this.$store.dispatch('postFirstComment', this.formdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TODO
|
||||
* - patch endpoint to update Content
|
||||
* - delete/reset button ?
|
||||
* - manage flash messages => specific component ?
|
||||
* - ckeditor
|
||||
*/
|
||||
</script>
|
Reference in New Issue
Block a user