diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index fda45bab8..21e1638f7 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -102,7 +102,8 @@ define([ // work handlers - 'comment:closeEditing': _.bind(this.closeEditing, this) + 'comment:closeEditing': _.bind(this.closeEditing, this), + 'comment:sort': _.bind(this.setComparator, this) }, 'Common.Views.ReviewPopover': { @@ -144,10 +145,11 @@ define([ }.bind(this)); }, onLaunch: function () { + var filter = Common.localStorage.getKeysFilter(); + this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; + this.collection = this.getApplication().getCollection('Common.Collections.Comments'); - if (this.collection) { - this.collection.comparator = function (collection) { return -collection.get('time'); }; - } + this.setComparator(); this.popoverComments = new Common.Collections.Comments(); if (this.popoverComments) { @@ -204,6 +206,33 @@ define([ }, // + setComparator: function(type) { + if (this.collection) { + var sort = (type !== undefined); + if (type === undefined) { + type = Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date'; + } + Common.localStorage.setItem(this.appPrefix + "comments-sort", type); + Common.Utils.InternalSettings.set(this.appPrefix + "comments-sort", type); + + if (type=='position') { + } else if (type=='author') { + this.collection.comparator = function (collection) { + return collection.get('parsedName').toLowerCase(); + }; + } else { // date + this.collection.comparator = function (collection) { + return -collection.get('time'); + }; + } + sort && this.updateComments(true); + } + }, + + getComparator: function() { + return Common.Utils.InternalSettings.get(this.appPrefix + "comments-sort") || 'date'; + }, + onCreateComment: function (panel, commentVal, editMode, hidereply, documentFlag) { if (this.api && commentVal && commentVal.length > 0) { var comment = buildCommentData(); // new asc_CCommentData(null); @@ -776,9 +805,11 @@ define([ ((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime()))); var user = this.userCollection.findOriginalUser(data.asc_getUserId()); + var needSort = (this.getComparator() == 'author') && (data.asc_getUserName() !== comment.get('username')); comment.set('comment', data.asc_getText()); comment.set('userid', data.asc_getUserId()); comment.set('username', data.asc_getUserName()); + comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())); comment.set('usercolor', (user) ? user.get('color') : null); comment.set('resolved', data.asc_getSolved()); comment.set('quote', data.asc_getQuoteText()); @@ -804,6 +835,7 @@ define([ id : Common.UI.getId(), userid : data.asc_getReply(i).asc_getUserId(), username : data.asc_getReply(i).asc_getUserName(), + parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), usercolor : (user) ? user.get('color') : null, date : t.dateToLocaleTimeString(dateReply), reply : data.asc_getReply(i).asc_getText(), @@ -825,7 +857,7 @@ define([ } if (!silentUpdate) { - this.updateComments(false, true); + this.updateComments(needSort, !needSort); // if (this.getPopover() && this.getPopover().isVisible()) { // this._dontScrollToComment = true; @@ -1089,7 +1121,7 @@ define([ var i, end = true; - if (_.isUndefined(disableSort)) { + if (!disableSort) { this.collection.sort(); } @@ -1253,6 +1285,7 @@ define([ guid : data.asc_getGuid(), userid : data.asc_getUserId(), username : data.asc_getUserName(), + parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()), usercolor : (user) ? user.get('color') : null, date : this.dateToLocaleTimeString(date), quote : data.asc_getQuoteText(), @@ -1299,6 +1332,7 @@ define([ id : Common.UI.getId(), userid : data.asc_getReply(i).asc_getUserId(), username : data.asc_getReply(i).asc_getUserName(), + parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), usercolor : (user) ? user.get('color') : null, date : this.dateToLocaleTimeString(date), reply : data.asc_getReply(i).asc_getText(), diff --git a/apps/common/main/lib/template/CommentsPanel.template b/apps/common/main/lib/template/CommentsPanel.template index bcbe18673..5de0e80d7 100644 --- a/apps/common/main/lib/template/CommentsPanel.template +++ b/apps/common/main/lib/template/CommentsPanel.template @@ -10,4 +10,8 @@ +
+ +
+
diff --git a/apps/common/main/lib/view/Comments.js b/apps/common/main/lib/view/Comments.js index b1e9090ea..749a655f5 100644 --- a/apps/common/main/lib/view/Comments.js +++ b/apps/common/main/lib/view/Comments.js @@ -293,6 +293,9 @@ define([ Common.UI.BaseView.prototype.initialize.call(this, options); this.store = this.options.store; + + var filter = Common.localStorage.getKeysFilter(); + this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; }, render: function () { @@ -304,7 +307,8 @@ define([ textAddComment: me.textAddComment, textCancel: me.textCancel, textEnterCommentHint: me.textEnterCommentHint, - maxCommLength: Asc.c_oAscMaxCellOrCommentLength + maxCommLength: Asc.c_oAscMaxCellOrCommentLength, + textComments: me.textComments })); this.buttonAddCommentToDoc = new Common.UI.Button({ @@ -321,9 +325,44 @@ define([ enableToggle: false }); + this.buttonSort = new Common.UI.Button({ + parentEl: $('#comments-btn-sort', this.$el), + cls: 'btn-toolbar', + iconCls: 'toolbar__icon btn-rotate-270', + hint: this.textSort, + menu: new Common.UI.Menu({ + menuAlign: 'tr-br', + style: 'min-width: auto;', + items: [ + // { + // caption: this.mniPosition, + // value: 'position', + // checkable: true, + // checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'position', + // toggleGroup: 'sortcomments' + // }, + { + caption: this.mniAuthor, + value: 'author', + checkable: true, + checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'author', + toggleGroup: 'sortcomments' + }, + { + caption: this.mniDate, + value: 'date', + checkable: true, + checked: (Common.localStorage.getItem(this.appPrefix + "comments-sort") || 'date') === 'date', + toggleGroup: 'sortcomments' + } + ] + }) + }); + this.buttonAddCommentToDoc.on('click', _.bind(this.onClickShowBoxDocumentComment, this)); this.buttonAdd.on('click', _.bind(this.onClickAddDocumentComment, this)); this.buttonCancel.on('click', _.bind(this.onClickCancelDocumentComment, this)); + this.buttonSort.menu.on('item:toggle', _.bind(this.onSortClick, this)); this.txtComment = $('#comment-msg-new', this.el); this.txtComment.keydown(function (event) { @@ -730,6 +769,10 @@ define([ }); }, + onSortClick: function(menu, item, state) { + state && this.fireEvent('comment:sort', [item.value]); + }, + textComments : 'Comments', textAnonym : 'Guest', textAddCommentToDoc : 'Add Comment to Document', @@ -744,6 +787,10 @@ define([ textEdit : 'Edit', textAdd : "Add", textOpenAgain : "Open Again", - textHintAddComment : 'Add Comment' + textHintAddComment : 'Add Comment', + textSort: 'Sort comments', + mniPosition: 'Sort by Position', + mniAuthor: 'Sort by Authors', + mniDate: 'Sort by Date' }, Common.Views.Comments || {})) }); \ No newline at end of file diff --git a/apps/common/main/resources/less/comments.less b/apps/common/main/resources/less/comments.less index 415f98a0c..4447724b1 100644 --- a/apps/common/main/resources/less/comments.less +++ b/apps/common/main/resources/less/comments.less @@ -7,6 +7,24 @@ display: table-row; } + #comments-header { + position: absolute; + height: 45px; + left: 0; + top: 0; + right: 0; + padding: 12px; + overflow: hidden; + border-bottom: @scaled-one-px-value-ie solid @border-toolbar-ie; + border-bottom: @scaled-one-px-value solid @border-toolbar; + + label { + font-size: 12px; + font-weight: bold; + margin-top: 2px; + } + } + .messages-ct { position: absolute; overflow: hidden; @@ -14,6 +32,7 @@ right: 0; bottom: 45px; height: 300px; + padding-top: 45px; border-bottom: @scaled-one-px-value-ie solid @border-toolbar-ie; border-bottom: @scaled-one-px-value solid @border-toolbar; diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 92048ca45..54c5148cf 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -246,6 +246,10 @@ "Common.Views.Comments.textReply": "Reply", "Common.Views.Comments.textResolve": "Resolve", "Common.Views.Comments.textResolved": "Resolved", + "Common.Views.Comments.textSort": "Sort comments", + "Common.Views.Comments.mniPosition": "Sort by Position", + "Common.Views.Comments.mniAuthor": "Sort by Authors", + "Common.Views.Comments.mniDate": "Sort by Date", "Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again", "Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.

To copy or paste to or from applications outside the editor tab use the following keyboard combinations:", "Common.Views.CopyWarningDialog.textTitle": "Copy, Cut and Paste Actions", diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 4ef65a7f5..2be27c3b6 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -139,6 +139,10 @@ "Common.Views.Comments.textReply": "Reply", "Common.Views.Comments.textResolve": "Resolve", "Common.Views.Comments.textResolved": "Resolved", + "Common.Views.Comments.textSort": "Sort comments", + "Common.Views.Comments.mniPosition": "Sort by Position", + "Common.Views.Comments.mniAuthor": "Sort by Authors", + "Common.Views.Comments.mniDate": "Sort by Date", "Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again", "Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.

To copy or paste to or from applications outside the editor tab use the following keyboard combinations:", "Common.Views.CopyWarningDialog.textTitle": "Copy, Cut and Paste Actions", diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5793314d5..afd0e9992 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -187,6 +187,10 @@ "Common.Views.Comments.textReply": "Reply", "Common.Views.Comments.textResolve": "Resolve", "Common.Views.Comments.textResolved": "Resolved", + "Common.Views.Comments.textSort": "Sort comments", + "Common.Views.Comments.mniPosition": "Sort by Position", + "Common.Views.Comments.mniAuthor": "Sort by Authors", + "Common.Views.Comments.mniDate": "Sort by Date", "Common.Views.CopyWarningDialog.textDontShow": "Don't show this message again", "Common.Views.CopyWarningDialog.textMsg": "Copy, cut and paste actions using the editor toolbar buttons and context menu actions will be performed within this editor tab only.

To copy or paste to or from applications outside the editor tab use the following keyboard combinations:", "Common.Views.CopyWarningDialog.textTitle": "Copy, Cut and Paste Actions",