diff --git a/js/controller/ActivityController.js b/js/controller/ActivityController.js index a7d3a7de8..f42548e0e 100644 --- a/js/controller/ActivityController.js +++ b/js/controller/ActivityController.js @@ -53,8 +53,12 @@ class ActivityController { self.activityservice.fetchNewerActivities(self.type, self.element.id).then(function () {}); }, true); - let $target = $('.newCommentForm .message'); + this.applyAtWho($target); + } + + applyAtWho($target) { + const self = this; if (!$target) { return; } @@ -104,6 +108,9 @@ class ActivityController { 'span[data-username="' + $el.find('[data-username]').data('username') + '"]' ).avatar(); }); + $target.on('shown.atwho', function (je) { + $target.find('.avatar').avatar(); + }); } commentBodyToPlain(content) { @@ -120,7 +127,7 @@ class ActivityController { static _composeHTMLMention(uid, displayName) { var avatar = '' + - '' + ''; @@ -128,7 +135,7 @@ class ActivityController { var isCurrentUser = (uid === OC.getCurrentUser().uid); return '' + - '' + + '' + '' + avatar + '' + _.escape(displayName) + '' + @@ -201,12 +208,38 @@ class ActivityController { } updateComment(item) { - let newMessage = 'Edited at ' + (new Date()); - item.commentModel.save({ - message: newMessage, - }); - item.message = newMessage; + let message = this.formatMessage(item); + item.commentEdit = message; + let $target = $('.newCommentForm .message'); + this.applyAtWho($target); + window.setTimeout(function () { + $target.find('.avatar').avatar(undefined, 16); + }, 0); + } + editComment(item) { + const self = this; + let content = this.commentBodyToPlain(item.commentEdit); + if (content.length < 1) { + OC.Notification.showTemporary(t('deck', 'Please provide a content for your comment.')); + return; + } + /** We need to save the model and afterwards run a fetch to update the mentions + * and call apply to propagate the changes to angular + */ + item.commentModel.on('sync', function() { + item.commentModel.off('sync'); + item.commentModel.fetch({ + success: function() { + self.$scope.$apply(); + } + }); + }); + item.commentModel.save({ + message: content, + }); + item.message = content; + item.commentEdit = undefined; } deleteComment(item) { diff --git a/js/directive/contenteditable.js b/js/directive/contenteditable.js index 7d8b24058..8ea80dda8 100644 --- a/js/directive/contenteditable.js +++ b/js/directive/contenteditable.js @@ -22,9 +22,10 @@ import app from '../app/App'; -app.directive("contenteditable", function() { +app.directive("ngContenteditable", function($compile) { return { require: "ngModel", + restrict: 'A', link: function(scope, element, attrs, ngModel) { //read the text typed in the div (syncing model with the view) diff --git a/templates/part.card.activity.html b/templates/part.card.activity.html index 44e71a6b8..065e83d5d 100644 --- a/templates/part.card.activity.html +++ b/templates/part.card.activity.html @@ -5,13 +5,12 @@
{{ $ctrl.currentUser.displayName }}
-
+
-
  • @@ -35,8 +34,14 @@
    -
    +
    +
    +
    + +
+