]>
git.r.bdr.sh - rbdr/dasein/blob - app/components/comment_form.js
1 import Axios
from 'axios';
3 import AuthService
from '../services/auth';
7 internals
.kPostsRoute
= '/api/posts';
8 internals
.kCommentsRoute
= '/comments';
10 export default internals
.CommentFormComponent
= Vue
.component('comment-form', {
11 template: '<div class="comment-form-container">' +
12 '<p v-show="!active" class="comment-form-error">' +
13 '<button class="comment-activate" v-on:click="activate">Add comment.</button>' +
15 '<textarea v-show="active" :disabled="submitting" v-model="content" class="comment-content-input" placeholder="tell us something" maxlength=255></textarea>' +
16 '<p v-show="message" class="comment-form-error">{{message}}</p>' +
17 '<button v-show="active" :disabled="submitting" class="comment-submit" v-on:click="submit">Go.</button>' +
29 authService: new AuthService()
35 // Activates the form.
46 this.submitting
= true;
47 const route
= `${internals.kPostsRoute}/${this.postUuid}${internals.kCommentsRoute}`;
52 Authorization: `Bearer ${this.authService.token}`
58 }).then((response
) => {
60 this.$emit('comment-submitted', response
.data
);
63 this.submitting
= false;
67 console
.error(err
.stack
);
68 this.submitting
= false;
69 this.message
= 'Error while creating the post...';