[SSE] Fix getting protection options

This commit is contained in:
Julia Radzhabova 2021-08-12 01:42:14 +03:00
parent c1a400019c
commit eb93f3562a

View file

@ -91,7 +91,7 @@ define([
this.api = api; this.api = api;
this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this));
this.api.asc_registerCallback('asc_onChangeProtectWorksheet',_.bind(this.onChangeProtectSheet, this)); this.api.asc_registerCallback('asc_onChangeProtectWorksheet',_.bind(this.onChangeProtectSheet, this));
this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this));
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
} }
@ -290,7 +290,7 @@ define([
}, },
onChangeProtectSheet: function() { onChangeProtectSheet: function() {
var props = this.getWSProps(); var props = this.getWSProps(true);
this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet
Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [this.view.chLockedText, this.view.chLockedShape]}); Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [this.view.chLockedText, this.view.chLockedShape]});
@ -298,26 +298,29 @@ define([
Common.NotificationCenter.trigger('protect:wslock', props); Common.NotificationCenter.trigger('protect:wslock', props);
}, },
onApiSheetChanged: function() { onActiveSheetChanged: function() {
this.onChangeProtectSheet(); //current sheet this.onChangeProtectSheet(); //current sheet
}, },
getWSProps: function() { getWSProps: function(update) {
var wsProtected = !!this.api.asc_isProtectedSheet(); if (update || !this._state.protection) {
var arr = []; var wsProtected = !!this.api.asc_isProtectedSheet();
if (wsProtected) { var arr = [];
arr = []; if (wsProtected) {
var props = this.api.asc_getProtectedSheet(); arr = [];
props && this.wsLockOptions.forEach(function(item){ var props = this.api.asc_getProtectedSheet();
arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; props && this.wsLockOptions.forEach(function(item){
}); arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false;
} else { });
this.wsLockOptions.forEach(function(item){ } else {
arr[item] = false; this.wsLockOptions.forEach(function(item){
}); arr[item] = false;
});
}
this._state.protection = {wsLock: wsProtected, wsProps: arr};
} }
return {wsLock: wsProtected, wsProps: arr}; return this._state.protection;
}, },
onApiSelectionChanged: function(info) { onApiSelectionChanged: function(info) {