- deleteComment: function () {
- var resp = window.confirm(trans('entities.comment_delete_confirm'));
- if (!resp) {
- return;
- }
- this.$http.delete(window.baseUrl(`/ajax/comment/${this.comment.id}`)).then(resp => {
- if (!isCommentOpSuccess(resp)) {
- return;
- }
- updateComment(this.comment, resp.data, true);
- }, function (resp) {
- if (isCommentOpSuccess(resp)) {
- this.$events.emit('success', trans('entities.comment_deleted'));
- } else {
- this.$events.emit('error', trans('error.comment_delete'));
- }
- });
- },
- replyComment: function () {
- this.toggleEditor(false);
- },
- editComment: function () {
- this.toggleEditor(true);
- },
- hideComment: function () {
- this.showEditor = false;
- },
- toggleEditor: function (isEdit) {
- this.showEditor = false;
- this.isEdit = isEdit;
- this.isReply = !isEdit;
- this.showEditor = true;
- },
- commentReplied: function (event, comment) {
- this.comments.push(comment);
- this.showEditor = false;
- },
- commentEdited: function (event, comment) {
- this.comment = comment;
- this.showEditor = false;
- },
- commentAdded: function (event, comment) {
- // this is to handle non-parent child relationship
- // we want to make it go up.
- this.$emit('comment-added', event);
- },
- canEditOrDelete: function (prop) {
- if (!this.comment.active) {
- return false;
- }
+ deleteComment: function () {
+ var resp = window.confirm(trans('entities.comment_delete_confirm'));
+ if (!resp) {
+ return;
+ }
+ this.$http.delete(window.baseUrl(`/ajax/comment/${this.comment.id}`)).then(resp => {
+ if (!isCommentOpSuccess(resp)) {
+ this.$events.emit('error', trans('error.comment_delete'));
+ return;
+ }
+ this.$events.emit('success', trans('entities.comment_deleted'));
+ this.comment = resp.data.comment;
+ }).catch(err => {
+ this.$events.emit('error', trans('error.comment_delete'));
+ });
+ },
+ replyComment: function () {
+ this.toggleEditor(false);
+ },
+ editComment: function () {
+ this.toggleEditor(true);
+ },
+ hideComment: function () {
+ this.showEditor = false;
+ },
+ toggleEditor: function (isEdit) {
+ this.showEditor = false;
+ this.isEdit = isEdit;
+ this.isReply = !isEdit;
+ this.showEditor = true;
+ },
+ commentReplied: function (event, comment) {
+ this.comments.push(comment);
+ this.showEditor = false;
+ },
+ commentEdited: function (event, comment) {
+ this.comment = comment;
+ this.showEditor = false;
+ },
+ commentAdded: function (event, comment) {
+ // this is to handle non-parent child relationship
+ // we want to make it go up.
+ this.$emit('comment-added', event);
+ },
+ canEditOrDelete: function (prop) {
+ if (!this.comment.active) {
+ return false;
+ }