Fix Bug 59838

This commit is contained in:
Julia Radzhabova 2022-11-22 16:58:14 +03:00
parent 2440e7d637
commit 124ee64a23
2 changed files with 22 additions and 12 deletions

View file

@ -116,12 +116,10 @@ define([
onProtectDocClick: function(state) { onProtectDocClick: function(state) {
this.view.btnProtectDoc.toggle(!state, true); this.view.btnProtectDoc.toggle(!state, true);
if (state) { if (state) {
var me = this, var me = this;
btn, me._docProtectDlg = new DE.Views.ProtectDialog({
win = new DE.Views.ProtectDialog({
props: me.appConfig, props: me.appConfig,
handler: function(result, value, props) { handler: function(result, value, props) {
btn = result;
if (result == 'ok') { if (result == 'ok') {
var protection = me.api.asc_getDocumentProtection() || new AscCommonWord.CDocProtect(); var protection = me.api.asc_getDocumentProtection() || new AscCommonWord.CDocProtect();
protection.asc_setEditType(props); protection.asc_setEditType(props);
@ -131,14 +129,12 @@ define([
Common.NotificationCenter.trigger('edit:complete'); Common.NotificationCenter.trigger('edit:complete');
} }
}).on('close', function() { }).on('close', function() {
if (btn!=='ok') me._docProtectDlg = undefined;
me.view.btnProtectDoc.toggle(false, true);
}); });
win.show(); me._docProtectDlg.show();
} else { } else {
var me = this, var me = this,
btn,
props = me.api.asc_getDocumentProtection(); props = me.api.asc_getDocumentProtection();
if (props && props.asc_getIsPassword()) { if (props && props.asc_getIsPassword()) {
var win = new Common.Views.OpenDialog({ var win = new Common.Views.OpenDialog({
@ -149,7 +145,6 @@ define([
validatePwd: false, validatePwd: false,
maxPasswordLength: 15, maxPasswordLength: 15,
handler: function (result, value) { handler: function (result, value) {
btn = result;
if (result == 'ok') { if (result == 'ok') {
if (me.api) { if (me.api) {
props.asc_setEditType(Asc.c_oAscEDocProtect.None); props.asc_setEditType(Asc.c_oAscEDocProtect.None);
@ -160,8 +155,6 @@ define([
} }
} }
}).on('close', function() { }).on('close', function() {
if (btn!=='ok')
me.view.btnProtectDoc.toggle(true, true);
}); });
win.show(); win.show();
@ -208,6 +201,8 @@ define([
} }
props && this.applyRestrictions(props.type); props && this.applyRestrictions(props.type);
if (this._docProtectDlg && this._docProtectDlg.isVisible())
this._docProtectDlg.SetDisabled(!!this._state.lockDocProtect || isProtected);
Common.NotificationCenter.trigger('protect:doclock', props); Common.NotificationCenter.trigger('protect:doclock', props);
}, },
@ -246,7 +241,11 @@ define([
}, },
onLockDocumentProtection: function(state) { onLockDocumentProtection: function(state) {
this._state.lockDocProtect = state;
this.view && Common.Utils.lockControls(Common.enumLock.protectLock, state, {array: [this.view.btnProtectDoc]}); this.view && Common.Utils.lockControls(Common.enumLock.protectLock, state, {array: [this.view.btnProtectDoc]});
if (this._docProtectDlg && this._docProtectDlg.isVisible())
this._docProtectDlg.SetDisabled(state || this._state.docProtection && (this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly ||
this._state.docProtection.isCommentsOnly || this._state.docProtection.isReviewOnly));
} }
}, DE.Controllers.DocProtection || {})); }, DE.Controllers.DocProtection || {}));

View file

@ -146,6 +146,10 @@ define([
value: Asc.c_oAscEDocProtect.Comments value: Asc.c_oAscEDocProtect.Comments
}); });
this.btnOk = new Common.UI.Button({
el: this.$window.find('.primary')
});
this.afterRender(); this.afterRender();
}, },
@ -171,8 +175,11 @@ define([
}, },
_handleInput: function(state) { _handleInput: function(state) {
if (state === 'ok' && this.btnOk.isDisabled())
return;
if (this.handler) { if (this.handler) {
if (state == 'ok') { if (state === 'ok') {
if (this.inputPwd.checkValidate() !== true) { if (this.inputPwd.checkValidate() !== true) {
this.inputPwd.focus(); this.inputPwd.focus();
return; return;
@ -208,6 +215,10 @@ define([
return Asc.c_oAscEDocProtect.Comments; return Asc.c_oAscEDocProtect.Comments;
}, },
SetDisabled: function(disabled) {
this.btnOk.setDisabled(disabled);
},
txtPassword : "Password", txtPassword : "Password",
txtRepeat: 'Repeat password', txtRepeat: 'Repeat password',
txtOptional: 'optional', txtOptional: 'optional',