]>
git.r.bdr.sh - rbdr/dasein/blob - app/components/post_form.js
1f45f0c53f4b222cfb3427e4a89c0db7f5c36f27
1 import Axios
from 'axios';
3 import AuthService
from '../services/auth';
7 internals
.kPostsRoute
= '/api/posts';
9 export default internals
.PostFormComponent
= Vue
.component('post-form', {
10 template: '<div class="post-form-container">' +
11 '<h1>hi {{authService.user.name}}</h1>' +
12 '<button v-show="!active" class="post-submit" v-on:click="activate">Post something.</button>' +
13 '<textarea v-show="active" :disabled="submitting" v-model="content" class="post-content-input" placeholder="tell us something" maxlength=255></textarea>' +
14 '<p v-show="message" class="post-form-error">{{message}}</p>' +
15 '<button v-show="active" :disabled="submitting" class="post-submit" v-on:click="submit">Go.</button>' +
25 authService: new AuthService()
31 // Activates the form.
42 this.submitting
= true;
47 Authorization: `Bearer ${this.authService.token}`
52 url: internals
.kPostsRoute
53 }).then((response
) => {
55 this.$emit('post-submitted', response
.data
);
58 this.submitting
= false;
62 console
.error(err
.stack
);
63 this.submitting
= false;
64 this.message
= 'Error while creating the post...';