From 5ffb7e8fa0067e71c4e5e4271cd1f123166940bb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 20 Aug 2021 17:38:32 +0300 Subject: [PATCH] [SSE] Disable remove/resolve comment buttons when objects protected --- .../main/lib/controller/ReviewChanges.js | 28 +++++++++++++++---- apps/common/main/lib/view/ReviewChanges.js | 6 ++-- .../main/app/controller/LeftMenu.js | 4 +++ .../main/app/controller/LeftMenu.js | 4 +++ .../main/app/controller/LeftMenu.js | 4 +++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index fafa6cdc55..49043cefc0 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -109,6 +109,7 @@ define([ Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.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('add', _.bind(this.onUpdateUsers, this)); @@ -163,7 +164,7 @@ define([ SetDisabled: function(state) { if (this.dlgChanges) 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); }, @@ -840,9 +841,10 @@ define([ me.view.turnChat(state); }); } + me.onChangeProtectSheet(); if (me.view) { - me.view.btnCommentRemove && me.view.btnCommentRemove.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)); + 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) || !!this._state.wsProps['Objects']); } }, @@ -974,8 +976,24 @@ define([ commentsShowHide: function(mode) { if (!this.view) return; 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.btnCommentResolve && this.view.btnCommentResolve.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 || !!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: 'Inserted:', diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 04d197591c..c7d7b4251f 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -803,7 +803,7 @@ define([ } }, - SetDisabled: function (state, langs) { + SetDisabled: function (state, langs, protectProps) { this.btnsSpelling && this.btnsSpelling.forEach(function(button) { if ( button ) { button.setDisabled(state); @@ -821,8 +821,8 @@ define([ }, this); // this.btnChat && this.btnChat.setDisabled(state); - this.btnCommentRemove && this.btnCommentRemove.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment")); - this.btnCommentResolve && this.btnCommentResolve.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") || protectProps && protectProps.comments); }, onLostEditRights: function() { diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index c57d4026c2..683a81bbf7 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -899,6 +899,10 @@ define([ } }, + isCommentsVisible: function() { + return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible(); + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', requestEditRightsText : 'Requesting editing rights...', diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 31b3eaa988..ed7d2ebc12 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -796,6 +796,10 @@ define([ this.leftMenu.btnThumbs.setDisabled(disable); }, + isCommentsVisible: function() { + return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible(); + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', requestEditRightsText : 'Requesting editing rights...', diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 27f16d8d1a..6da017281a 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -1026,6 +1026,10 @@ define([ Common.Gateway.requestHistory(); }, + isCommentsVisible: function() { + return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible(); + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', textItemEntireCell : 'Entire cell contents',