diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 65bcb0e22..a8357d176 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -144,10 +144,12 @@ define([ } }, this, area); }.bind(this)); + Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this)); }, onLaunch: function () { var filter = Common.localStorage.getKeysFilter(); this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; + this._state = {viewmode: false}; this.collection = this.getApplication().getCollection('Common.Collections.Comments'); this.setComparator(); @@ -1645,16 +1647,26 @@ define([ }, setPreviewMode: function(mode) { - if (this.viewmode === mode) return; - this.viewmode = mode; - if (mode) + this._state.viewmode = mode; + this.updatePreviewMode(); + }, + + updatePreviewMode: function() { + var lockMode = this._state.docProtection ? this._state.docProtection.lockMode : undefined; + lockMode = (lockMode===Asc.c_oAscProtection.View || lockMode===Asc.c_oAscProtection.Forms); + var viewmode = this._state.viewmode || lockMode; + + if (this.viewmode === viewmode) return; + this.viewmode = viewmode; + + if (viewmode) this.prevcanComments = this.mode.canComments; - this.mode.canComments = (mode) ? false : this.prevcanComments; + this.mode.canComments = (viewmode) ? false : this.prevcanComments; this.closeEditing(); this.setMode(this.mode); this.updateComments(true); if (this.getPopover()) - mode ? this.getPopover().hide() : this.getPopover().update(true); + viewmode ? this.getPopover().hide() : this.getPopover().update(true); }, clearCollections: function() { @@ -1718,6 +1730,17 @@ define([ } } this.updateComments(true); + }, + + onChangeProtectDocument: function(props) { + if (!props) { + var docprotect = this.getApplication().getController('DocProtection'); + props = docprotect ? docprotect.getDocProps() : null; + } + if (props) { + this._state.docProtection = props; + this.updatePreviewMode(); + } } }, Common.Controllers.Comments || {})); diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index d25d1a9c6..b395255a8 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -102,7 +102,7 @@ define([ this.userCollection = this.getApplication().getCollection('Common.Collections.Users'); this.viewmode = false; - this._state = {posx: -1000, posy: -1000, popoverVisible: false, previewMode: false, compareSettings: null, wsLock: false, wsProps: []}; + this._state = {posx: -1000, posy: -1000, popoverVisible: false, previewMode: false, compareSettings: null, wsLock: false, wsProps: [], viewmode: false}; Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); @@ -180,11 +180,20 @@ define([ }, setPreviewMode: function(mode) { //disable accept/reject in popover - if (this.viewmode === mode) return; - this.viewmode = mode; - if (mode) + this._state.viewmode = mode; + this.updatePreviewMode(); + }, + + updatePreviewMode: function() { + var lockMode = this._state.docProtection ? this._state.docProtection.lockMode : undefined; + lockMode = (lockMode===Asc.c_oAscProtection.View || lockMode===Asc.c_oAscProtection.Forms || lockMode===Asc.c_oAscProtection.Comments); + var viewmode = this._state.viewmode || lockMode; + + if (this.viewmode === viewmode) return; + this.viewmode = viewmode; + if (viewmode) this.prevcanReview = this.appConfig.canReview; - this.appConfig.canReview = (mode) ? false : this.prevcanReview; + this.appConfig.canReview = (viewmode) ? false : this.prevcanReview; var me = this; this.popoverChanges && this.popoverChanges.each(function (model) { model.set('hint', !me.appConfig.canReview); @@ -1024,6 +1033,7 @@ define([ this.lockToolbar(Common.enumLock.docLockForms, props.docLock && (props.lockMode===Asc.c_oAscProtection.Forms)); this.lockToolbar(Common.enumLock.docLockReview, props.docLock && (props.lockMode===Asc.c_oAscProtection.Review)); this.lockToolbar(Common.enumLock.docLockComments, props.docLock && (props.lockMode===Asc.c_oAscProtection.Comments)); + this.updatePreviewMode(); } }, diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 1a9e70001..1fe6247ad 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -113,12 +113,13 @@ define([ if ( !this.leftMenu.panelHistory.isVisible() ) this.clickMenuFileItem(null, 'history'); }, this)); + Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this)); }, onLaunch: function() { this.leftMenu = this.createView('LeftMenu').render(); this.leftMenu.btnSearchBar.on('toggle', _.bind(this.onMenuSearchBar, this)); - + this._state = {viewmode: false}; Common.util.Shortcuts.delegateShortcuts({ shortcuts: { 'command+shift+s,ctrl+shift+s': _.bind(this.onShortcut, this, 'save'), @@ -581,8 +582,16 @@ define([ }, setPreviewMode: function(mode) { - if (this.viewmode === mode) return; - this.viewmode = mode; + this._state.viewmode = mode; + this.updatePreviewMode(); + }, + + updatePreviewMode: function() { + var lockMode = this._state.docProtection ? this._state.docProtection.lockMode : undefined; + lockMode = (lockMode===Asc.c_oAscProtection.View || lockMode===Asc.c_oAscProtection.Forms); + var viewmode = this._state.viewmode || lockMode; + if (this.viewmode === viewmode) return; + this.viewmode = viewmode; this.leftMenu.panelSearch && this.leftMenu.panelSearch.setSearchMode(this.viewmode ? 'no-replace' : 'search'); }, @@ -887,6 +896,17 @@ define([ return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible(); }, + onChangeProtectDocument: function(props) { + if (!props) { + var docprotect = this.getApplication().getController('DocProtection'); + props = docprotect ? docprotect.getDocProps() : null; + } + if (props) { + this._state.docProtection = props; + this.updatePreviewMode(); + } + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', requestEditRightsText : 'Requesting editing rights...',