[SSE] Sheet protection

This commit is contained in:
Julia Radzhabova 2021-07-17 00:49:36 +03:00
parent 2e9391d907
commit 304af6ae6e
6 changed files with 64 additions and 44 deletions

View file

@ -148,6 +148,7 @@ define([
});
Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this));
Common.NotificationCenter.on('formula:settings', _.bind(this.applyFormulaSettings, this));
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
this.editMode = true;
this._isAddingShape = false;
@ -196,7 +197,7 @@ define([
cf_locked: [],
selectedCells: 0,
wsLock: false,
wsProps: {}
wsProps: []
};
this.binding = {};
@ -1820,7 +1821,6 @@ define([
this.api.asc_registerCallback('asc_onUpdateDocumentProps', _.bind(this.onUpdateDocumentProps, this));
this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this));
this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this));
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
}
if ( !this.appConfig.isEditMailMerge ) {
@ -2837,13 +2837,13 @@ define([
}
val = filterInfo && filterInfo.asc_getIsApplyAutoFilter();
if ( this._state.controlsdisabled.cells_right!==(this._state.controlsdisabled.rows || val) ) {
this._state.controlsdisabled.cells_right = (this._state.controlsdisabled.rows || val);
if ( this._state.controlsdisabled.cells_right!==(this._state.controlsdisabled.rows || val || this._state.wsLock) ) {
this._state.controlsdisabled.cells_right = (this._state.controlsdisabled.rows || val || this._state.wsLock);
toolbar.btnAddCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right);
toolbar.btnDeleteCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right);
}
if ( this._state.controlsdisabled.cells_down!==(this._state.controlsdisabled.cols || val) ) {
this._state.controlsdisabled.cells_down = (this._state.controlsdisabled.cols || val);
if ( this._state.controlsdisabled.cells_down!==(this._state.controlsdisabled.cols || val || this._state.wsLock) ) {
this._state.controlsdisabled.cells_down = (this._state.controlsdisabled.cols || val || this._state.wsLock);
toolbar.btnAddCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down);
toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down);
}
@ -3992,9 +3992,14 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onChangeProtectSheet: function(props) {
onChangeProtectSheet: function(props, state) {
this._state.wsProps = props;
this._state.wsLock = state;
if (this._state.activated) {
this.toolbar.lockToolbar(SSE.enumLock.wsLock, state);
this.onApiSelectionChanged(this.api.asc_getCellInfo());
}
},
textEmptyImgUrl : 'You need to specify image URL.',

View file

@ -94,6 +94,7 @@ define([
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
}
Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this));
},
setMode: function(mode) {
@ -270,6 +271,7 @@ define([
})).then(function () {
me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true);
me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet
me.onChangeProtectSheet();
});
},
@ -278,19 +280,24 @@ define([
},
onChangeProtectSheet: function() {
var wsProtected = this.api.asc_isProtectedSheet();
var wsProtected = !!this.api.asc_isProtectedSheet();
if (this._state.wsLock===wsProtected && !wsProtected) return;
this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet
var arr = [];
if (wsProtected) {
arr = [];
var props = this.api.asc_getProtectedSheet();
props && this.wsLockOptions.forEach(function(item){
arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false;
});
} else {
this.wsLockOptions.forEach(function(item){
arr[item] = false;
});
}
this._state.wsLock = wsProtected;
Common.NotificationCenter.trigger('protect:wslock', arr);
Common.NotificationCenter.trigger('protect:wslock', arr, this._state.wsLock);
},
onApiSheetChanged: function() {
@ -308,6 +315,10 @@ define([
onCoAuthoringDisconnect: function() {
this.SetDisabled(true);
},
onDocumentReady: function() {
// this.onChangeProtectSheet();
}
}, SSE.Controllers.WBProtection || {}));

View file

@ -130,7 +130,7 @@ define([
caption: this.capDataFromText,
menu: !this.toolbar.mode.isDesktopApp,
disabled: true,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth, _set.wsLock]
});
this.lockedControls.push(this.btnDataFromText);
@ -142,7 +142,7 @@ define([
split: true,
menu: true,
disabled: true,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth, _set.wsLock]
});
this.lockedControls.push(this.btnGroup);
@ -154,7 +154,7 @@ define([
split: true,
menu: true,
disabled: true,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth, _set.wsLock]
});
this.lockedControls.push(this.btnUngroup);
@ -165,7 +165,7 @@ define([
caption: this.capBtnTextToCol,
split: false,
disabled: true,
lock: [_set.multiselect, _set.multiselectCols, _set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth]
lock: [_set.multiselect, _set.multiselectCols, _set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.wsLock]
});
this.lockedControls.push(this.btnTextToColumns);
@ -195,7 +195,7 @@ define([
iconCls: 'toolbar__icon btn-remove-duplicates',
caption: this.capBtnTextRemDuplicates,
disabled: true,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock, _set.wsLock]
});
this.lockedControls.push(this.btnRemoveDuplicates);
@ -205,7 +205,7 @@ define([
iconCls: 'toolbar__icon btn-data-validation',
caption: this.capBtnTextDataValidation,
disabled: true,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock, _set.wsLock]
});
this.lockedControls.push(this.btnDataValidation);
@ -226,11 +226,11 @@ define([
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort]);
this.btnsSetAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-setfilter'), '', 'toolbar__icon btn-autofilter', '',
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.tableHasSlicer],
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.tableHasSlicer, _set.wsLock],
false, false, true);
this.btnsClearAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-clear-filter'), '', 'toolbar__icon btn-clear-filter', '',
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter]);
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.wsLock]);
Array.prototype.push.apply(this.lockedControls, this.btnsSortDown.concat(this.btnsSortUp, this.btnsSetAutofilter,this.btnsClearAutofilter));

