From 4fa78dad3a311039c8e697dc3f488e9d1d26d930 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 21 Nov 2022 13:04:25 +0300 Subject: [PATCH] [desktop] 'file locked' message didn't open --- apps/common/main/lib/controller/Desktop.js | 31 +++++++++++---------- apps/documenteditor/main/locale/en.json | 1 + apps/presentationeditor/main/locale/en.json | 2 ++ apps/spreadsheeteditor/main/locale/en.json | 2 ++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 16eaef266..f96088cf4 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -234,21 +234,19 @@ define([ Common.NotificationCenter.on('document:ready', function () { if ( config.isEdit ) { - // var maincontroller = webapp.getController('Main'); - // if (maincontroller.api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== maincontroller.api.asc_getLocalRestrictions()) { - // maincontroller.warningDocumentIsLocked(); - // } - } - }); + function get_locked_message (t) { + switch (t) { + // case Asc.c_oAscLocalRestrictionType.Nosafe: + case Asc.c_oAscLocalRestrictionType.ReadOnly: + return Common.Locale.get("tipFileReadOnly",{name:"Common.Translation", default: "Document is read only. You can make changes and save its local copy later."}); + default: return Common.Locale.get("tipFileLocked",{name:"Common.Translation", default: "Document is locked for editing. You can make changes and save its local copy later."}); + } + } - Common.NotificationCenter.on('app:face', function (mode) { - features.viewmode = !mode.isEdit; - features.crypted = mode.isCrypted; - - const header = webapp.getController('Viewport').getView('Common.Views.Header'); - if ( mode.isEdit ) { + const header = webapp.getController('Viewport').getView('Common.Views.Header'); const api = webapp.getController('Main').api; - if ( api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== api.asc_getLocalRestrictions()) { + const locktype = api.asc_getLocalRestrictions ? api.asc_getLocalRestrictions() : Asc.c_oAscLocalRestrictionType.None; + if ( Asc.c_oAscLocalRestrictionType.None !== locktype ) { features.readonly = true; header.setDocumentReadOnly(true); @@ -258,18 +256,23 @@ define([ extCls: 'no-arrow', placement: 'bottom', target: $('.toolbar'), - text: Common.Locale.get("tipFileLocked",{name:"Common.Translation", default: "Document is locked for editing. You can make changes and save it as local copy later."}), + text: get_locked_message(locktype), showLink: false, })).on('closeclick', function () { this.close(); }).show(); } } + }); + Common.NotificationCenter.on('app:face', function (mode) { + features.viewmode = !mode.isEdit; + features.crypted = mode.isCrypted; native.execCommand('webapps:features', JSON.stringify(features)); titlebuttons = {}; if ( mode.isEdit ) { + const header = webapp.getController('Viewport').getView('Common.Views.Header'); if (!!header.btnSave) { titlebuttons['save'] = {btn: header.btnSave}; diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index a6a6a1b61..0ac753dda 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -128,6 +128,7 @@ "Common.Translation.textMoreButton": "More", "Common.Translation.warnFileLocked": "You can't edit this file because it's being edited in another app.", "Common.Translation.tipFileLocked": "Document is locked for editing. You can make changes and save it as local copy later.", + "Common.Translation.tipFileReadOnly": "Document is read only and locked for editing. You can make changes and save its local copy later.", "Common.Translation.warnFileLockedBtnEdit": "Create a copy", "Common.Translation.warnFileLockedBtnView": "Open for viewing", "Common.UI.ButtonColored.textAutoColor": "Automatic", diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 52910b371..596a8be5b 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -252,6 +252,8 @@ "Common.Translation.warnFileLocked": "The file is being edited in another app. You can continue editing and save it as a copy.", "Common.Translation.warnFileLockedBtnEdit": "Create a copy", "Common.Translation.warnFileLockedBtnView": "Open for viewing", + "Common.Translation.tipFileLocked": "Document is locked for editing. You can make changes and save it as local copy later.", + "Common.Translation.tipFileReadOnly": "Document is read only and locked for editing. You can make changes and save its local copy later.", "Common.UI.ButtonColored.textAutoColor": "Automatic", "Common.UI.ButtonColored.textNewColor": "Add New Custom Color", "Common.UI.ComboBorderSize.txtNoBorders": "No borders", diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 6b297ba29..5ef00dc4f 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -104,6 +104,8 @@ "Common.Translation.warnFileLocked": "The file is being edited in another app. You can continue editing and save it as a copy.", "Common.Translation.warnFileLockedBtnEdit": "Create a copy", "Common.Translation.warnFileLockedBtnView": "Open for viewing", + "Common.Translation.tipFileLocked": "Document is locked for editing. You can make changes and save it as local copy later.", + "Common.Translation.tipFileReadOnly": "Document is read only and locked for editing. You can make changes and save its local copy later.", "Common.UI.ButtonColored.textAutoColor": "Automatic", "Common.UI.ButtonColored.textNewColor": "Add New Custom Color", "Common.UI.ComboBorderSize.txtNoBorders": "No borders",