1 const comment = require('./components/comments/comment');
2 const commentReply = require('./components/comments/comment-reply');
5 totalCommentsStr: trans('entities.comments_loading'),
14 commentAdded: function () {
22 return this.commentCount;
24 set: function (value) {
25 this.commentCount = value;
27 this.totalCommentsStr = trans('entities.no_comments');
28 } else if (value === 1) {
29 this.totalCommentsStr = trans('entities.one_comment');
31 this.totalCommentsStr = trans('entities.x_comments', {
37 canComment: function () {
38 if (!this.permissions) {
41 return this.permissions.comment_create === true;
46 this.pageId = Number(this.$el.getAttribute('page-id'));
47 // let linkedCommentId = this.$route.query.cm;
48 let linkedCommentId = null;
49 this.$http.get(window.baseUrl(`/ajax/page/${this.pageId}/comments/`)).then(resp => {
50 if (!isCommentOpSuccess(resp)) {
51 // just show that no comments are available.
53 this.$events.emit('error', getErrorMsg(resp));
56 this.comments = resp.data.comments;
57 this.totalComments = +resp.data.total;
58 this.permissions = resp.data.permissions;
59 this.currentUserId = resp.data.user_id;
60 if (!linkedCommentId) {
63 focusLinkedComment(linkedCommentId);
65 this.$events.emit('error', 'errors.comment_list');
69 function isCommentOpSuccess(resp) {
70 if (resp && resp.data && resp.data.status === 'success') {
76 function getErrorMsg(response) {
78 return response.data.message;
80 return trans('errors.comment_add');
85 this.$on('new-comment', function (event, comment) {
86 this.comments.push(comment);
90 function beforeDestroy() {
91 this.$off('new-comment');
95 data, methods, mounted, computed, components: {
98 created, beforeDestroy