View file

@ -260,7 +260,7 @@ define([
hint: this.toolbar.txtNamedRange,
split: false,
disabled: true,
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit],
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit, _set.wsLock],
menu: new Common.UI.Menu({
items: [
{

View file

@ -161,25 +161,25 @@ define([
this.chRowHeader = new Common.UI.CheckBox({
labelText: this.textRowHeader,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']]
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']]
});
this.lockedControls.push(this.chRowHeader);
this.chColHeader = new Common.UI.CheckBox({
labelText: this.textColHeader,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']]
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']]
});
this.lockedControls.push(this.chColHeader);
this.chRowBanded = new Common.UI.CheckBox({
labelText: this.textRowBanded,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']]
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']]
});
this.lockedControls.push(this.chRowBanded);
this.chColBanded = new Common.UI.CheckBox({
labelText: this.textColBanded,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']]
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']]
});
this.lockedControls.push(this.chColBanded);
@ -188,7 +188,7 @@ define([
iconCls : 'toolbar__icon btn-pivot-layout',
caption : this.capLayout,
disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock],
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock],
menu : true
});
this.lockedControls.push(this.btnPivotLayout);
@ -198,7 +198,7 @@ define([
iconCls : 'toolbar__icon btn-blank-rows',
caption : this.capBlankRows,
disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock],
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock],
menu : true
});
this.lockedControls.push(this.btnPivotBlankRows);
@ -208,7 +208,7 @@ define([
iconCls : 'toolbar__icon btn-subtotals',
caption : this.capSubtotals,
disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock],
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock],
menu : true
});
this.lockedControls.push(this.btnPivotSubtotals);
@ -218,7 +218,7 @@ define([
iconCls : 'toolbar__icon btn-grand-totals',
caption : this.capGrandTotals,
disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock],
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock],
menu : true
});
this.lockedControls.push(this.btnPivotGrandTotals);
@ -228,7 +228,7 @@ define([
iconCls: 'toolbar__icon btn-update',
caption: this.txtRefresh,
disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock]
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock]
});
this.lockedControls.push(this.btnRefreshPivot);
@ -236,7 +236,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-select-pivot',
caption: this.txtSelect,
lock: [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit]
lock: [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set['PivotTables']]
});
this.lockedControls.push(this.btnSelectPivot);
@ -246,7 +246,7 @@ define([
itemWidth : 61,
itemHeight : 49,
menuMaxHeight : 300,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']],
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']],
beforeOpenHandler: function(e) {
var cmp = this,
menu = cmp.openButton.menu;

View file

@ -716,7 +716,7 @@ define([
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-inserthyperlink',
caption : me.capInsertHyperlink,
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot, _set.wsLock]
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot]
});
me.btnInsertChart = new Common.UI.Button({
@ -785,7 +785,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-symbol',
caption: me.capBtnInsSymbol,
lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLock]
lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect]
});
me.btnInsertSlicer = new Common.UI.Button({
@ -793,14 +793,14 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-slicer',
caption: me.capBtnInsSlicer,
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.multiselect, _set.noSlicerSource]
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.multiselect, _set.noSlicerSource, _set.wsLock]
});
me.btnTableTemplate = new Common.UI.Button({
id : 'id-toolbar-btn-ttempl',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-table',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set['FormatCells']],
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.wsLock, _set['FormatCells']],
menu : new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-toolbar-menu-table-templates" style="width: 494px; height: 300px; margin: 0px 4px;"></div>') }
@ -813,7 +813,7 @@ define([
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-inserttable',
caption : me.capInsertTable,
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set['FormatCells']]
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set.wsLock, _set['FormatCells']]
});
me.listStyles = new Common.UI.ComboDataView({
@ -964,7 +964,7 @@ define([
id : 'id-toolbar-btn-insertrange',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-named-range',
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit],
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit, _set.wsLock],
menu : new Common.UI.Menu({
style : 'min-width: 110px',
items : [
@ -1040,11 +1040,13 @@ define([
items : [
{
caption : me.textInsRight,
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftRight
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftRight,
lock : [_set.wsLock]
},
{
caption : me.textInsDown,
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftDown
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftDown,
lock : [_set.wsLock]
},
{
caption : me.textEntireRow,
@ -1067,11 +1069,13 @@ define([
items : [
{
caption : me.textDelLeft,
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftLeft
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftLeft,
lock : [_set.wsLock]
},
{
caption : me.textDelUp,
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftTop
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftTop,
lock : [_set.wsLock]
},
{
caption : me.textEntireRow,
@ -1429,7 +1433,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-img-align',
caption: me.capImgAlign,
lock : [_set.selRange, _set.selRangeEdit, _set.cantGroup, _set.lostConnect, _set.coAuth, _set.coAuthText],
lock : [_set.selRange, _set.selRangeEdit, _set.cantGroup, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]],
menu: true
});
@ -1437,7 +1441,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-img-group',
caption: me.capImgGroup,
lock : [_set.selRange, _set.selRangeEdit, _set.cantGroupUngroup, _set.lostConnect, _set.coAuth, _set.coAuthText],
lock : [_set.selRange, _set.selRangeEdit, _set.cantGroupUngroup, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]],
menu: true
});
me.btnImgForward = new Common.UI.Button({
@ -1445,14 +1449,14 @@ define([
iconCls: 'toolbar__icon btn-img-frwd',
caption: me.capImgForward,
split: true,
lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText],
lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]],
menu: true
});
me.btnImgBackward = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-img-bkwd',
caption: me.capImgBackward,
lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText],
lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]],
split: true,
menu: true
});