[SSE] Disable remove/resolve comment buttons when objects protected

This commit is contained in:
Julia Radzhabova 2021-08-20 17:38:32 +03:00
parent 2855cc0eca
commit 5ffb7e8fa0
5 changed files with 38 additions and 8 deletions

View file

@ -109,6 +109,7 @@ define([
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this));
Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this));
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
this.userCollection.on('reset', _.bind(this.onUpdateUsers, this)); this.userCollection.on('reset', _.bind(this.onUpdateUsers, this));
this.userCollection.on('add', _.bind(this.onUpdateUsers, this)); this.userCollection.on('add', _.bind(this.onUpdateUsers, this));
@ -163,7 +164,7 @@ define([
SetDisabled: function(state) { SetDisabled: function(state) {
if (this.dlgChanges) if (this.dlgChanges)
this.dlgChanges.close(); this.dlgChanges.close();
this.view && this.view.SetDisabled(state, this.langs); this.view && this.view.SetDisabled(state, this.langs, {comments: !!this._state.wsProps['Objects']});
this.setPreviewMode(state); this.setPreviewMode(state);
}, },
@ -840,9 +841,10 @@ define([
me.view.turnChat(state); me.view.turnChat(state);
}); });
} }
me.onChangeProtectSheet();
if (me.view) { if (me.view) {
me.view.btnCommentRemove && me.view.btnCommentRemove.setDisabled(!Common.localStorage.getBool(me.view.appPrefix + "settings-livecomment", true)); me.view.btnCommentRemove && me.view.btnCommentRemove.setDisabled(!Common.localStorage.getBool(me.view.appPrefix + "settings-livecomment", true) || !!this._state.wsProps['Objects']);
me.view.btnCommentResolve && me.view.btnCommentResolve.setDisabled(!Common.localStorage.getBool(me.view.appPrefix + "settings-livecomment", true)); me.view.btnCommentResolve && me.view.btnCommentResolve.setDisabled(!Common.localStorage.getBool(me.view.appPrefix + "settings-livecomment", true) || !!this._state.wsProps['Objects']);
} }
}, },
@ -974,8 +976,24 @@ define([
commentsShowHide: function(mode) { commentsShowHide: function(mode) {
if (!this.view) return; if (!this.view) return;
var value = Common.Utils.InternalSettings.get(this.view.appPrefix + "settings-livecomment"); var value = Common.Utils.InternalSettings.get(this.view.appPrefix + "settings-livecomment");
(value!==undefined) && this.view.btnCommentRemove && this.view.btnCommentRemove.setDisabled(mode != 'show' && !value); (value!==undefined) && this.view.btnCommentRemove && this.view.btnCommentRemove.setDisabled(mode != 'show' && !value || !!this._state.wsProps['Objects']);
(value!==undefined) && this.view.btnCommentResolve && this.view.btnCommentResolve.setDisabled(mode != 'show' && !value); (value!==undefined) && this.view.btnCommentResolve && this.view.btnCommentResolve.setDisabled(mode != 'show' && !value || !!this._state.wsProps['Objects']);
},
onChangeProtectSheet: function(props) {
if (!props) {
var wbprotect = this.getApplication().getController('WBProtection');
props = wbprotect ? wbprotect.getWSProps() : null;
}
this._state.wsProps = props ? props.wsProps : {};
this._state.wsLock = props ? props.wsLock : false;
if (!this.view) return;
var leftmenu = this.getApplication().getController('LeftMenu'),
isCommentsVisible = leftmenu && leftmenu.isCommentsVisible();
var value = Common.Utils.InternalSettings.get(this.view.appPrefix + "settings-livecomment");
(value!==undefined) && this.view.btnCommentRemove && this.view.btnCommentRemove.setDisabled(!isCommentsVisible && !value || !!this._state.wsProps['Objects']);
(value!==undefined) && this.view.btnCommentResolve && this.view.btnCommentResolve.setDisabled(!isCommentsVisible && !value || !!this._state.wsProps['Objects']);
}, },
textInserted: '<b>Inserted:</b>', textInserted: '<b>Inserted:</b>',

View file

@ -803,7 +803,7 @@ define([
} }
}, },
SetDisabled: function (state, langs) { SetDisabled: function (state, langs, protectProps) {
this.btnsSpelling && this.btnsSpelling.forEach(function(button) { this.btnsSpelling && this.btnsSpelling.forEach(function(button) {
if ( button ) { if ( button ) {
button.setDisabled(state); button.setDisabled(state);
@ -821,8 +821,8 @@ define([
}, this); }, this);
// this.btnChat && this.btnChat.setDisabled(state); // this.btnChat && this.btnChat.setDisabled(state);
this.btnCommentRemove && this.btnCommentRemove.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment")); this.btnCommentRemove && this.btnCommentRemove.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment") || protectProps && protectProps.comments);
this.btnCommentResolve && this.btnCommentResolve.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment")); this.btnCommentResolve && this.btnCommentResolve.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment") || protectProps && protectProps.comments);
}, },
onLostEditRights: function() { onLostEditRights: function() {

View file

@ -899,6 +899,10 @@ define([
} }
}, },
isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
textNoTextFound : 'Text not found', textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document', newDocumentTitle : 'Unnamed document',
requestEditRightsText : 'Requesting editing rights...', requestEditRightsText : 'Requesting editing rights...',

View file

@ -796,6 +796,10 @@ define([
this.leftMenu.btnThumbs.setDisabled(disable); this.leftMenu.btnThumbs.setDisabled(disable);
}, },
isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
textNoTextFound : 'Text not found', textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document', newDocumentTitle : 'Unnamed document',
requestEditRightsText : 'Requesting editing rights...', requestEditRightsText : 'Requesting editing rights...',

View file

@ -1026,6 +1026,10 @@ define([
Common.Gateway.requestHistory(); Common.Gateway.requestHistory();
}, },
isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
textNoTextFound : 'Text not found', textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document', newDocumentTitle : 'Unnamed document',
textItemEntireCell : 'Entire cell contents', textItemEntireCell : 'Entire cell contents',