From 1f49644924b88281062d9cf8a9ff949ad168f273 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 10 Jul 2020 16:19:07 +0300 Subject: [PATCH] [SSE] Lock view settings --- apps/common/main/lib/view/Header.js | 6 ++++-- .../main/app/controller/Toolbar.js | 2 +- .../main/app/controller/ViewTab.js | 16 ++++++++-------- .../main/app/controller/Viewport.js | 19 +++++++++++++++++++ .../main/app/view/ViewTab.js | 6 +++--- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 974274901..2c83638d6 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -719,9 +719,11 @@ define([ fakeMenuItem: function() { return { - conf: {checked: false}, + conf: {checked: false, disabled: false}, setChecked: function (val) { this.conf.checked = val; }, - isChecked: function () { return this.conf.checked; } + isChecked: function () { return this.conf.checked; }, + setDisabled: function (val) { this.conf.disabled = val; }, + isDisabled: function () { return this.conf.disabled; } }; }, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 848d9085b..256bc6d85 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -3307,7 +3307,7 @@ define([ var viewtab = me.getApplication().getController('ViewTab'); viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); - + Array.prototype.push.apply(me.toolbar.lockControls, viewtab.getView('ViewTab').getButtons()); } } }, diff --git a/apps/spreadsheeteditor/main/app/controller/ViewTab.js b/apps/spreadsheeteditor/main/app/controller/ViewTab.js index 9b901fdf3..168bec832 100644 --- a/apps/spreadsheeteditor/main/app/controller/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/controller/ViewTab.js @@ -65,7 +65,7 @@ define([ this.api = api; this.api.asc_registerCallback('asc_onZoomChanged', this.onApiZoomChange.bind(this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); - // this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this)); + this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this)); this.api.asc_registerCallback('asc_onSheetsChanged', this.onApiSheetChanged.bind(this)); this.api.asc_registerCallback('asc_onUpdateSheetViewSettings', this.onApiSheetChanged.bind(this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); @@ -185,11 +185,11 @@ define([ }).show(); }, - // onWorksheetLocked: function(index,locked) { - // if (index == this.api.asc_getActiveWorksheetIndex()) { - // Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)}); - // } - // }, + onWorksheetLocked: function(index,locked) { + if (index == this.api.asc_getActiveWorksheetIndex()) { + Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: [this.view.chHeadings, this.view.chGridlines, this.view.btnFreezePanes]}); + } + }, onApiSheetChanged: function() { if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; @@ -199,8 +199,8 @@ define([ this.view.chGridlines.setValue(!!params.asc_getShowGridLines(), true); this.view.btnFreezePanes.toggle(!!params.asc_getIsFreezePane(), true); - // var currentSheet = this.api.asc_getActiveWorksheetIndex(); - // this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); + var currentSheet = this.api.asc_getActiveWorksheetIndex(); + this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); }, onLayoutChanged: function(area) { diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index d9bbf598a..dd757f0e5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -125,6 +125,7 @@ define([ this.api.asc_registerCallback('asc_onZoomChanged', this.onApiZoomChange.bind(this)); this.api.asc_registerCallback('asc_onSheetsChanged', this.onApiSheetChanged.bind(this)); this.api.asc_registerCallback('asc_onUpdateSheetViewSettings', this.onApiSheetChanged.bind(this)); + this.api.asc_registerCallback('asc_onWorksheetLocked', this.onWorksheetLocked.bind(this)); this.api.asc_registerCallback('asc_onEditCell', this.onApiEditCell.bind(this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',this.onApiCoAuthoringDisconnect.bind(this)); Common.NotificationCenter.on('api:disconnect', this.onApiCoAuthoringDisconnect.bind(this)); @@ -218,6 +219,7 @@ define([ caption : me.textHideHeadings, checkable : true, checked : me.header.mnuitemHideHeadings.isChecked(), + disabled : me.header.mnuitemHideHeadings.isDisabled(), value : 'headings' }); @@ -225,6 +227,7 @@ define([ caption : me.textHideGridlines, checkable : true, checked : me.header.mnuitemHideGridlines.isChecked(), + disabled : me.header.mnuitemHideGridlines.isDisabled(), value : 'gridlines' }); @@ -232,6 +235,7 @@ define([ caption : me.textFreezePanes, checkable : true, checked : me.header.mnuitemFreezePanes.isChecked(), + disabled : me.header.mnuitemFreezePanes.isDisabled(), value : 'freezepanes' }); @@ -434,6 +438,21 @@ define([ me.header.mnuitemHideHeadings.setChecked(!params.asc_getShowRowColHeaders()); me.header.mnuitemHideGridlines.setChecked(!params.asc_getShowGridLines()); me.header.mnuitemFreezePanes.setChecked(params.asc_getIsFreezePane()); + + var currentSheet = me.api.asc_getActiveWorksheetIndex(); + this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); + } + }, + + onWorksheetLocked: function(index,locked) { + var me = this; + var appConfig = me.viewport.mode; + if ( !!appConfig && !appConfig.isEditDiagram && !appConfig.isEditMailMerge ) { + if (index == this.api.asc_getActiveWorksheetIndex()) { + me.header.mnuitemHideHeadings.setDisabled(locked); + me.header.mnuitemHideGridlines.setDisabled(locked); + me.header.mnuitemFreezePanes.setDisabled(locked); + } } }, diff --git a/apps/spreadsheeteditor/main/app/view/ViewTab.js b/apps/spreadsheeteditor/main/app/view/ViewTab.js index cb94ebea8..5ff557af0 100644 --- a/apps/spreadsheeteditor/main/app/view/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/view/ViewTab.js @@ -127,7 +127,7 @@ define([ caption: this.capBtnFreeze, split: false, enableToggle: true, - lock: [_set.lostConnect, _set.coAuth] + lock: [_set.sheetLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.btnFreezePanes); @@ -161,14 +161,14 @@ define([ this.chHeadings = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-heading'), labelText: this.textHeadings, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.sheetLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chHeadings); this.chGridlines = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-gridlines'), labelText: this.textGridlines, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.sheetLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chGridlines);