From be8bc7dd42ba72fb9c6705b35b312abdf92743c9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 22 Jul 2021 22:56:15 +0300 Subject: [PATCH 1/2] Move api parameters showReviewChanges, reviewDisplay, trackChanges to section customization.review --- apps/api/documents/api.js | 11 +++++++---- .../main/lib/controller/ReviewChanges.js | 14 ++++++++++---- .../lib/controller/collaboration/Review.jsx | 18 ++++++++++++++---- .../documenteditor/main/app/controller/Main.js | 9 +++++++++ .../main/app/controller/Statusbar.js | 4 +++- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 2aa7ad002..6154a0c5e 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -136,7 +136,10 @@ label: string (default: "Guest") // postfix for user name }, review: { - hideReviewDisplay: false // hide button Review mode + hideReviewDisplay: false // hide button Review mode, + showReviewChanges: false, + reviewDisplay: 'original', + trackChanges: undefined // true/false - open editor with track changes mode on/off, }, chat: true, comments: true, @@ -150,12 +153,12 @@ autosave: true, forcesave: false, commentAuthorOnly: false, // must be deprecated. use permissions.editCommentAuthorOnly and permissions.deleteCommentAuthorOnly instead - showReviewChanges: false, + showReviewChanges: false, // must be deprecated. use customization.review.showReviewChanges instead help: true, compactHeader: false, toolbarNoTabs: false, toolbarHideFileName: false, - reviewDisplay: 'original', + reviewDisplay: 'original', // must be deprecated. use customization.review.reviewDisplay instead spellcheck: true, compatibleFeatures: false, unit: 'cm' // cm, pt, inch, @@ -163,7 +166,7 @@ macros: true // can run macros in document plugins: true // can run plugins in document macrosMode: 'warn' // warn about automatic macros, 'enable', 'disable', 'warn', - trackChanges: undefined // true/false - open editor with track changes mode on/off, + trackChanges: undefined // true/false - open editor with track changes mode on/off, // must be deprecated. use customization.review.trackChanges instead hideRulers: false // hide or show rulers on first loading (presentation or document editor) hideNotes: false // hide or show notes panel on first loading (presentation editor) uiTheme: 'theme-dark' // set interface theme: id or default-dark/default-light diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 79213e290..fafa6cdc5 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -798,7 +798,9 @@ define([ // Common.Utils.InternalSettings.set(me.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0)); // }; - var trackChanges = typeof (me.appConfig.customization) == 'object' ? me.appConfig.customization.trackChanges : undefined; + var trackChanges = me.appConfig.customization && me.appConfig.customization.review ? me.appConfig.customization.review.trackChanges : undefined; + (trackChanges===undefined) && (trackChanges = me.appConfig.customization ? me.appConfig.customization.trackChanges : undefined); + if (config.isReviewOnly || trackChanges!==undefined) me.api.asc_SetLocalTrackRevisions(config.isReviewOnly || trackChanges===true); else @@ -807,7 +809,8 @@ define([ // _setReviewStatus(state, global); - if ( typeof (me.appConfig.customization) == 'object' && (me.appConfig.customization.showReviewChanges==true) ) { + if ( typeof (me.appConfig.customization) == 'object' && (me.appConfig.customization.review && me.appConfig.customization.review.showReviewChanges==true || + (!me.appConfig.customization.review || me.appConfig.customization.review.showReviewChanges===undefined) && me.appConfig.customization.showReviewChanges==true) ) { me.dlgChanges = (new Common.Views.ReviewChangesDialog({ popoverChanges : me.popoverChanges, mode : me.appConfig @@ -821,8 +824,11 @@ define([ config.canViewReview = (config.isEdit || me.api.asc_HaveRevisionsChanges(true)); // check revisions from all users if (config.canViewReview) { var val = Common.localStorage.getItem(me.view.appPrefix + "review-mode"); - if (val===null) - val = me.appConfig.customization && /^(original|final|markup)$/i.test(me.appConfig.customization.reviewDisplay) ? me.appConfig.customization.reviewDisplay.toLocaleLowerCase() : 'original'; + if (val===null) { + val = me.appConfig.customization && me.appConfig.customization.review ? me.appConfig.customization.review.reviewDisplay : undefined; + !val && (val = me.appConfig.customization ? me.appConfig.customization.reviewDisplay : undefined); + val = /^(original|final|markup)$/i.test(val) ? val.toLocaleLowerCase() : 'original'; + } me.turnDisplayMode((config.isEdit || config.isRestrictedEdit) ? 'markup' : val); // load display mode only in viewer me.view.turnDisplayMode((config.isEdit || config.isRestrictedEdit) ? 'markup' : val); } diff --git a/apps/common/mobile/lib/controller/collaboration/Review.jsx b/apps/common/mobile/lib/controller/collaboration/Review.jsx index 830ab10de..4f86a6cc7 100644 --- a/apps/common/mobile/lib/controller/collaboration/Review.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Review.jsx @@ -17,15 +17,24 @@ class InitReview extends Component { Common.Notifications.on('document:ready', () => { const api = Common.EditorApi.get(); const appOptions = props.storeAppOptions; - api.asc_SetTrackRevisions(appOptions.isReviewOnly || LocalStorage.getBool("de-mobile-track-changes-" + (appOptions.fileKey || ''))); + + let trackChanges = appOptions.customization && appOptions.customization.review ? appOptions.customization.review.trackChanges : undefined; + (trackChanges===undefined) && (trackChanges = appOptions.customization ? appOptions.customization.trackChanges : undefined); + trackChanges = appOptions.isReviewOnly || trackChanges === true || trackChanges !== false + && LocalStorage.getBool(`${this.editorPrefix}-mobile-track-changes-${appOptions.fileKey || ''}`); + + api.asc_SetTrackRevisions(trackChanges); // Init display mode if (!appOptions.canReview) { const canViewReview = appOptions.isEdit || api.asc_HaveRevisionsChanges(true); appOptions.setCanViewReview(canViewReview); if (canViewReview) { let viewReviewMode = LocalStorage.getItem("de-view-review-mode"); - if (viewReviewMode === null) - viewReviewMode = appOptions.customization && /^(original|final|markup)$/i.test(appOptions.customization.reviewDisplay) ? appOptions.customization.reviewDisplay.toLocaleLowerCase() : 'original'; + if (viewReviewMode === null) { + viewReviewMode = appOptions.customization && appOptions.customization.review ? appOptions.customization.review.reviewDisplay : undefined; + !viewReviewMode && (viewReviewMode = appOptions.customization ? appOptions.customization.reviewDisplay : undefined); + viewReviewMode = /^(original|final|markup)$/i.test(viewReviewMode) ? viewReviewMode.toLocaleLowerCase() : 'original'; + } viewReviewMode = (appOptions.isEdit || appOptions.isRestrictedEdit) ? 'markup' : viewReviewMode; const displayMode = viewReviewMode.toLocaleLowerCase(); if (displayMode === 'final') { @@ -60,7 +69,8 @@ class Review extends Component { this.appConfig = props.storeAppOptions; this.editorPrefix = window.editorType || ''; - let trackChanges = typeof this.appConfig.customization == 'object' ? this.appConfig.customization.trackChanges : undefined; + let trackChanges = this.appConfig.customization && this.appConfig.customization.review ? this.appConfig.customization.review.trackChanges : undefined; + (trackChanges===undefined) && (trackChanges = this.appConfig.customization ? this.appConfig.customization.trackChanges : undefined); trackChanges = this.appConfig.isReviewOnly || trackChanges === true || trackChanges !== false && LocalStorage.getBool(`${this.editorPrefix}-mobile-track-changes-${this.appConfig.fileKey || ''}`); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 311b9b5ea..c479784f7 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1395,6 +1395,15 @@ define([ if (this.permissions.editCommentAuthorOnly===undefined && this.permissions.deleteCommentAuthorOnly===undefined) this.appOptions.canEditComments = this.appOptions.canDeleteComments = this.appOptions.isOffline; } + if (typeof (this.editorConfig.customization) == 'object') { + if (this.editorConfig.customization.showReviewChanges!==undefined) + console.log("Obsolete: The 'showReviewChanges' parameter of the 'customization' section is deprecated. Please use 'showReviewChanges' parameter in the 'customization.review' section instead."); + if (this.editorConfig.customization.reviewDisplay!==undefined) + console.log("Obsolete: The 'reviewDisplay' parameter of the 'customization' section is deprecated. Please use 'reviewDisplay' parameter in the 'customization.review' section instead."); + if (this.editorConfig.customization.trackChanges!==undefined) + console.log("Obsolete: The 'trackChanges' parameter of the 'customization' section is deprecated. Please use 'trackChanges' parameter in the 'customization.review' section instead."); + } + this.appOptions.trialMode = params.asc_getLicenseMode(); this.appOptions.isBeta = params.asc_getIsBeta(); this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport(); diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index b48ee0e7f..db122880e 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -144,7 +144,9 @@ define([ } var trackRevisions = me.api.asc_IsTrackRevisions(), - trackChanges = typeof (config.customization) == 'object' ? config.customization.trackChanges : undefined; + trackChanges = config.customization && config.customization.review ? config.customization.review.trackChanges : undefined; + (trackChanges===undefined) && (trackChanges = config.customization ? config.customization.trackChanges : undefined); + if ( config.isReviewOnly || trackChanges===true || (trackChanges!==false) && trackRevisions) { _process_changestip(); } else if ( trackRevisions ) { From 4e3d968f265709bce943e99eacb83b1024213068 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 22 Jul 2021 23:59:21 +0300 Subject: [PATCH 2/2] Refactoring --- apps/common/mobile/lib/controller/collaboration/Review.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common/mobile/lib/controller/collaboration/Review.jsx b/apps/common/mobile/lib/controller/collaboration/Review.jsx index 4f86a6cc7..a56773d84 100644 --- a/apps/common/mobile/lib/controller/collaboration/Review.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Review.jsx @@ -21,7 +21,7 @@ class InitReview extends Component { let trackChanges = appOptions.customization && appOptions.customization.review ? appOptions.customization.review.trackChanges : undefined; (trackChanges===undefined) && (trackChanges = appOptions.customization ? appOptions.customization.trackChanges : undefined); trackChanges = appOptions.isReviewOnly || trackChanges === true || trackChanges !== false - && LocalStorage.getBool(`${this.editorPrefix}-mobile-track-changes-${appOptions.fileKey || ''}`); + && LocalStorage.getBool("de-mobile-track-changes-" + (appOptions.fileKey || '')); api.asc_SetTrackRevisions(trackChanges); // Init display mode