From 1caee3ac2e6406df2e9ab644925bff106836b0a4 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 3 Feb 2016 20:32:37 +0100 Subject: [PATCH] Move comment delete action into edit mode --- apps/comments/css/comments.css | 2 +- apps/comments/js/commentstabview.js | 33 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index f4e7d144ec5..b86ed38efe7 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -47,7 +47,7 @@ #commentsTabView .comment .date { position: absolute; - right: 20px; + right: 0; } #commentsTabView .comment .action { diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 9db39408c70..2c5e9414751 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -27,12 +27,15 @@ ' {{/if}}' + '
{{actorDisplayName}}
' + '{{#if isEditMode}}' + - ' ' + + ' ' + '{{/if}}' + ' ' + '
' + ' ' + ' ' + + '{{#if isEditMode}}' + + ' ' + + '{{/if}}' + ' '+ '
' + ''; @@ -48,9 +51,6 @@ ' ' + '{{/if}}' + '
{{date}}
' + - '{{#if isUserAuthor}}' + - ' ' + - '{{/if}}' + ' ' + '
{{{formattedMessage}}}
' + ''; @@ -68,7 +68,7 @@ 'click .showMore': '_onClickShowMore', 'click .action.edit': '_onClickEditComment', 'click .action.delete': '_onClickDeleteComment', - 'click .action.close': '_onClickCloseComment' + 'click .cancel': '_onClickCloseComment' }, initialize: function() { @@ -102,10 +102,12 @@ var currentUser = OC.getCurrentUser(); return this._editCommentTemplate(_.extend({ avatarEnabled: this._avatarsEnabled, - userId: currentUser.uid, - userDisplayName: currentUser.displayName, + actorId: currentUser.uid, + actorDisplayName: currentUser.displayName, newMessagePlaceholder: t('comments', 'Type in a new comment...'), - submitText: t('comments', 'Post') + deleteTooltip: t('comments', 'Delete comment'), + submitText: t('comments', 'Post'), + cancelText: t('comments', 'Cancel') }, params)); }, @@ -115,7 +117,6 @@ } return this._commentTemplate(_.extend({ avatarEnabled: this._avatarsEnabled, - deleteTooltip: t('comments', 'Delete comment'), editTooltip: t('comments', 'Edit comment'), isUserAuthor: OC.getCurrentUser().uid === params.actorId }, params)); @@ -167,9 +168,11 @@ this.$el.find('.loading').toggleClass('hidden', !state); }, - _onRequest: function() { - this._toggleLoading(true); - this.$el.find('.showMore').addClass('hidden'); + _onRequest: function(type) { + if (type === 'REPORT') { + this._toggleLoading(true); + this.$el.find('.showMore').addClass('hidden'); + } }, _onEndRequest: function(type) { @@ -251,6 +254,7 @@ // copy avatar element from original to avoid flickering $formRow.find('.avatar').replaceWith($comment.find('.avatar').clone()); + $formRow.find('.has-tooltip').tooltip(); return false; }, @@ -267,14 +271,17 @@ ev.preventDefault(); var $comment = $(ev.target).closest('.comment'); var commentId = $comment.data('id'); - // TODO: undo logic + var $loading = $comment.find('.submitLoading'); $comment.addClass('disabled'); + $loading.removeClass('hidden'); this.collection.get(commentId).destroy({ success: function() { + $comment.data('commentEl').remove(); $comment.remove(); }, error: function(msg) { + $loading.addClass('hidden'); $comment.removeClass('disabled'); OC.Notification.showTemporary(msg); } -- 2.39.5