From 542d438ea8ced75e89988cf3aacb52f2346d9ade Mon Sep 17 00:00:00 2001 From: nikita_bartoshuk Date: Tue, 17 Jun 2025 18:16:09 +0300 Subject: [PATCH] added status filter --- apps/common/main/lib/controller/Comments.js | 33 ++++++++++++++- apps/common/main/lib/view/Comments.js | 45 ++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index c4e68e08e4..ae202d45f9 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -103,7 +103,8 @@ define([ 'comment:closeEditing': _.bind(this.closeEditing, this), 'comment:sort': _.bind(this.setComparator, this), - 'comment:filtergroups': _.bind(this.setFilterGroups, this) + 'comment:filtergroups': _.bind(this.setFilterGroups, this), + 'comment:filtercomments': _.bind(this.setFilterComments, this) }, 'Common.Views.ReviewPopover': { @@ -1776,6 +1777,36 @@ define([ this.updateComments(true); }, + setFilterComments: function (type) { + console.log(this.collection) + console.log(type) + var i, end = true; + + for (i = this.collection.length - 1; i >= 0; --i) { + var item = this.collection.at(i); + + var isResolved = item.get('resolved') === true; + let shouldFilter = false; + + if (type === 'open' && isResolved) { + shouldFilter = true; + } else if (type === 'resolved' && !isResolved) { + shouldFilter = true; + } + + item.set('filtered', shouldFilter, { silent: true }); + + if (end && !item.get('filtered') && !item.get('hide')) { + item.set('last', true, { silent: true }); + end = false; + } else if (item.get('last')) { + item.set('last', false, { silent: true }); + } + } + + this.updateComments(true); + }, + onAppReady: function (config) { var me = this; (new Promise(function (accept, reject) { diff --git a/apps/common/main/lib/view/Comments.js b/apps/common/main/lib/view/Comments.js index 4d5314c727..c7bb1cd2a7 100644 --- a/apps/common/main/lib/view/Comments.js +++ b/apps/common/main/lib/view/Comments.js @@ -399,8 +399,38 @@ define([ }, { caption: '--', - visible: false + visible: true }, + this.menuFilterComments = new Common.UI.MenuItem({ + caption: this.mniFilterComments, + checkable: false, + visible: true, + menu: new Common.UI.Menu({ + menuAlign: 'tl-tr', + style: 'min-width: auto;', + items: [ + { + caption: 'Open', + checkable: true, + visible: true, + value: 'open' + }, + { + caption: 'Resolved', + checkable: true, + visible: true, + value: 'resolved' + }, + { + caption: 'All', + checkable: true, + visible: true, + value: 'all', + checked: true + } + ] + }) + }), this.menuFilterGroups = new Common.UI.MenuItem({ caption: this.mniFilterGroups, checkable: false, @@ -442,6 +472,7 @@ define([ this.buttonClose.on('click', _.bind(this.onClickClosePanel, this)); this.buttonSort.menu.on('item:toggle', _.bind(this.onSortClick, this)); this.menuFilterGroups.menu.on('item:toggle', _.bind(this.onFilterGroupsClick, this)); + this.menuFilterComments.menu.on('item:toggle', _.bind(this.onFilterCommentsClick, this)); this.mnuAddCommentToDoc.on('click', _.bind(this.onClickShowBoxDocumentComment, this)); this.buttonAddNew.on('click', _.bind(this.onClickAddNewComment, this)); @@ -907,6 +938,17 @@ define([ state && this.fireEvent('comment:filtergroups', [item.value]); }, + onFilterCommentsClick: function(menu, item, state) { + if (!state) return; + + menu.items.forEach(function (it) { + if (it !== item) { + it.setChecked(false); + } + }); + state && this.fireEvent('comment:filtercomments', [item.value]); + }, + onClickClosePanel: function() { Common.NotificationCenter.trigger('leftmenu:change', 'hide'); }, @@ -937,6 +979,7 @@ define([ textClosePanel: 'Close comments', textViewResolved: 'You have not permission for reopen comment', mniFilterGroups: 'Filter by Group', + mniFilterComments: 'Show comments', textAll: 'All', txtEmpty: 'There are no comments in the document.', textSortFilter: 'Sort and filter comments',