[PE][SSE] Fix lock of save button

This commit is contained in:
Julia.Radzhabova
2025-05-06 23:24:08 +03:00
parent d0278c9dd1
commit 733f6cc80e
5 changed files with 35 additions and 46 deletions

View File

@ -686,11 +686,7 @@ define([
application.getController('DocumentHolder').getView().focus();
if (this.api && this.appOptions.isEdit && this.api.asc_isDocumentCanSave) {
var cansave = this.api.asc_isDocumentCanSave(),
forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isSyncButton = (toolbarView.btnCollabChanges.rendered) ? toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false,
isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
toolbarView.btnSave.setDisabled(isDisabled);
this.disableSaveButton(this.api.asc_isDocumentCanSave());
}
if (this.appOptions.isEdit && (toolbarView && toolbarView._isEyedropperStart || rightMenu && rightMenu._isEyedropperStart)) {
toolbarView._isEyedropperStart ? toolbarView._isEyedropperStart = false : rightMenu._isEyedropperStart = false;
@ -700,6 +696,16 @@ define([
Common.UI.HintManager.clearHints(true);
},
disableSaveButton: function (isCanSave) {
var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar');
if (!toolbarView || !toolbarView.btnSave || !this.api) return;
var forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isSyncButton = (toolbarView.btnCollabChanges && toolbarView.btnCollabChanges.rendered) ? toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false,
isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
toolbarView.lockToolbar(Common.enumLock.cantSave, isDisabled, {array: [toolbarView.btnSave]});
},
onLongActionBegin: function(type, id) {
var action = {id: id, type: type};
this.stackLongActions.push(action);
@ -1976,23 +1982,10 @@ define([
}
this.updateWindowTitle();
var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar');
if (toolbarView && toolbarView.btnCollabChanges) {
var isSyncButton = toolbarView.btnCollabChanges.cmpEl.hasClass('notify'),
forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isDisabled = !isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
toolbarView.btnSave.setDisabled(isDisabled);
}
this.disableSaveButton(isModified);
},
onDocumentCanSaveChanged: function (isCanSave) {
var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar');
if ( toolbarView ) {
var isSyncButton = toolbarView.btnCollabChanges.cmpEl.hasClass('notify'),
forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
toolbarView.btnSave.setDisabled(isDisabled);
}
this.disableSaveButton(isCanSave);
},
onContextMenu: function(event){

View File

@ -1226,7 +1226,7 @@ define([
this.api.asc_Save();
}
toolbar.btnSave.setDisabled(!toolbar.mode.forcesave && !toolbar.mode.canSaveDocumentToBinary);
toolbar.btnSave && toolbar.lockToolbar(Common.enumLock.cantSave, !toolbar.mode.forcesave && !toolbar.mode.canSaveDocumentToBinary, {array: [toolbar.btnSave]});
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('Save');

View File

@ -104,7 +104,8 @@ define([
noParagraphObject: 'no-paragraph-obj',
inSlideMaster: 'in-slide-master',
slideMasterMode: 'slide-master-mode',
cantMergeShape: 'merge-shape-lock'
cantMergeShape: 'merge-shape-lock',
cantSave: 'cant-save'
};
for (var key in enumLock) {
if (enumLock.hasOwnProperty(key)) {
@ -187,7 +188,7 @@ define([
id: 'id-toolbar-btn-save',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon no-mask ' + me.btnSaveCls,
lock: [_set.lostConnect],
lock: [_set.cantSave, _set.lostConnect],
signals: ['disabled'],
dataHint: '1',
dataHintDirection: 'top',
@ -2241,8 +2242,7 @@ define([
} else {
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}
this.btnSave.setDisabled(false);
this.lockToolbar(Common.enumLock.cantSave, false, {array: [this.btnSave]});
Common.Gateway.collaborativeChanges();
},
@ -2273,8 +2273,7 @@ define([
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnCollabChanges.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(!me.mode.forcesave && !me.mode.canSaveDocumentToBinary);
this.lockToolbar(Common.enumLock.cantSave, !me.mode.forcesave && !me.mode.canSaveDocumentToBinary, {array: [this.btnSave]});
this._state.hasCollaborativeChanges = false;
}
}

View File

@ -2422,22 +2422,20 @@ define([
this._isDocReady && Common.Gateway.setDocumentModified(change);
}
if (this.toolbarView && this.toolbarView.btnCollabChanges && this.api) {
var isSyncButton = this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify'),
forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
cansave = this.api.asc_isDocumentCanSave(),
isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
this.toolbarView.btnSave.setDisabled(isDisabled);
}
this.api && this.disableSaveButton(this.api.asc_isDocumentCanSave());
},
onDocumentCanSaveChanged: function (isCanSave) {
if (this.toolbarView && this.toolbarView.btnCollabChanges) {
var isSyncButton = this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify'),
forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
this.toolbarView.btnSave.setDisabled(isDisabled);
}
this.disableSaveButton(isCanSave)
},
disableSaveButton: function (isCanSave) {
if (!this.toolbarView || !this.toolbarView.btnCollabChanges) return;
var forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary,
isSyncButton = (this.toolbarView.btnCollabChanges.rendered) ? this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false,
isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave;
this.toolbarView.lockToolbar(Common.enumLock.cantSave, isDisabled, {array: [this.toolbarView.btnSave]});
},
onBeforeUnload: function() {

View File

@ -115,7 +115,8 @@ define([
userProtected: 'cell-user-protected',
pageBreakLock: 'page-break-lock',
fileMenuOpened: 'file-menu-opened',
cantMergeShape: 'merge-shape-lock'
cantMergeShape: 'merge-shape-lock',
cantSave: 'cant-save'
};
for (var key in enumLock) {
if (enumLock.hasOwnProperty(key)) {
@ -858,7 +859,7 @@ define([
id : 'id-toolbar-btn-save',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon no-mask ' + me.btnSaveCls,
lock : [_set.lostConnect],
lock : [_set.cantSave, _set.lostConnect],
signals : ['disabled'],
dataHint : '1',
dataHintDirection: 'top',
@ -3287,8 +3288,7 @@ define([
} else {
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}
this.btnSave.setDisabled(false);
this.lockToolbar(Common.enumLock.cantSave, false, {array: [this.btnSave]});
Common.Gateway.collaborativeChanges();
},
@ -3319,8 +3319,7 @@ define([
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnCollabChanges.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(!me.mode.forcesave && !me.mode.canSaveDocumentToBinary);
this.lockToolbar(Common.enumLock.cantSave, !me.mode.forcesave && !me.mode.canSaveDocumentToBinary, {array: [this.btnSave]});
this._state.hasCollaborativeChanges = false;
}
}