Merge pull request #1355 from ONLYOFFICE/feature/filter-comments
Feature/filter comments
This commit is contained in:
commit
e434212883
|
@ -103,7 +103,8 @@ define([
|
|||
// work handlers
|
||||
|
||||
'comment:closeEditing': _.bind(this.closeEditing, this),
|
||||
'comment:sort': _.bind(this.setComparator, this)
|
||||
'comment:sort': _.bind(this.setComparator, this),
|
||||
'comment:filtergroups': _.bind(this.setFilterGroups, this)
|
||||
},
|
||||
|
||||
'Common.Views.ReviewPopover': {
|
||||
|
@ -157,6 +158,7 @@ define([
|
|||
}
|
||||
|
||||
this.groupCollection = [];
|
||||
this.userGroups = []; // for filtering comments
|
||||
|
||||
this.view = this.createView('Common.Views.Comments', { store: this.collection });
|
||||
this.view.render();
|
||||
|
@ -695,14 +697,15 @@ define([
|
|||
|
||||
var end = true;
|
||||
for (var i = this.collection.length - 1; i >= 0; --i) {
|
||||
if (end) {
|
||||
this.collection.at(i).set('last', true, {silent: true});
|
||||
var item = this.collection.at(i);
|
||||
if (end && !item.get('hide') && !item.get('filtered')) {
|
||||
item.set('last', true, {silent: true});
|
||||
end = false;
|
||||
} else {
|
||||
if (this.collection.at(i).get('last')) {
|
||||
this.collection.at(i).set('last', false, {silent: true});
|
||||
if (item.get('last')) {
|
||||
item.set('last', false, {silent: true});
|
||||
}
|
||||
}
|
||||
end = false;
|
||||
}
|
||||
this.view.render();
|
||||
this.view.update();
|
||||
|
@ -820,6 +823,7 @@ define([
|
|||
comment.set('userid', data.asc_getUserId());
|
||||
comment.set('username', data.asc_getUserName());
|
||||
comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()));
|
||||
comment.set('parsedGroups', AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()));
|
||||
comment.set('usercolor', (user) ? user.get('color') : null);
|
||||
comment.set('resolved', data.asc_getSolved());
|
||||
comment.set('quote', data.asc_getQuoteText());
|
||||
|
@ -830,6 +834,14 @@ define([
|
|||
comment.set('removable', (t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName()));
|
||||
comment.set('hide', !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName()));
|
||||
|
||||
if (!comment.get('hide')) {
|
||||
var usergroups = comment.get('parsedGroups');
|
||||
t.fillUserGroups(usergroups);
|
||||
var group = Common.Utils.InternalSettings.get(t.appPrefix + "comments-filtergroups");
|
||||
var filter = !!group && (group!==-1) && (!usergroups || usergroups.length<1 || usergroups.indexOf(group)<0);
|
||||
comment.set('filtered', filter);
|
||||
}
|
||||
|
||||
replies = _.clone(comment.get('replys'));
|
||||
|
||||
replies.length = 0;
|
||||
|
@ -1148,14 +1160,15 @@ define([
|
|||
this.onUpdateFilter(this.filter, true);
|
||||
|
||||
for (i = this.collection.length - 1; i >= 0; --i) {
|
||||
if (end) {
|
||||
this.collection.at(i).set('last', true, {silent: true});
|
||||
var item = this.collection.at(i);
|
||||
if (end && !item.get('hide') && !item.get('filtered')) {
|
||||
item.set('last', true, {silent: true});
|
||||
end = false;
|
||||
} else {
|
||||
if (this.collection.at(i).get('last')) {
|
||||
this.collection.at(i).set('last', false, {silent: true});
|
||||
if (item.get('last')) {
|
||||
item.set('last', false, {silent: true});
|
||||
}
|
||||
}
|
||||
end = false;
|
||||
}
|
||||
|
||||
this.view.render();
|
||||
|
@ -1306,6 +1319,7 @@ define([
|
|||
userid : data.asc_getUserId(),
|
||||
username : data.asc_getUserName(),
|
||||
parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()),
|
||||
parsedGroups : AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()),
|
||||
usercolor : (user) ? user.get('color') : null,
|
||||
date : this.dateToLocaleTimeString(date),
|
||||
quote : data.asc_getQuoteText(),
|
||||
|
@ -1329,6 +1343,13 @@ define([
|
|||
groupName : (groupname && groupname.length>1) ? groupname[1] : null
|
||||
});
|
||||
if (comment) {
|
||||
if (!comment.get('hide')) {
|
||||
var usergroups = comment.get('parsedGroups');
|
||||
this.fillUserGroups(usergroups);
|
||||
var group = Common.Utils.InternalSettings.get(this.appPrefix + "comments-filtergroups");
|
||||
var filter = !!group && (group!==-1) && (!usergroups || usergroups.length<1 || usergroups.indexOf(group)<0);
|
||||
comment.set('filtered', filter);
|
||||
}
|
||||
var replies = this.readSDKReplies(data);
|
||||
if (replies.length) {
|
||||
comment.set('replys', replies);
|
||||
|
@ -1639,6 +1660,64 @@ define([
|
|||
clearCollections: function() {
|
||||
this.collection.reset();
|
||||
this.groupCollection = [];
|
||||
},
|
||||
|
||||
fillUserGroups: function(usergroups) {
|
||||
if (!this.mode.canUseCommentPermissions) return;
|
||||
|
||||
var viewgroups = AscCommon.UserInfoParser.getCommentPermissions('view');
|
||||
if (usergroups && usergroups.length>0) {
|
||||
if (viewgroups)
|
||||
usergroups = _.intersection(usergroups, viewgroups);
|
||||
usergroups = _.uniq(this.userGroups.concat(usergroups));
|
||||
}
|
||||
if (this.view && this.view.buttonSort && _.difference(usergroups, this.userGroups).length>0) {
|
||||
this.userGroups = usergroups;
|
||||
var menu = this.view.buttonSort.menu;
|
||||
menu.items[menu.items.length-1].setVisible(this.userGroups.length>0);
|
||||
menu.items[menu.items.length-2].setVisible(this.userGroups.length>0);
|
||||
menu = menu.items[menu.items.length-1].menu;
|
||||
menu.removeAll();
|
||||
|
||||
var last = Common.Utils.InternalSettings.get(this.appPrefix + "comments-filtergroups");
|
||||
menu.addItem(new Common.UI.MenuItem({
|
||||
checkable: true,
|
||||
checked: last===-1 || last===undefined,
|
||||
toggleGroup: 'filtercomments',
|
||||
caption: this.view.textAll,
|
||||
value: -1
|
||||
}));
|
||||
this.userGroups.forEach(function(item){
|
||||
menu.addItem(new Common.UI.MenuItem({
|
||||
checkable: true,
|
||||
checked: last === item,
|
||||
toggleGroup: 'filtercomments',
|
||||
caption: Common.Utils.String.htmlEncode(item),
|
||||
value: item
|
||||
}));
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setFilterGroups: function (group) {
|
||||
Common.Utils.InternalSettings.set(this.appPrefix + "comments-filtergroups", group);
|
||||
var i, end = true;
|
||||
for (i = this.collection.length - 1; i >= 0; --i) {
|
||||
var item = this.collection.at(i);
|
||||
if (!item.get('hide')) {
|
||||
var usergroups = item.get('parsedGroups');
|
||||
item.set('filtered', !!group && (group!==-1) && (!usergroups || usergroups.length<1 || usergroups.indexOf(group)<0), {silent: true});
|
||||
}
|
||||
if (end && !item.get('hide') && !item.get('filtered')) {
|
||||
item.set('last', true, {silent: true});
|
||||
end = false;
|
||||
} else {
|
||||
if (item.get('last')) {
|
||||
item.set('last', false, {silent: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateComments(true);
|
||||
}
|
||||
|
||||
}, Common.Controllers.Comments || {}));
|
||||
|
|
|
@ -57,6 +57,7 @@ define([
|
|||
userid : 0,
|
||||
username : 'Guest',
|
||||
parsedName : 'Guest',
|
||||
parsedGroups : undefined,
|
||||
usercolor : null,
|
||||
date : undefined,
|
||||
quote : '',
|
||||
|
@ -79,6 +80,7 @@ define([
|
|||
hideAddReply : false,
|
||||
scope : null,
|
||||
hide : false,
|
||||
filtered : false,
|
||||
hint : false,
|
||||
dummy : undefined,
|
||||
editable : true,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% if (!hide) { %>
|
||||
<% if (!hide && !filtered) { %>
|
||||
<div id="<%= id %>" class="user-comment-item">
|
||||
|
||||
<!-- comment block -->
|
||||
|
|
|
@ -377,7 +377,21 @@ define([
|
|||
visible: this.appPrefix==='de-',
|
||||
checked: Common.localStorage.getItem(this.appPrefix + "comments-sort") === 'position-desc',
|
||||
toggleGroup: 'sortcomments'
|
||||
}
|
||||
},
|
||||
{
|
||||
caption: '--',
|
||||
visible: false
|
||||
},
|
||||
this.menuFilterGroups = new Common.UI.MenuItem({
|
||||
caption: this.mniFilterGroups,
|
||||
checkable: false,
|
||||
visible: false,
|
||||
menu: new Common.UI.Menu({
|
||||
menuAlign: 'tl-tr',
|
||||
style: 'min-width: auto;',
|
||||
items: []
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
@ -394,6 +408,7 @@ define([
|
|||
this.buttonCancel.on('click', _.bind(this.onClickCancelDocumentComment, this));
|
||||
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.txtComment = $('#comment-msg-new', this.el);
|
||||
this.txtComment.keydown(function (event) {
|
||||
|
@ -812,6 +827,10 @@ define([
|
|||
state && this.fireEvent('comment:sort', [item.value]);
|
||||
},
|
||||
|
||||
onFilterGroupsClick: function(menu, item, state) {
|
||||
state && this.fireEvent('comment:filtergroups', [item.value]);
|
||||
},
|
||||
|
||||
onClickClosePanel: function() {
|
||||
Common.NotificationCenter.trigger('leftmenu:change', 'hide');
|
||||
},
|
||||
|
@ -839,6 +858,8 @@ define([
|
|||
mniDateDesc: 'Newest',
|
||||
mniDateAsc: 'Oldest',
|
||||
textClosePanel: 'Close comments',
|
||||
textViewResolved: 'You have not permission for reopen comment'
|
||||
textViewResolved: 'You have not permission for reopen comment',
|
||||
mniFilterGroups: 'Filter by Group',
|
||||
textAll: 'All'
|
||||
}, Common.Views.Comments || {}))
|
||||
});
|
|
@ -259,6 +259,8 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.textViewResolved": "You have not permission for reopen comment",
|
||||
"Common.Views.Comments.mniFilterGroups": "Filter by Group",
|
||||
"Common.Views.Comments.textAll": "All",
|
||||
"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.<br><br>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",
|
||||
|
|
|
@ -152,6 +152,8 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.textViewResolved": "You have not permission for reopen comment",
|
||||
"Common.Views.Comments.mniFilterGroups": "Filter by Group",
|
||||
"Common.Views.Comments.textAll": "All",
|
||||
"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.<br><br>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",
|
||||
|
|
|
@ -200,6 +200,8 @@
|
|||
"Common.Views.Comments.textResolved": "Resolved",
|
||||
"Common.Views.Comments.textSort": "Sort comments",
|
||||
"Common.Views.Comments.textViewResolved": "You have not permission for reopen comment",
|
||||
"Common.Views.Comments.mniFilterGroups": "Filter by Group",
|
||||
"Common.Views.Comments.textAll": "All",
|
||||
"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.<br><br>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",
|
||||
|
|
Loading…
Reference in a new issue