From 6a270a5e038856297ba40feba67cca32a73d96af Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 00:37:48 +0300 Subject: [PATCH] [SSE] Protect sheet from context menu --- .../main/app/controller/Statusbar.js | 7 +++++++ .../main/app/controller/WBProtection.js | 1 + .../spreadsheeteditor/main/app/view/Statusbar.js | 16 +++++++++++----- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index bd4ecc7f4..1a10b17a5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -308,6 +308,9 @@ define([ me.hideWorksheet(true, arrIndex); }, 1); break; + case 'protect': + this.protectWorksheet(); + break; } }, @@ -779,6 +782,10 @@ define([ this._sheetViewTip.hide(); }, + protectWorksheet: function() { + Common.NotificationCenter.trigger('protect:sheet', !this.api.asc_isProtectedSheet()); + }, + zoomText : 'Zoom {0}%', errorLastSheet : 'Workbook must have at least one visible worksheet.', errorRemoveSheet: 'Can\'t delete the worksheet.', diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 6ab13e791..7a6b8f69b 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -77,6 +77,7 @@ define([ Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('protect:sheet', _.bind(this.onSheetClick, this)); }, setConfig: function (data, api) { this.setApi(api); diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index a9c646173..75ade6956 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -342,6 +342,7 @@ define([ caption: this.itemHidden, menu: menuHiddenItems }, + {caption: this.itemProtect, value: 'protect'}, { caption: this.itemTabColor, menu: menuColorItems @@ -657,16 +658,19 @@ define([ this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected); - this.tabMenu.items[7].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[7].setDisabled(select.length>1); + this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected); + + this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); if (select.length === 1) { - this.tabMenu.items[10].hide(); + this.tabMenu.items[11].hide(); } else { - this.tabMenu.items[10].show(); + this.tabMenu.items[11].show(); } - this.tabMenu.items[9].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[11].setDisabled(issheetlocked || isdocprotected); this.api.asc_closeCellEditor(); this.api.asc_enableKeyEvents(false); @@ -857,7 +861,9 @@ define([ itemCount : 'Count', itemMinimum : 'Minimum', itemMaximum : 'Maximum', - itemSum : 'Sum' + itemSum : 'Sum', + itemProtect : 'Protect', + itemUnProtect : 'Unprotect' }, SSE.Views.Statusbar || {})); SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({ diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 9737392c3..3b7ec4e90 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2978,6 +2978,8 @@ "SSE.Views.Statusbar.itemRename": "Rename", "SSE.Views.Statusbar.itemSum": "Sum", "SSE.Views.Statusbar.itemTabColor": "Tab Color", + "SSE.Views.Statusbar.itemProtect": "Protect", + "SSE.Views.Statusbar.itemUnProtect": "Unprotect", "SSE.Views.Statusbar.RenameDialog.errNameExists": "Worksheet with such a name already exists.", "SSE.Views.Statusbar.RenameDialog.errNameWrongChar": "A sheet name cannot contain the following characters: \\/*?[]:", "SSE.Views.Statusbar.RenameDialog.labelSheetName": "Sheet Name",