From 976ded1cb61474790d7d5376a4df4acc71813e5a Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 3 Jul 2023 15:18:05 +0300 Subject: [PATCH] [DE mobile] Correct force edit mode --- apps/common/mobile/lib/controller/Themes.jsx | 11 ----------- apps/documenteditor/mobile/src/controller/Main.jsx | 7 ++++++- apps/documenteditor/mobile/src/controller/Toolbar.jsx | 2 +- .../src/controller/settings/ApplicationSettings.jsx | 5 +++-- .../src/controller/settings/DocumentProtection.jsx | 2 +- apps/documenteditor/mobile/src/page/main.jsx | 2 +- apps/documenteditor/mobile/src/store/appOptions.js | 5 +++-- 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/apps/common/mobile/lib/controller/Themes.jsx b/apps/common/mobile/lib/controller/Themes.jsx index 782d366a1b..abc65cd7a3 100644 --- a/apps/common/mobile/lib/controller/Themes.jsx +++ b/apps/common/mobile/lib/controller/Themes.jsx @@ -70,29 +70,18 @@ class ThemesController extends React.Component { this.checkSystemDarkTheme = this.checkSystemDarkTheme.bind(this); } - turnOffViewerMode() { - const appOptions = this.props.storeAppOptions; - appOptions.changeViewerMode(false); - } - init() { const appOptions = this.props.storeAppOptions; const editorConfig = window.native?.editorConfig; - const editorType = window.editorType; const obj = LocalStorage.getItem("ui-theme"); let theme = this.themes_map.light; if(editorConfig) { - const isForceEdit = editorConfig.forceedit; const themeConfig = editorConfig.theme; const typeTheme = themeConfig ? themeConfig.type : null; const isSelectTheme = themeConfig ? themeConfig.select : null; - // if(isForceEdit && editorType === 'de') { - // this.turnOffViewerMode(); - // } - if(isSelectTheme) { if(!!obj) { theme = this.setClientTheme(theme, obj); diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 2723c53158..e142f4608f 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -220,12 +220,17 @@ class MainController extends Component { this.applyMode(storeAppOptions); + const appOptions = this.props.storeAppOptions; + const editorConfig = window.native?.editorConfig; + const isForceEdit = editorConfig?.forceedit; const storeDocumentInfo = this.props.storeDocumentInfo; const dataDoc = storeDocumentInfo.dataDoc; const isExtRestriction = dataDoc.fileType !== 'oform'; - if(isExtRestriction) { + if(isExtRestriction && !isForceEdit) { this.api.asc_addRestriction(Asc.c_oAscRestrictionType.View); + } else if(isExtRestriction && isForceEdit) { + appOptions.changeViewerMode(false); } else { this.api.asc_addRestriction(Asc.c_oAscRestrictionType.OnlyForms) } diff --git a/apps/documenteditor/mobile/src/controller/Toolbar.jsx b/apps/documenteditor/mobile/src/controller/Toolbar.jsx index d10b2bac14..ba6efde245 100644 --- a/apps/documenteditor/mobile/src/controller/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/controller/Toolbar.jsx @@ -191,7 +191,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto f7.popover.close('.document-menu.modal-in', false); - appOptions.changeViewerMode(); + appOptions.changeViewerMode(true); api.asc_addRestriction(Asc.c_oAscRestrictionType.View); } diff --git a/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx b/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx index 99679ece2e..9497094203 100644 --- a/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx @@ -140,8 +140,9 @@ class ApplicationSettingsController extends Component { LocalStorage.setItem("ui-theme", JSON.stringify(theme)); appOptions.setColorTheme(theme); - } else if(this.checkSystemDarkTheme()) { - theme = themesMap.dark; + } else { + const isSystemDarkTheme = this.checkSystemDarkTheme(); + if(isSystemDarkTheme) theme = themesMap.dark; LocalStorage.setItem("ui-theme", JSON.stringify(themesMap["system"])); appOptions.setColorTheme(themesMap["system"]); diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx index 2fd08ed41d..227349a248 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx @@ -28,7 +28,7 @@ class ProtectionDocumentController extends React.Component { appOptions.setTypeProtection(typeProtection); if(typeProtection !== Asc.c_oAscEDocProtect.TrackedChanges && !isViewer) { - appOptions.changeViewerMode(); + appOptions.changeViewerMode(true); } protection.asc_setEditType(typeProtection); diff --git a/apps/documenteditor/mobile/src/page/main.jsx b/apps/documenteditor/mobile/src/page/main.jsx index d78a72f2e8..ea6a28c1e9 100644 --- a/apps/documenteditor/mobile/src/page/main.jsx +++ b/apps/documenteditor/mobile/src/page/main.jsx @@ -116,7 +116,7 @@ class MainPage extends Component { f7.popover.close('.document-menu.modal-in', false); f7.navbar.show('.main-navbar', false); - appOptions.changeViewerMode(); + appOptions.changeViewerMode(false); api.asc_removeRestriction(Asc.c_oAscRestrictionType.View) api.asc_addRestriction(Asc.c_oAscRestrictionType.None); }; diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index f61980bd1f..207c5f6a38 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -62,6 +62,7 @@ export class storeAppOptions { type: 'system' } }; + isEdit = false; isConfigSelectTheme = true; @@ -96,8 +97,8 @@ export class storeAppOptions { isViewer = true; - changeViewerMode() { - this.isViewer = !this.isViewer; + changeViewerMode(value) { + this.isViewer = value; } canViewComments = false;