From f50d0253ca3dcd73fe6930b8bad805e0ed32dab9 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 29 Apr 2020 20:54:48 +0300 Subject: [PATCH] [all] debug locked file open --- apps/common/locale.js | 3 +++ apps/common/main/lib/controller/Desktop.js | 8 +++--- apps/common/main/lib/util/utils.js | 24 +++++++++++++++++ .../main/app/controller/Main.js | 27 +++---------------- apps/documenteditor/main/locale/en.json | 2 +- .../main/app/controller/Main.js | 14 ++++++++++ apps/presentationeditor/main/locale/en.json | 1 + .../main/app/controller/Main.js | 16 +++++++++++ apps/spreadsheeteditor/main/locale/en.json | 1 + 9 files changed, 68 insertions(+), 28 deletions(-) diff --git a/apps/common/locale.js b/apps/common/locale.js index d954165fc..7990b2c8d 100644 --- a/apps/common/locale.js +++ b/apps/common/locale.js @@ -74,6 +74,9 @@ Common.Locale = new(function() { var res = ''; if (l10n && scope && scope.name) { res = l10n[scope.name + '.' + prop]; + + if ( !res && scope.default ) + res = scope.default; } return res || (scope ? eval(scope.name).prototype[prop] : ''); diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 6d3e41a40..a5cd5bae3 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -201,9 +201,11 @@ define([ }); Common.NotificationCenter.on('document:ready', function () { - var maincontroller = webapp.getController('Main'); - if ( maincontroller.api.asc_isReadOnly && maincontroller.api.asc_isReadOnly() ) { - maincontroller.warningDocumentIsLocked(); + if ( config.isEdit ) { + var maincontroller = webapp.getController('Main'); + if (maincontroller.api.asc_isReadOnly && maincontroller.api.asc_isReadOnly()) { + maincontroller.warningDocumentIsLocked(); + } } }); diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 57e933da4..39bbf45a9 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -853,6 +853,30 @@ Common.Utils.injectComponent = function ($slot, cmp) { } }; +Common.Utils.warningDocumentIsLocked = function (opts) { + if ( opts.disablefunc ) + opts.disablefunc(true); + + var app = window.DE || window.PE || window.SSE; + var tip = new Common.UI.SynchronizeTip({ + extCls : 'simple', + text : Common.Locale.get("warnFileLocked",{name:"Common.Translation", default:'Document is in use by another application. You can continue editing and save it as a copy.'}), + textLink : Common.Locale.get("txtContinueEditing",{name:app.nameSpace + ".Views.SignatureSettings", default:'Edit anyway'}), + placement : 'document' + }); + tip.on({ + 'dontshowclick': function() { + if ( opts.disablefunc ) opts.disablefunc(false); + app.getController('Main').api.asc_setIsReadOnly(false); + this.close(); + }, + 'closeclick': function() { + this.close(); + } + }); + tip.show(); +}; + jQuery.fn.extend({ elementById: function (id, parent) { /** diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 1cdc0ff1a..bf8dc0e8e 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -2222,36 +2222,15 @@ define([ warningDocumentIsLocked: function() { var me = this; var _disable_ui = function (disable) { - DE.getController('RightMenu').SetDisabled(disable, false, true); - DE.getController('Toolbar').DisableToolbar(disable, disable); - DE.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - DE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); + me.disableEditing(disable); DE.getController('DocumentHolder').getView().SetDisabled(disable, true); DE.getController('Navigation') && DE.getController('Navigation').SetDisabled(disable); DE.getController('LeftMenu').setPreviewMode(disable); var comments = DE.getController('Common.Controllers.Comments'); if (comments) comments.setPreviewMode(disable); - } + }; - _disable_ui(true); - - var tip = new Common.UI.SynchronizeTip({ - extCls : 'simple', - text : Common.Locale.get("warnFileLocked",{name:"DE.Controllers.Main"}), - textLink : Common.Locale.get("txtContinueEditing",{name:"DE.Views.SignatureSettings"}), - placement : 'document' - }); - tip.on({ - 'dontshowclick': function() { - _disable_ui(false); - me.api.asc_setIsReadOnly(false); - this.close(); - }, - 'closeclick': function() { - this.close(); - } - }); - tip.show(); + Common.Utils.warningDocumentIsLocked({disablefunc: _disable_ui}); }, leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 7cc96cf00..6a2e1ee46 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -71,6 +71,7 @@ "Common.Controllers.ReviewChanges.textUnderline": "Underline", "Common.Controllers.ReviewChanges.textUrl": "Paste a document URL", "Common.Controllers.ReviewChanges.textWidow": "Widow control", + "Common.Translation.warnFileLocked": "Document is in use by another application. You can continue editing and save it as a copy.", "Common.define.chartData.textArea": "Area", "Common.define.chartData.textBar": "Bar", "Common.define.chartData.textCharts": "Charts", @@ -743,7 +744,6 @@ "DE.Controllers.Main.warnNoLicense": "This version of %1 editors has certain limitations for concurrent connections to the document server.
If you need more please consider purchasing a commercial license.", "DE.Controllers.Main.warnNoLicenseUsers": "This version of %1 editors has certain limitations for concurrent users.
If you need more please consider purchasing a commercial license.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", - "DE.Controllers.Main.warnFileLocked": "Document is in use by another application. You can continue editing and save it as a copy.", "DE.Controllers.Main.textConvertEquation": "This equation was created with an old version of equation editor which is no longer supported. Converting this equation to Office Math ML format will make it editable.
Do you want to convert this equation?", "DE.Controllers.Main.textApplyAll": "Apply to all equations", "DE.Controllers.Main.textLearnMore": "Learn More", diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index b32a87ac0..bcbc8026b 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1866,6 +1866,20 @@ define([ } }, + warningDocumentIsLocked: function() { + var me = this; + Common.Utils.warningDocumentIsLocked({ + disablefunc: function (disable) { + me.disableEditing(disable); + PE.getController('RightMenu').SetDisabled(disable, true); + PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); + PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable); + PE.getController('LeftMenu').setPreviewMode(disable); + var comments = PE.getController('Common.Controllers.Comments'); + if (comments) comments.setPreviewMode(disable); + }}); + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index bf5cd807c..c7f9fc9ce 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1,4 +1,5 @@ { + "Common.Translation.warnFileLocked": "Document is in use by another application. You can continue editing and save it as a copy.", "Common.Controllers.Chat.notcriticalErrorTitle": "Warning", "Common.Controllers.Chat.textEnterMessage": "Enter your message here", "Common.Controllers.ExternalDiagramEditor.textAnonymous": "Anonymous", diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 7dee9bd7c..ed18c256e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2164,6 +2164,22 @@ define([ if (url) this.iframePrint.src = url; }, + warningDocumentIsLocked: function() { + var me = this; + Common.Utils.warningDocumentIsLocked({ + disablefunc: function (disable) { + me.disableEditing(disable); + + SSE.getController('RightMenu').SetDisabled(disable, true); + SSE.getController('Statusbar').SetDisabled(disable); + SSE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); + SSE.getController('DocumentHolder').SetDisabled(disable, true); + SSE.getController('LeftMenu').setPreviewMode(disable); + var comments = SSE.getController('Common.Controllers.Comments'); + if (comments) comments.setPreviewMode(disable); + }}); + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 13fa749b0..9808366fd 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1,5 +1,6 @@ { "cancelButtonText": "Cancel", + "Common.Translation.warnFileLocked": "Document is in use by another application. You can continue editing and save it as a copy.", "Common.Controllers.Chat.notcriticalErrorTitle": "Warning", "Common.Controllers.Chat.textEnterMessage": "Enter your message here", "Common.define.chartData.textArea": "Area",