From 112c12d64ca1029eedc683422eb1b25553f411cf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 16 Jul 2019 13:11:38 +0300 Subject: [PATCH] User original id for comments mentions --- apps/common/main/lib/controller/Comments.js | 14 +++++++++++--- apps/common/main/lib/model/Comment.js | 1 + apps/documenteditor/main/app/controller/Main.js | 2 +- .../presentationeditor/main/app/controller/Main.js | 2 +- apps/spreadsheeteditor/main/app/controller/Main.js | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 5831c62b6..cdc6b19ef 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -130,6 +130,7 @@ define([ }); Common.NotificationCenter.on('comments:updatefilter', _.bind(this.onUpdateFilter, this)); + Common.NotificationCenter.on('comments:showaction', _.bind(this.onShowAction, this)); Common.NotificationCenter.on('app:comment:add', _.bind(this.onAppAddComment, this)); Common.NotificationCenter.on('layout:changed', function(area){ Common.Utils.asyncCall(function(e) { @@ -281,7 +282,7 @@ define([ return false; }, onShowComment: function (id, selected) { - var comment = this.findComment(id); + var comment = (typeof id == Object) ? id : this.findComment(id); if (comment) { if (null !== comment.get('quote')) { if (this.api) { @@ -495,7 +496,7 @@ define([ ascComment.asc_addReply(addReply); me.api.asc_changeComment(id, ascComment); - me.mode && me.mode.canRequestUsers && me.view.pickEMail(id, replyVal); + me.mode && me.mode.canRequestUsers && me.view.pickEMail(ascComment.asc_getDurableId ? ascComment.asc_getDurableId() : ascComment.asc_getGuid(), replyVal); return true; } @@ -1193,6 +1194,7 @@ define([ groupname = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/); var comment = new Common.Models.Comment({ uid : id, + originalUid : data.asc_getDurableId ? data.asc_getDurableId() : data.asc_getGuid(), userid : data.asc_getUserId(), username : data.asc_getUserName(), usercolor : (user) ? user.get('color') : null, @@ -1342,13 +1344,14 @@ define([ comment.asc_putUserId(this.currentUserId); comment.asc_putUserName(this.currentUserName); comment.asc_putSolved(false); + comment.asc_putDurableId ? comment.asc_putDurableId(AscCommon.CreateUInt32()) : comment.asc_putGuid(AscCommon.CreateUInt32()); if (!_.isUndefined(comment.asc_putDocumentFlag)) comment.asc_putDocumentFlag(false); var commentId = this.api.asc_addComment(comment); this.view.showEditContainer(false); - this.mode && this.mode.canRequestUsers && this.view.pickEMail(commentId, commentVal); + this.mode && this.mode.canRequestUsers && this.view.pickEMail(comment.asc_getDurableId ? comment.asc_getDurableId() : comment.asc_getGuid(), commentVal); if (!_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)) { this.api.asc_SetDocumentPlaceChangedEnabled(false); } @@ -1521,6 +1524,11 @@ define([ clearCollections: function() { this.collection.reset(); this.groupCollection = []; + }, + + onShowAction: function(id, selected) { + var comment = this.collection.findWhere({originalUid: id}); + comment && this.onShowComment(comment, selected); } }, Common.Controllers.Comments || {})); diff --git a/apps/common/main/lib/model/Comment.js b/apps/common/main/lib/model/Comment.js index 54f30d973..c77f2f967 100644 --- a/apps/common/main/lib/model/Comment.js +++ b/apps/common/main/lib/model/Comment.js @@ -53,6 +53,7 @@ define([ Common.Models.Comment = Backbone.Model.extend({ defaults: { uid : 0, // asc + originalUid : 0, userid : 0, username : 'Guest', usercolor : null, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 172f45189..527957739 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1047,7 +1047,7 @@ define([ onDocumentReady: function() { if (this.editorConfig.actionLink && this.editorConfig.actionLink.action && this.editorConfig.actionLink.action.type == 'comment') { - this.contComments.getView().fireEvent('comment:show', [this.editorConfig.actionLink.action.data, false]); + Common.NotificationCenter.trigger('comments:showaction', this.editorConfig.actionLink.action.data, false); } }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 00f776d5a..3e63b1d26 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -790,7 +790,7 @@ define([ onDocumentReady: function() { if (this.editorConfig.actionLink && this.editorConfig.actionLink.action && this.editorConfig.actionLink.action.type == 'comment') { - this.getApplication().getController('Common.Controllers.Comments').getView().fireEvent('comment:show', [this.editorConfig.actionLink.action.data, false]); + Common.NotificationCenter.trigger('comments:showaction', this.editorConfig.actionLink.action.data, false); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 6b3ca47e9..9b9b92b42 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -803,7 +803,7 @@ define([ onDocumentReady: function() { if (this.editorConfig.actionLink && this.editorConfig.actionLink.action && this.editorConfig.actionLink.action.type == 'comment') { - this.getApplication().getController('Common.Controllers.Comments').getView().fireEvent('comment:show', [this.editorConfig.actionLink.action.data, false]); + Common.NotificationCenter.trigger('comments:showaction', this.editorConfig.actionLink.action.data, false); } },