From 00fb06281eb1c80b0440e0408e7bce1d16a1dbbe Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 14 Jun 2017 14:53:29 +0300 Subject: [PATCH] View mode with commenting (permissions.comments = true). --- apps/common/main/lib/controller/Comments.js | 13 ++--- .../main/app/controller/LeftMenu.js | 4 +- .../main/app/controller/Main.js | 23 ++++---- .../main/app/view/DocumentHolder.js | 11 ++-- .../main/app/view/FileMenuPanels.js | 9 ++-- .../main/app/controller/LeftMenu.js | 4 +- .../main/app/controller/Main.js | 28 +++++----- .../main/app/view/DocumentHolder.js | 11 ++-- .../main/app/controller/DocumentHolder.js | 34 ++++++------ .../main/app/controller/LeftMenu.js | 4 +- .../main/app/controller/Main.js | 52 ++++++++----------- .../main/app/controller/Toolbar.js | 8 +-- .../main/app/view/FileMenu.js | 4 +- .../main/app/view/FileMenuPanels.js | 15 +++--- 14 files changed, 115 insertions(+), 105 deletions(-) diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 11626936b..867fb158a 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -750,14 +750,15 @@ define([ if (this.mode && !this.mode.canComments) hint = true; - if (this.getPopover()) { + var popover = this.getPopover(); + if (popover) { this.clearDummyComment(); if (this.isSelectedComment && (0 === _.difference(this.uids, uids).length)) { //NOTE: click to sdk view ? if (this.api) { //this.view.txtComment.blur(); - this.getPopover().commentsView.setFocusToTextBox(true); + popover.commentsView && popover.commentsView.setFocusToTextBox(true); this.api.asc_enableKeyEvents(true); } @@ -813,12 +814,12 @@ define([ this._dontScrollToComment = false; } - if (this.getPopover().isVisible()) { - this.getPopover().hide(); + if (popover.isVisible()) { + popover.hide(); } - this.getPopover().setLeftTop(posX, posY, leftX); - this.getPopover().show(animate, false, true, text); + popover.setLeftTop(posX, posY, leftX); + popover.show(animate, false, true, text); } }, onApiHideComment: function (hint) { diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 066f625af..ce78fda3c 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -166,7 +166,7 @@ define([ createDelayedElements: function() { /** coauthoring begin **/ if ( this.mode.canCoAuthoring ) { - this.leftMenu.btnComments[(this.mode.isEdit && this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); + this.leftMenu.btnComments[(this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); if (this.mode.canComments) this.leftMenu.setOptionsPanel('comment', this.getApplication().getController('Common.Controllers.Comments').getView()); @@ -623,7 +623,7 @@ define([ } return false; case 'comments': - if (this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments && !this.mode.isLightVersion) { + if (this.mode.canCoAuthoring && this.mode.canComments && !this.mode.isLightVersion) { Common.UI.Menu.Manager.hideAll(); this.leftMenu.showMenu('comments'); this.getApplication().getController('Common.Controllers.Comments').onAfterShow(); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index fdf1f006a..ad7c35ac1 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -968,8 +968,9 @@ define([ this.appOptions.canHistoryRestore= this.editorConfig.canHistoryRestore && !!this.permissions.changeHistory; this.appOptions.canUseMailMerge= this.appOptions.canLicense && this.appOptions.canEdit && !this.appOptions.isOffline; this.appOptions.canSendEmailAddresses = this.appOptions.canLicense && this.editorConfig.canSendEmailAddresses && this.appOptions.canEdit && this.appOptions.canCoAuthoring; - this.appOptions.canComments = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); - this.appOptions.canChat = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); + this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comments===undefined ? this.appOptions.isEdit : this.permissions.comments); + this.appOptions.canComments = this.appOptions.canComments && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); + this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; @@ -1007,16 +1008,16 @@ define([ this.updatePlugins(this.plugins, true); this.applyModeCommonElements(); - if ( this.appOptions.isEdit ) { - this.applyModeEditorElements(); - } else { + this.applyModeEditorElements(); + + if ( !this.appOptions.isEdit ) { Common.NotificationCenter.trigger('app:face', this.appOptions); this.hidePreloader(); this.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); } - this.api.asc_setViewMode(!this.appOptions.isEdit); + this.api.asc_setViewMode(!this.appOptions.isEdit && !this.appOptions.canComments); this.api.asc_LoadDocument(); }, @@ -1060,6 +1061,12 @@ define([ }, applyModeEditorElements: function() { + if (this.appOptions.canComments || this.appOptions.isEdit) { + /** coauthoring begin **/ + this.contComments.setMode(this.appOptions); + this.contComments.setConfig({config: this.editorConfig}, this.api); + /** coauthoring end **/ + } if (this.appOptions.isEdit) { var me = this, application = this.getApplication(), @@ -1071,10 +1078,6 @@ define([ fontsControllers && fontsControllers.setApi(me.api); toolbarController && toolbarController.setApi(me.api); - /** coauthoring begin **/ - me.contComments.setMode(me.appOptions); - me.contComments.setConfig({config: me.editorConfig}, me.api); - /** coauthoring end **/ rightmenuController && rightmenuController.setApi(me.api); if (reviewController) diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index 0811fcd0e..a39beaab9 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -1540,7 +1540,7 @@ define([ this.mode = m; /** coauthoring begin **/ - !(this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments) + !(this.mode.canCoAuthoring && this.mode.canComments) ? Common.util.Shortcuts.suspendEvents(hkComments) : Common.util.Shortcuts.resumeEvents(hkComments); /** coauthoring end **/ @@ -1725,7 +1725,7 @@ define([ /** coauthoring begin **/ addComment: function(item, e, eOpt){ - if (this.api && this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments) { + if (this.api && this.mode.canCoAuthoring && this.mode.canComments) { this.suppressEditComplete = true; var controller = DE.getController('Common.Controllers.Comments'); @@ -1818,9 +1818,10 @@ define([ initMenu: function (value) { var isInChart = (value.imgProps && value.imgProps.value && !_.isNull(value.imgProps.value.get_ChartProperties())); - menuViewUndo.setVisible(me.mode.isEdit); - menuViewCopySeparator.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit); - menuViewAddComment.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit); + menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments); + menuViewUndo.setDisabled(/* !me.api.asc_canUndo()*/); + menuViewCopySeparator.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments); + menuViewAddComment.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments); menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true); var cancopy = me.api && me.api.can_CopyCut(); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 8d846efa4..4040f6f39 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -111,14 +111,14 @@ define([ template: _.template([ '', /** coauthoring begin **/ - '', + '', '', '', - '','', - '', + '','', + '', '', '', - '','', + '','', /** coauthoring end **/ '', '', @@ -337,6 +337,7 @@ define([ /** coauthoring begin **/ $('tr.coauth', this.el)[mode.isEdit && mode.canCoAuthoring ? 'show' : 'hide'](); $('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide'](); + $('tr.comments', this.el)[mode.canCoAuthoring && mode.canComments ? 'show' : 'hide'](); /** coauthoring end **/ }, diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 453df76aa..2a7d757d9 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -159,7 +159,7 @@ define([ createDelayedElements: function() { /** coauthoring begin **/ if ( this.mode.canCoAuthoring ) { - this.leftMenu.btnComments[(this.mode.isEdit&&this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); + this.leftMenu.btnComments[(this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); if (this.mode.canComments) this.leftMenu.setOptionsPanel('comment', this.getApplication().getController('Common.Controllers.Comments').getView('Common.Views.Comments')); @@ -505,7 +505,7 @@ define([ } return false; case 'comments': - if (this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments && !this.mode.isLightVersion && (!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) { + if (this.mode.canCoAuthoring && this.mode.canComments && !this.mode.isLightVersion && (!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) { Common.UI.Menu.Manager.hideAll(); this.leftMenu.showMenu('comments'); this.getApplication().getController('Common.Controllers.Comments').onAfterShow(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 0b00ac42c..9ae0fb4dd 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -744,8 +744,9 @@ define([ this.appOptions.isEdit = this.appOptions.canLicense && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; this.appOptions.canDownload = !this.appOptions.nativeApp && this.permissions.download !== false; this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable(); - this.appOptions.canComments = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); - this.appOptions.canChat = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); + this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comments===undefined ? this.appOptions.isEdit : this.permissions.comments); + this.appOptions.canComments = this.appOptions.canComments && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); + this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave); @@ -766,17 +767,16 @@ define([ this.updatePlugins(this.plugins, true); this.applyModeCommonElements(); + this.applyModeEditorElements(); - if ( this.appOptions.isEdit ) { - this.applyModeEditorElements(); - } else { + if ( !this.appOptions.isEdit ) { Common.NotificationCenter.trigger('app:face', this.appOptions); this.hidePreloader(); this.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } - this.api.asc_setViewMode(!this.appOptions.isEdit); + this.api.asc_setViewMode(!this.appOptions.isEdit && !this.appOptions.canComments); this.api.asc_LoadDocument(); }, @@ -817,6 +817,15 @@ define([ }, applyModeEditorElements: function(prevmode) { + if (this.appOptions.canComments || this.appOptions.isEdit) { + /** coauthoring begin **/ + var commentsController = this.getApplication().getController('Common.Controllers.Comments'); + if (commentsController) { + commentsController.setMode(this.appOptions); + commentsController.setConfig({config: this.editorConfig}, this.api); + } + /** coauthoring end **/ + } if (this.appOptions.isEdit) { var me = this, application = this.getApplication(), @@ -828,13 +837,6 @@ define([ fontsControllers && fontsControllers.setApi(me.api); toolbarController && toolbarController.setApi(me.api); - /** coauthoring begin **/ - var commentsController = application.getController('Common.Controllers.Comments'); - if (commentsController) { - commentsController.setMode(this.appOptions); - commentsController.setConfig({config: me.editorConfig}, me.api); - } - /** coauthoring end **/ rightmenuController && rightmenuController.setApi(me.api); var viewport = this.getApplication().getController('Viewport').getView('Viewport'); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 1bc42af9f..2b08705ca 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1527,7 +1527,7 @@ define([ me.mode = mode; /** coauthoring begin **/ - !(me.mode.canCoAuthoring && me.mode.isEdit && me.mode.canComments) + !(me.mode.canCoAuthoring && me.mode.canComments) ? Common.util.Shortcuts.suspendEvents(hkComments) : Common.util.Shortcuts.resumeEvents(hkComments); /** coauthoring end **/ @@ -1609,7 +1609,7 @@ define([ /** coauthoring begin **/ addComment: function(item, e, eOpt){ - if (this.api && this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments) { + if (this.api && this.mode.canCoAuthoring && this.mode.canComments) { this.suppressEditComplete = true; var controller = PE.getController('Common.Controllers.Comments'); @@ -1714,9 +1714,10 @@ define([ this.viewModeMenu = new Common.UI.Menu({ initMenu: function (value) { - menuViewUndo.setVisible(me.mode.isEdit); - menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit); - menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit); + menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments); + menuViewUndo.setDisabled(/* !me.api.asc_canUndo()*/); + menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments); + menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments); menuViewAddComment.setDisabled(value.locked); }, items: [ diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index dde77c532..713ae0c69 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -239,7 +239,7 @@ define([ setMode: function(permissions) { this.permissions = permissions; /** coauthoring begin **/ - !(this.permissions.canCoAuthoring && this.permissions.isEdit && this.permissions.canComments) + !(this.permissions.canCoAuthoring && this.permissions.canComments) ? Common.util.Shortcuts.suspendEvents(this.hkComments) : Common.util.Shortcuts.resumeEvents(this.hkComments); /** coauthoring end **/ @@ -254,17 +254,18 @@ define([ // this.api.asc_registerCallback('asc_onShowComment', this.wrapEvents.apiShowComment); /** coauthoring end **/ this.api.asc_registerCallback('asc_onHyperlinkClick', _.bind(this.onApiHyperlinkClick, this)); - this.api.asc_registerCallback('asc_onSetAFDialog', _.bind(this.onApiAutofilter, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); - this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this)); - this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); - this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); - this.api.asc_registerCallback('asc_onEntriesListMenu', _.bind(this.onEntriesListMenu, this)); // Alt + Down - this.api.asc_registerCallback('asc_onFormulaCompleteMenu', _.bind(this.onFormulaCompleteMenu, this)); - this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this)); - this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); - + this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); + if (this.permissions.isEdit===true) { + this.api.asc_registerCallback('asc_onSetAFDialog', _.bind(this.onApiAutofilter, this)); + this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this)); + this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); + this.api.asc_registerCallback('asc_onEntriesListMenu', _.bind(this.onEntriesListMenu, this)); // Alt + Down + this.api.asc_registerCallback('asc_onFormulaCompleteMenu', _.bind(this.onFormulaCompleteMenu, this)); + this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this)); + this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); + } return this; }, @@ -560,7 +561,7 @@ define([ }, onAddComment: function(item) { - if (this.api && this.permissions.canCoAuthoring && this.permissions.isEdit && this.permissions.canComments) { + if (this.api && this.permissions.canCoAuthoring && this.permissions.canComments) { var controller = SSE.getController('Common.Controllers.Comments'), cellinfo = this.api.asc_getCellInfo(); @@ -952,7 +953,7 @@ define([ } } - if (me.permissions.isEdit) { + if (me.permissions.isEdit || me.permissions.canComments) { if (index_comments && !this.popupmenu) { data = dataarray[index_comments - 1]; if (!commentTip.editCommentId && commentTip.moveCommentId != data.asc_getCommentIndexes()[0]) { @@ -994,7 +995,9 @@ define([ } } } + } + if (me.permissions.isEdit) { if (index_locked) { data = dataarray[index_locked-1]; @@ -1484,9 +1487,10 @@ define([ if (!showMenu && !documentHolder.viewModeMenu.isVisible()) return; - documentHolder.menuViewUndo.setVisible(this.permissions.isEdit); - documentHolder.menuViewCopySeparator.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && this.permissions.isEdit); - documentHolder.menuViewAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && this.permissions.isEdit); + documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments); + documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo()); + documentHolder.menuViewCopySeparator.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); + documentHolder.menuViewAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); documentHolder.setMenuItemCommentCaptionMode(documentHolder.menuViewAddComment, cellinfo.asc_getComments().length < 1, this.permissions.canEditComments); commentsController && commentsController.blockPopover(true); documentHolder.menuViewAddComment.setDisabled(isCellLocked || isTableLocked); diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index ad40bd0a6..4484cc38a 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -166,7 +166,7 @@ define([ createDelayedElements: function() { /** coauthoring begin **/ if ( this.mode.canCoAuthoring ) { - this.leftMenu.btnComments[(this.mode.isEdit&&this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); + this.leftMenu.btnComments[(this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide'](); if (this.mode.canComments) this.leftMenu.setOptionsPanel('comment', this.getApplication().getController('Common.Controllers.Comments').getView('Common.Views.Comments')); @@ -671,7 +671,7 @@ define([ } return false; case 'comments': - if (this.mode.canCoAuthoring && this.mode.isEdit && this.mode.canComments && !this.mode.isLightVersion) { + if (this.mode.canCoAuthoring && this.mode.canComments && !this.mode.isLightVersion) { Common.UI.Menu.Manager.hideAll(); this.leftMenu.showMenu('comments'); this.getApplication().getController('Common.Controllers.Comments').onAfterShow(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9176bca06..4f9d8caf4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -422,7 +422,7 @@ define([ action && this.setLongActionView(action); if (id == Asc.c_oAscAsyncAction.Save) { - this.toolbarView.synchronizeChanges(); + this.toolbarView && this.toolbarView.synchronizeChanges(); } action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction}); @@ -766,8 +766,9 @@ define([ /** coauthoring begin **/ this.appOptions.canCoAuthoring = !this.appOptions.isLightVersion; /** coauthoring end **/ - this.appOptions.canComments = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); - this.appOptions.canChat = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); + this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comments===undefined ? (this.permissions.edit !== false && this.editorConfig.mode !== 'view') : this.permissions.comments); + this.appOptions.canComments = this.appOptions.canComments && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); + this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canRename = !!this.permissions.rename; this.appOptions.isTrial = params.asc_getTrial(); @@ -796,15 +797,16 @@ define([ this._state.licenseWarning = !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; this.applyModeCommonElements(); - if ( this.appOptions.isEdit ) { - this.applyModeEditorElements(); - } else { + this.applyModeEditorElements(); + + if ( !this.appOptions.isEdit ) { Common.NotificationCenter.trigger('app:face', this.appOptions); this.hidePreloader(); this.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); } + this.api.asc_setViewMode(!this.appOptions.isEdit && !this.appOptions.canComments); this.api.asc_setViewMode(!this.appOptions.isEdit); (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram) ? this.api.asc_LoadEmptyDocument() : this.api.asc_LoadDocument(); }, @@ -874,46 +876,38 @@ define([ }, applyModeEditorElements: function(prevmode) { + if (this.appOptions.canComments || this.appOptions.isEdit) { + /** coauthoring begin **/ + var commentsController = this.getApplication().getController('Common.Controllers.Comments'); + if (commentsController) { + commentsController.setMode(this.appOptions); + commentsController.setConfig({ + config : this.editorConfig, + sdkviewname : '#ws-canvas-outer', + hintmode : true}, + this.api); + } + /** coauthoring end **/ + } + if (this.appOptions.isEdit) { var me = this, application = this.getApplication(), toolbarController = application.getController('Toolbar'), statusbarController = application.getController('Statusbar'), rightmenuController = application.getController('RightMenu'), - /** coauthoring begin **/ - commentsController = application.getController('Common.Controllers.Comments'), - /** coauthoring end **/ - fontsControllers = application.getController('Common.Controllers.Fonts'); + fontsControllers = application.getController('Common.Controllers.Fonts'); fontsControllers && fontsControllers.setApi(me.api); toolbarController && toolbarController.setApi(me.api); // statusbarController && statusbarController.setApi(me.api); - if (commentsController) { - commentsController.setMode(this.appOptions); - commentsController.setConfig({ - config : me.editorConfig, - sdkviewname : '#ws-canvas-outer', - hintmode : true}, - me.api); - } - rightmenuController && rightmenuController.setApi(me.api); if (statusbarController) { statusbarController.getView('Statusbar').changeViewMode(true); } - /** coauthoring begin **/ - if (prevmode=='view') { - if (commentsController) { - Common.NotificationCenter.trigger('comments:updatefilter',{ - property : 'uid', - value : new RegExp('^(doc_|sheet' + this.api.asc_getActiveWorksheetId() + '_)')}); - } - } - /** coauthoring end **/ - var viewport = this.getApplication().getController('Viewport').getView('Viewport'); viewport.applyEditorMode(); rightmenuController.getView('RightMenu').setMode(me.appOptions).setApi(me.api); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 8f3d1cdd6..ddbbabf7d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2852,9 +2852,11 @@ define([ }, applyFormulaSettings: function() { - var formulas = this.toolbar.btnInsertFormula.menu.items; - for (var i=0; i0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); - this.items[11][this.mode.isEdit?'show':'hide'](); - this.items[11].$el.find('+.devider')[this.mode.isEdit?'show':'hide'](); + this.items[11][(this.mode.isEdit || this.mode.canComments)?'show':'hide'](); + this.items[11].$el.find('+.devider')[(this.mode.isEdit || this.mode.canComments)?'show':'hide'](); this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : this.$el.find('#fm-btn-back').hide().prev().hide(); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index cca986fc4..35ca7695f 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -439,14 +439,14 @@ define([ template: _.template([ '
', /** coauthoring begin **/ - '', + '', '', '', - '','', - '', + '','', + '', '', '', - '','', + '','', '', '', '', @@ -480,12 +480,12 @@ define([ '
', '
', '
','', - '', + '', '', '', - '','', + '','', '', '', '', @@ -670,13 +670,14 @@ define([ setMode: function(mode) { this.mode = mode; + $('tr.edit', this.el)[mode.isEdit ? 'show' : 'hide'](); $('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide'](); if (this.mode.isDesktopApp && this.mode.isOffline) { this.chAutosave.setCaption(this.strAutoRecover); this.lblAutosave.text(this.textAutoRecover); } $('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide'](); - $('tr.coauth', this.el)[mode.canCoAuthoring && mode.isEdit ? 'show' : 'hide'](); + $('tr.comments', this.el)[mode.canCoAuthoring && mode.canComments ? 'show' : 'hide'](); $('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring? 'show' : 'hide'](); },
', '
', '