[SSE] Fix view and commenting mode. Fix Bug 52384

This commit is contained in:
Julia Radzhabova 2021-09-07 02:02:15 +03:00
parent f06b098bb0
commit 3688ccec24
6 changed files with 34 additions and 18 deletions

View file

@ -1017,7 +1017,7 @@ define([
var wbprotect = this.getApplication().getController('WBProtection');
props = wbprotect ? wbprotect.getWSProps() : null;
}
this._state.wsProps = props ? props.wsProps : {};
this._state.wsProps = props ? props.wsProps : [];
this._state.wsLock = props ? props.wsLock : false;
if (!this.view) return;

View file

@ -116,7 +116,7 @@ define([
me._currentMathObj = undefined;
me._currentParaObjDisabled = false;
me._isDisabled = false;
me._state = {};
me._state = {wsLock: false, wsProps: []};
me.fastcoauthtips = [];
me._TtHeight = 20;
/** coauthoring begin **/

View file

@ -1389,11 +1389,13 @@ define([
Common.Utils.Metric.setCurrentMetric(value);
Common.Utils.InternalSettings.set("sse-settings-unit", value);
if (this.appOptions.isEdit || this.appOptions.isRestrictedEdit) { // set api events for toolbar in the Restricted Editing mode
if (this.appOptions.isRestrictedEdit) {
var toolbarController = application.getController('Toolbar');
toolbarController && toolbarController.setApi(me.api);
application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
} else if (this.appOptions.isEdit) { // set api events for toolbar in the Restricted Editing mode
var toolbarController = application.getController('Toolbar');
toolbarController && toolbarController.setApi(me.api);
if (!this.appOptions.isEdit) return;
var statusbarController = application.getController('Statusbar'),
rightmenuController = application.getController('RightMenu'),

View file

@ -54,7 +54,7 @@ define([
initialize: function() {
this.editMode = true;
this._state = {};
this._state = {wsLock: false, wsProps: []};
this.addListeners({
'Toolbar': {
@ -456,8 +456,10 @@ define([
var wbprotect = this.getApplication().getController('WBProtection');
props = wbprotect ? wbprotect.getWSProps() : null;
}
this._state.wsProps = props.wsProps;
this._state.wsLock = props.wsLock;
if (props) {
this._state.wsProps = props.wsProps;
this._state.wsLock = props.wsLock;
}
this.onSelectionChanged(this.api.asc_getCellInfo());
}
});

View file

@ -426,9 +426,10 @@ define([
this.api.asc_registerCallback('asc_onUnLockCFManager', _.bind(this.onUnLockCFManager, this));
this.api.asc_registerCallback('asc_onZoomChanged', _.bind(this.onApiZoomChange, this));
Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this));
} else if (config.isRestrictedEdit)
} else if (config.isRestrictedEdit) {
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChangedRestricted, this));
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
}
},
// onNewDocument: function(btn, e) {
@ -2913,10 +2914,13 @@ define([
},
onApiSelectionChangedRestricted: function(info) {
if (!this.appConfig.isRestrictedEdit) return;
var selectionType = info.asc_getSelectionType();
this.toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (!info.asc_getComments() || info.asc_getComments().length>0 || info.asc_getLocked()) ||
this.appConfig && this.appConfig.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells),
{ array: this.btnsComment });
this.toolbar.lockToolbar(SSE.enumLock['Objects'], !!this._state.wsProps['Objects'], { array: this.btnsComment });
},
onApiSelectionChanged_DiagramEditor: function(info) {
@ -4065,7 +4069,7 @@ define([
this.toolbar.lockToolbar(SSE.enumLock.wsLock, this._state.wsLock);
this.toolbar.lockToolbar(SSE.enumLock['InsertHyperlinks'], this._state.wsProps['InsertHyperlinks'], {array: [this.toolbar.btnInsertHyperlink]});
this.onApiSelectionChanged(this.api.asc_getCellInfo());
this.appConfig && this.appConfig.isEdit ? this.onApiSelectionChanged(this.api.asc_getCellInfo()) : this.onApiSelectionChangedRestricted(this.api.asc_getCellInfo());
}
},

View file

@ -98,15 +98,16 @@ define([
setMode: function(mode) {
this.appConfig = mode;
this.view = this.createView('WBProtection', {
this.appConfig.isEdit && (this.view = this.createView('WBProtection', {
mode: mode
});
}));
return this;
},
createToolbarPanel: function() {
return this.view.getPanel();
if (this.view)
return this.view.getPanel();
},
getView: function(name) {
@ -270,6 +271,8 @@ define([
},
onAppReady: function (config) {
if (!this.view) return;
var me = this;
(new Promise(function (resolve) {
resolve();
@ -284,15 +287,17 @@ define([
},
onChangeProtectWorkbook: function() {
this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true);
this.view && this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true);
},
onChangeProtectSheet: function() {
var props = this.getWSProps(true);
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.wsLock, props.wsLock, { array: [this.view.btnAllowRanges]});
if (this.view) {
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.wsLock, props.wsLock, { array: [this.view.btnAllowRanges]});
}
Common.NotificationCenter.trigger('protect:wslock', props);
},
@ -301,6 +306,8 @@ define([
},
getWSProps: function(update) {
if (!this.appConfig || !this.appConfig.isEdit && !this.appConfig.isRestrictedEdit) return;
if (update || !this._state.protection) {
var wsProtected = !!this.api.asc_isProtectedSheet();
var arr = [];
@ -322,6 +329,7 @@ define([
},
onApiSelectionChanged: function(info) {
if (!this.view) return;
if ($('.asc-window.enable-key-events:visible').length>0) return;
var selectionType = info.asc_getSelectionType();