CommentReplyForm.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div class="my-3">
  3. <div class="d-flex align-items-top reply-form child-reply-form">
  4. <img class="shadow-sm media-avatar border" :src="profile.avatar" width="40" height="40" draggable="false" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg?v=0';">
  5. <div style="display: flex;flex-grow: 1;position: relative;">
  6. <textarea
  7. class="form-control bg-light rounded-lg shadow-sm" style="resize: none;padding-right: 60px;"
  8. placeholder="Write a comment...."
  9. v-model="replyContent"
  10. :disabled="isPostingReply" />
  11. <button
  12. class="btn btn-sm py-1 font-weight-bold ml-1 rounded-pill"
  13. :class="[replyContent && replyContent.length ? 'btn-primary' : 'btn-outline-muted']"
  14. @click="storeComment"
  15. :disabled="!replyContent || !replyContent.length"
  16. style="position: absolute;right:10px;top:50%;transform:translateY(-50%)">
  17. Post
  18. </button>
  19. </div>
  20. </div>
  21. <p class="text-right small font-weight-bold text-lighter">{{ replyContent ? replyContent.length : 0 }}/{{ config.uploader.max_caption_length }}</p>
  22. </div>
  23. </template>
  24. <script type="text/javascript">
  25. export default {
  26. props: {
  27. parentId: {
  28. type: String
  29. }
  30. },
  31. data() {
  32. return {
  33. config: App.config,
  34. isPostingReply: false,
  35. replyContent: '',
  36. profile: window._sharedData.user,
  37. sensitive: false
  38. }
  39. },
  40. methods: {
  41. storeComment() {
  42. this.isPostingReply = true;
  43. axios.post('/api/v1/statuses', {
  44. status: this.replyContent,
  45. in_reply_to_id: this.parentId,
  46. sensitive: this.sensitive
  47. })
  48. .then(res => {
  49. this.replyContent = undefined;
  50. this.isPostingReply = false;
  51. this.$emit('new-comment', res.data);
  52. // this.ids.push(res.data.id);
  53. // this.feed.push(res.data);
  54. })
  55. },
  56. }
  57. }
  58. </script>