From bad734bf2d2a88a400d25400179a87b3d2757dc5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 2 Nov 2021 15:56:37 +0300 Subject: [PATCH] [SSE] Use FeaturesManager for spellcheck customization. --- .../main/app/controller/LeftMenu.js | 4 ++-- .../main/app/controller/Main.js | 22 +++++++++++-------- .../main/app/view/FileMenuPanels.js | 13 +++++++---- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 1884d5538..66842ba85 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -239,7 +239,7 @@ define([ this.leftMenu.btnComments.hide(); } - if (this.mode.isEdit) { + if (this.mode.isEdit && Common.UI.FeaturesManager.canChange('spellcheck')) { Common.UI.LayoutManager.isElementVisible('leftMenu-spellcheck') && this.leftMenu.btnSpellcheck.show(); this.leftMenu.setOptionsPanel('spellcheck', this.getApplication().getController('Spellcheck').getView('Spellcheck')); } @@ -482,7 +482,7 @@ define([ }, applySpellcheckSettings: function(menu) { - if (this.mode.isEdit && this.api) { + if (this.mode.isEdit && this.api && Common.UI.FeaturesManager.canChange('spellcheck')) { var value = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words"); this.api.asc_ignoreUppercase(value); value = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words"); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 5b2f8720b..05988936b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -858,14 +858,17 @@ define([ this.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("sse-settings-autosave")); /** coauthoring end **/ - /** spellcheck settings begin **/ - var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true); - Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase); - this.api.asc_ignoreUppercase(ignoreUppercase); - var ignoreNumbers = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words", true); - Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers); - this.api.asc_ignoreNumbers(ignoreNumbers); - /** spellcheck settings end **/ + // spellcheck + if (Common.UI.FeaturesManager.canChange('spellcheck')) { // get from local storage + /** spellcheck settings begin **/ + var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true); + Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase); + this.api.asc_ignoreUppercase(ignoreUppercase); + var ignoreNumbers = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words", true); + Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers); + this.api.asc_ignoreNumbers(ignoreNumbers); + /** spellcheck settings end **/ + } me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me)); me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me)); @@ -917,7 +920,7 @@ define([ this.formulaInput = celleditorController.getView('CellEditor').$el.find('textarea'); if (me.appOptions.isEdit) { - spellcheckController.setApi(me.api).setMode(me.appOptions); + Common.UI.FeaturesManager.canChange('spellcheck') && spellcheckController.setApi(me.api).setMode(me.appOptions); if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true me.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", me.appOptions.canForcesave); @@ -1259,6 +1262,7 @@ define([ this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout); + this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features); } this.appOptions.canUseHistory = this.appOptions.canLicense && this.editorConfig.canUseHistory && this.appOptions.canCoAuthoring && !this.appOptions.isOffline; diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 1367681ec..8d15242fe 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1491,18 +1491,18 @@ define([ template: _.template([ '', - '', + '', '', '', '', - '', + '', '', '', '', - '', + '', '', '', - '','', + '','', '', '', '', @@ -1584,6 +1584,7 @@ define([ setMode: function(mode) { this.mode = mode; + $('tr.spellcheck', this.el)[Common.UI.FeaturesManager.canChange('spellcheck') ? 'show' : 'hide'](); }, setApi: function(api) { @@ -1591,6 +1592,8 @@ define([ }, updateSettings: function() { + if (!Common.UI.FeaturesManager.canChange('spellcheck')) return; + var arrLang = SSE.getController('Spellcheck').loadLanguages(), allLangs = arrLang[0], langs = arrLang[1], @@ -1627,6 +1630,8 @@ define([ }, applySettings: function() { + if (!Common.UI.FeaturesManager.canChange('spellcheck')) return; + var value = this.chIgnoreUppercase.isChecked(); Common.localStorage.setBool("sse-spellcheck-ignore-uppercase-words", value); Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", value);