From b825310d3022319a40820dbc43c18d325f338328 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 16 Nov 2022 19:04:46 +0300 Subject: [PATCH] [desktop] changed "read only" file opening --- apps/common/main/lib/controller/Desktop.js | 31 ++++++++++++++++++---- apps/common/main/lib/view/Header.js | 9 ++++++- apps/documenteditor/main/locale/en.json | 2 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index b65cd547d..16eaef266 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -234,21 +234,42 @@ 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(); - } + // var maincontroller = webapp.getController('Main'); + // if (maincontroller.api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== maincontroller.api.asc_getLocalRestrictions()) { + // maincontroller.warningDocumentIsLocked(); + // } } }); 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 api = webapp.getController('Main').api; + if ( api.asc_getLocalRestrictions && Asc.c_oAscLocalRestrictionType.None !== api.asc_getLocalRestrictions()) { + features.readonly = true; + + header.setDocumentReadOnly(true); + api.asc_setLocalRestrictions(Asc.c_oAscLocalRestrictionType.None); + + (new Common.UI.SynchronizeTip({ + 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."}), + showLink: false, + })).on('closeclick', function () { + this.close(); + }).show(); + } + } + native.execCommand('webapps:features', JSON.stringify(features)); titlebuttons = {}; if ( mode.isEdit ) { - var header = webapp.getController('Viewport').getView('Common.Views.Header'); if (!!header.btnSave) { titlebuttons['save'] = {btn: header.btnSave}; diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 554490f7a..3fe69ad61 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -709,6 +709,7 @@ define([ if (idx>0) this.fileExtention = this.documentCaption.substring(idx); this.isModified && (value += '*'); + this.readOnly && (value += ' (' + this.textReadOnly + ')'); if ( $labelDocName ) { this.setDocTitle( value ); } @@ -901,6 +902,11 @@ define([ return initials; }, + setDocumentReadOnly: function (readonly) { + this.readOnly = readonly; + this.setDocumentCaption(this.documentCaption); + }, + textBack: 'Go to Documents', txtRename: 'Rename', txtAccessRights: 'Change access rights', @@ -925,7 +931,8 @@ define([ textHideNotes: 'Hide Notes', tipSearch: 'Search', textShare: 'Share', - tipPrintQuick: 'Quick print' + tipPrintQuick: 'Quick print', + textReadOnly: 'Read only' } }(), Common.Views.Header || {})) }); diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 137221899..27356e349 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -127,6 +127,7 @@ "Common.define.chartData.textSurface": "Surface", "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.warnFileLockedBtnEdit": "Create a copy", "Common.Translation.warnFileLockedBtnView": "Open for viewing", "Common.UI.ButtonColored.textAutoColor": "Automatic", @@ -320,6 +321,7 @@ "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", "Common.Views.Header.tipPrintQuick": "Quick print", + "Common.Views.Header.textReadOnly": "Read only", "Common.Views.History.textCloseHistory": "Close History", "Common.Views.History.textHide": "Collapse", "Common.Views.History.textHideAll": "Hide detailed changes",