Remove comments (current, all, only my comments)

This commit is contained in:
Julia Radzhabova 2019-10-18 13:28:30 +03:00
parent 4da866952b
commit f34167d0f2
2 changed files with 61 additions and 3 deletions

View file

@ -126,6 +126,9 @@ define([
'comment:closeEditing': _.bind(this.closeEditing, this),
'comment:disableHint': _.bind(this.disableHint, this),
'comment:addDummyComment': _.bind(this.onAddDummyComment, this)
},
'Common.Views.ReviewChanges': {
'comment:removeComments': _.bind(this.onRemoveComments, this)
}
});
@ -180,7 +183,7 @@ define([
this.api.asc_registerCallback('asc_onAddComments', _.bind(this.onApiAddComments, this));
this.api.asc_registerCallback('asc_onRemoveComment', _.bind(this.onApiRemoveComment, this));
this.api.asc_registerCallback('asc_onChangeComments', _.bind(this.onChangeComments, this));
this.api.asc_registerCallback('asc_onRemoveComments', _.bind(this.onRemoveComments, this));
this.api.asc_registerCallback('asc_onRemoveComments', _.bind(this.onApiRemoveComments, this));
this.api.asc_registerCallback('asc_onChangeCommentData', _.bind(this.onApiChangeCommentData, this));
this.api.asc_registerCallback('asc_onLockComment', _.bind(this.onApiLockComment, this));
this.api.asc_registerCallback('asc_onUnLockComment', _.bind(this.onApiUnLockComment, this));
@ -233,6 +236,11 @@ define([
this.api.asc_removeComment(id);
}
},
onRemoveComments: function (type) {
if (this.api) {
this.api.asc_removeComments(type!='current', type=='my' || !this.mode.canEditComments);// 1 param = true if remove all comments (not current), 2 param - only my comments
}
},
onResolveComment: function (uid) {
var t = this,
reply = null,
@ -725,7 +733,7 @@ define([
this.updateComments(true);
},
onRemoveComments: function (data) {
onApiRemoveComments: function (data) {
for (var i = 0; i < data.length; ++i) {
this.onApiRemoveComment(data[i], true);
}

View file

@ -64,6 +64,7 @@ define([
'<div class="separator long sharing"/>' +
'<div class="group">' +
'<span class="btn-slot text x-huge slot-comment"></span>' +
'<span class="btn-slot text x-huge" id="slot-comment-remove"></span>' +
'</div>' +
'<div class="separator long comments"/>' +
'<div class="group">' +
@ -161,6 +162,16 @@ define([
this.btnChat && this.btnChat.on('click', function (btn, e) {
me.fireEvent('collaboration:chat', [btn.pressed]);
});
if (this.btnCommentRemove) {
this.btnCommentRemove.on('click', function (e) {
me.fireEvent('comment:removeComments', ['current']);
});
this.btnCommentRemove.menu.on('item:click', function (menu, item, e) {
me.fireEvent('comment:removeComments', [item.value]);
});
}
}
return {
@ -291,6 +302,15 @@ define([
});
}
if ( this.appConfig.canCoAuthoring && this.appConfig.canComments ) {
this.btnCommentRemove = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
caption: this.txtCommentRemove,
split: true,
iconCls: 'btn-menu-comments'
});
}
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
@ -397,6 +417,28 @@ define([
me.turnCoAuthMode((value===null || parseInt(value) == 1) && !(config.isDesktopApp && config.isOffline) && config.canCoAuthoring);
}
if (me.btnCommentRemove) {
var items = [
{
caption: me.txtCommentRemCurrent,
value: 'current'
},
{
caption: me.txtCommentRemMy,
value: 'my'
}
];
if (config.canEditComments)
items.push({
caption: me.txtCommentRemAll,
value: 'all'
});
me.btnCommentRemove.setMenu(
new Common.UI.Menu({items: items})
);
me.btnCommentRemove.updateHint([me.tipCommentRemCurrent, me.tipCommentRem]);
}
var separator_sharing = !(me.btnSharing || me.btnCoAuthMode) ? me.$el.find('.separator.sharing') : '.separator.sharing',
separator_comments = !(config.canComments && config.canCoAuthoring) ? me.$el.find('.separator.comments') : '.separator.comments',
separator_review = !(config.canReview || config.canViewReview) ? me.$el.find('.separator.review') : '.separator.review',
@ -448,6 +490,7 @@ define([
this.btnCoAuthMode && this.btnCoAuthMode.render(this.$el.find('#slot-btn-coauthmode'));
this.btnHistory && this.btnHistory.render(this.$el.find('#slot-btn-history'));
this.btnChat && this.btnChat.render(this.$el.find('#slot-btn-chat'));
this.btnCommentRemove && this.btnCommentRemove.render(this.$el.find('#slot-comment-remove'));
return this.$el;
},
@ -561,6 +604,7 @@ define([
}
}, this);
this.btnChat && this.btnChat.setDisabled(state);
this.btnCommentRemove && this.btnCommentRemove.setDisabled(state);
},
onLostEditRights: function() {
@ -609,7 +653,13 @@ define([
txtFinalCap: 'Final',
txtOriginalCap: 'Original',
strFastDesc: 'Real-time co-editing. All changes are saved automatically.',
strStrictDesc: 'Use the \'Save\' button to sync the changes you and others make.'
strStrictDesc: 'Use the \'Save\' button to sync the changes you and others make.',
txtCommentRemove: 'Remove Comments',
tipCommentRemCurrent: 'Remove current comments',
tipCommentRem: 'Remove comments',
txtCommentRemCurrent: 'Remove Current Comments',
txtCommentRemMy: 'Remove My Comments',
txtCommentRemAll: 'Remove All Comments'
}
}()), Common.Views.ReviewChanges || {}));