From 68fc002dc3ab97651411a2448dbae28ee71831eb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 30 Jun 2021 00:31:55 +0300 Subject: [PATCH] Refactoring --- .../main/lib/controller/ReviewChanges.js | 23 +------ .../main/app/controller/FormsTab.js | 14 ----- .../main/app/controller/LeftMenu.js | 20 ++++--- .../main/app/controller/Main.js | 60 +++++-------------- apps/documenteditor/main/app/view/FileMenu.js | 22 ++++--- apps/documenteditor/main/app/view/LeftMenu.js | 2 +- .../main/app/view/MailMergeSettings.js | 13 ---- .../main/app/view/SignatureSettings.js | 17 ------ 8 files changed, 44 insertions(+), 127 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 4ebedb97a..9a1b9cc68 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -738,7 +738,7 @@ define([ rightMenu: {clear: true, disable: true}, statusBar: true, leftMenu: {disable: false, previewMode: true}, - fileMenu: {protect: true, save: false, rename: false}, + fileMenu: {protect: true}, navigation: {disable: false, previewMode: true}, comments: {disable: false, previewMode: true}, chat: false, @@ -749,27 +749,6 @@ define([ plugins: true }); - - // var app = this.getApplication(); - // app.getController('Toolbar').DisableToolbar(disable, false, true); - // app.getController('DocumentHolder').getView().SetDisabled(disable); - - // if (this.appConfig.canReview) { - // app.getController('RightMenu').getView('RightMenu').clearSelection(); - // app.getController('RightMenu').SetDisabled(disable, false); - // app.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - // app.getController('Navigation') && app.getController('Navigation').SetDisabled(disable); - // app.getController('Common.Controllers.Plugins').getView('Common.Views.Plugins').disableControls(disable); - // } - - // var comments = app.getController('Common.Controllers.Comments'); - // if (comments) - // comments.setPreviewMode(disable); - - // var leftMenu = app.getController('LeftMenu'); - // leftMenu.leftMenu.getMenu('file').getButton('protect').setDisabled(disable); - // leftMenu.setPreviewMode(disable); - if (this.view) { this.view.$el.find('.no-group-mask.review').css('opacity', 1); diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index d38d7b09d..3dfb8c9f8 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -273,20 +273,6 @@ define([ toolbar: true, plugins: false }); - - // var app = this.getApplication(); - // var rightMenuController = app.getController('RightMenu'); - // rightMenuController.getView('RightMenu').clearSelection(); - // rightMenuController.SetDisabled(disable); - // app.getController('Toolbar').DisableToolbar(disable, false, false, true); - // app.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - // app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); - // app.getController('DocumentHolder').getView().SetDisabled(disable); - // app.getController('Navigation') && app.getController('Navigation').SetDisabled(disable); - // app.getController('LeftMenu').setPreviewMode(disable); - // var comments = app.getController('Common.Controllers.Comments'); - // if (comments) - // comments.setPreviewMode(disable); if (this.view) this.view.$el.find('.no-group-mask.form-view').css('opacity', 1); } diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 72ed69f31..17a145b1a 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -667,13 +667,19 @@ define([ }, SetDisabled: function(disable, options) { - this.mode.isEdit = !disable; - if (disable) this.leftMenu.close(); + if (this.leftMenu._state.disabled !== disable) { + this.leftMenu._state.disabled = disable; + if (disable) { + this.previsEdit = this.mode.isEdit; + this.prevcanEdit = this.mode.canEdit; + this.mode.isEdit = this.mode.canEdit = !disable; + } else { + this.mode.isEdit = this.previsEdit; + this.mode.canEdit = this.prevcanEdit; + } + } - // var comments = this.getApplication().getController('Common.Controllers.Comments'); - // if (comments) - // comments.setPreviewMode(disable); - // this.setPreviewMode(disable); + if (disable) this.leftMenu.close(); if (!options || options.comments && options.comments.disable) this.leftMenu.btnComments.setDisabled(disable); @@ -683,8 +689,6 @@ define([ this.leftMenu.btnNavigation.setDisabled(disable); this.leftMenu.btnPlugins.setDisabled(disable); - - // if (disableFileMenu) this.leftMenu.getMenu('file').SetDisabled(disable); }, /** coauthoring begin **/ diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 5001551e7..e008f0e5e 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -213,8 +213,7 @@ define([ Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); - Common.NotificationCenter.on('editing:disable', _.bind(this.disableEditing2, this)); - + Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); this.isShowOpenDialog = false; @@ -707,17 +706,6 @@ define([ disableEditing: function(disable, temp) { var app = this.getApplication(); - if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') { - // app.getController('RightMenu').getView('RightMenu').clearSelection(); - // app.getController('RightMenu').SetDisabled(disable, false); - // app.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - } - // app.getController('LeftMenu').SetDisabled(disable, true, viewmode); - // app.getController('Toolbar').DisableToolbar(disable, disable); - // app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); - // app.getController('Viewport').SetDisabled(disable); - // app.getController('DocumentHolder').getView().SetDisabled(disable); - Common.NotificationCenter.trigger('editing:disable', disable, { viewMode: disable, reviewMode: false, @@ -728,7 +716,7 @@ define([ rightMenu: {clear: true, disable: true}, statusBar: true, leftMenu: {disable: true, previewMode: true}, - fileMenu: {protect: true, save: true, rename: true}, + fileMenu: {protect: true, history: temp}, navigation: {disable: !temp, previewMode: true}, comments: {disable: !temp, previewMode: true}, chat: true, @@ -738,28 +726,9 @@ define([ toolbar: true, plugins: false }); - - - // this.disableEditing2(disable, { - // viewMode: disable, - // reviewMode: false, - // fillFormwMode: false, - // allowMerge: false, - // allowSignature: false, - // allowProtect: false, - // rightMenu: {clear: true, disable: true}, - // statusBar: true, - // leftMenu: {disable: true, previewMode: true}, - // fileMenu: true, - // comments: {previewMode: true}, - // review: true, - // viewport: true, - // documentHolder: true, - // toolbar: true // check!!! - // }); }, - disableEditing2: function(disable, options) { + onEditingDisable: function(disable, options) { var app = this.getApplication(); if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') { @@ -934,6 +903,10 @@ define([ Common.Utils.InternalSettings.get("de-settings-livecomment") ? this.api.asc_showComments(Common.Utils.InternalSettings.get("de-settings-resolvedcomment")) : this.api.asc_hideComments(); } + if ( id == Asc.c_oAscAsyncAction['Disconnect']) { + this.disableEditing(false, true); + } + if ( type == Asc.c_oAscAsyncActionType.BlockInteraction && (!this.getApplication().getController('LeftMenu').dlgSearch || !this.getApplication().getController('LeftMenu').dlgSearch.isVisible()) && (!this.getApplication().getController('Toolbar').dlgSymbolTable || !this.getApplication().getController('Toolbar').dlgSymbolTable.isVisible()) && @@ -1034,6 +1007,12 @@ define([ title = this.loadingDocumentTitleText + ' '; text = this.loadingDocumentTextText; break; + + case Asc.c_oAscAsyncAction['Disconnect']: + text = this.textDisconnect; + this.disableEditing(true, true); + break; + default: if (typeof action.id == 'string'){ title = action.id; @@ -2515,16 +2494,6 @@ define([ var me = this; var _disable_ui = function (disable) { me.disableEditing(disable, true); - // var app = me.getApplication(); - // app.getController('DocumentHolder').getView().SetDisabled(disable); - // app.getController('Navigation') && app.getController('Navigation').SetDisabled(disable); - // - // var leftMenu = app.getController('LeftMenu'); - // leftMenu.leftMenu.getMenu('file').getButton('protect').setDisabled(disable); - // leftMenu.setPreviewMode(disable); - // - // var comments = app.getController('Common.Controllers.Comments'); - // if (comments) comments.setPreviewMode(disable); }; Common.Utils.warningDocumentIsLocked({disablefunc: _disable_ui}); @@ -3011,7 +2980,8 @@ define([ txtNoTableOfFigures: "No table of figures entries found.", txtTableOfFigures: 'Table of figures', txtStyle_endnote_text: 'Endnote Text', - txtTOCHeading: 'TOC Heading' + txtTOCHeading: 'TOC Heading', + textDisconnect: 'Connection is lost' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index f15cc6ff5..6d970f307 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -182,6 +182,10 @@ define([ caption : this.btnHistoryCaption, canFocused: false }); + if ( !!this.options.miHistory ) { + this.miHistory.setDisabled(this.options.miHistory.isDisabled()); + delete this.options.miHistory; + } this.miHelp = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-help'), @@ -272,7 +276,7 @@ define([ applyMode: function() { if (!this.rendered) return; - + if (!this.panels) { this.panels = { 'opts' : (new DE.Views.FileMenuPanels.Settings({menu:this})).render(this.$el.find('#panel-settings')), @@ -413,13 +417,11 @@ define([ }, SetDisabled: function(disable, options) { - var _btn_save = this.getButton('save'), - _btn_rename = this.getButton('rename'), - _btn_protect = this.getButton('protect'); + var _btn_protect = this.getButton('protect'), + _btn_history = this.getButton('history'); - options && options.save && _btn_save.setDisabled(disable || !this.mode.isEdit); - options && options.protect && _btn_protect.setDisabled(disable || !this.mode.isEdit); - options && options.rename && _btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp); + options && options.protect && _btn_protect.setDisabled(disable); + options && options.history && _btn_history.setDisabled(disable); }, isVisible: function () { @@ -436,6 +438,9 @@ define([ } else if (type == 'protect') { return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({})); + } else + if (type == 'history') { + return this.options.miHistory ? this.options.miHistory : (this.options.miHistory = new Common.UI.MenuItem({})); } } else { if (type == 'save') { @@ -446,6 +451,9 @@ define([ }else if (type == 'protect') { return this.miProtect; + }else + if (type == 'history') { + return this.miHistory; } } }, diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index 5fa9eb4dc..a98cb6ba1 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -86,7 +86,7 @@ define([ initialize: function () { this.minimizedMode = true; - this._state = {}; + this._state = {disabled: false}; }, render: function () { diff --git a/apps/documenteditor/main/app/view/MailMergeSettings.js b/apps/documenteditor/main/app/view/MailMergeSettings.js index db738ae2e..f3f194786 100644 --- a/apps/documenteditor/main/app/view/MailMergeSettings.js +++ b/apps/documenteditor/main/app/view/MailMergeSettings.js @@ -820,19 +820,6 @@ define([ plugins: false }); - // DE.getController('Toolbar').DisableToolbar(disable, disable); - // DE.getController('RightMenu').SetDisabled(disable, true); - // DE.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - // DE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); - // DE.getController('DocumentHolder').getView().SetDisabled(disable); - // DE.getController('Navigation') && DE.getController('Navigation').SetDisabled(disable); - - // var comments = DE.getController('Common.Controllers.Comments'); - // if (comments) - // comments.setPreviewMode(disable); - - // DE.getController('LeftMenu').setPreviewMode(disable); - this.lockControls(DE.enumLockMM.preview, disable, {array: [this.btnInsField, this.btnEditData]}); }, diff --git a/apps/documenteditor/main/app/view/SignatureSettings.js b/apps/documenteditor/main/app/view/SignatureSettings.js index 3a2f202b9..2ef9ec848 100644 --- a/apps/documenteditor/main/app/view/SignatureSettings.js +++ b/apps/documenteditor/main/app/view/SignatureSettings.js @@ -413,23 +413,6 @@ define([ toolbar: true, plugins: false }); - - // var rightMenuController = DE.getController('RightMenu'); - // if (disable && rightMenuController.rightmenu.GetActivePane() !== 'id-signature-settings') - // rightMenuController.rightmenu.clearSelection(); - // rightMenuController.SetDisabled(disable, false, true); - // DE.getController('Toolbar').DisableToolbar(disable, disable); - // DE.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - // DE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); - // DE.getController('DocumentHolder').getView().SetDisabled(disable, true); - // DE.getController('Navigation') && DE.getController('Navigation').SetDisabled(disable); - - // var leftMenu = DE.getController('LeftMenu').leftMenu; - // leftMenu.btnComments.setDisabled(disable); - // DE.getController('LeftMenu').setPreviewMode(disable); - // var comments = DE.getController('Common.Controllers.Comments'); - // if (comments) - // comments.setPreviewMode(disable); } },