From 124ee64a23075481f07a90d97a34c466449ebb59 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Nov 2022 16:58:14 +0300 Subject: [PATCH] Fix Bug 59838 --- .../main/app/controller/DocProtection.js | 21 +++++++++---------- .../main/app/view/ProtectDialog.js | 13 +++++++++++- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/main/app/controller/DocProtection.js b/apps/documenteditor/main/app/controller/DocProtection.js index 3174987a1..58a482d5a 100644 --- a/apps/documenteditor/main/app/controller/DocProtection.js +++ b/apps/documenteditor/main/app/controller/DocProtection.js @@ -116,12 +116,10 @@ define([ onProtectDocClick: function(state) { this.view.btnProtectDoc.toggle(!state, true); if (state) { - var me = this, - btn, - win = new DE.Views.ProtectDialog({ + var me = this; + me._docProtectDlg = new DE.Views.ProtectDialog({ props: me.appConfig, handler: function(result, value, props) { - btn = result; if (result == 'ok') { var protection = me.api.asc_getDocumentProtection() || new AscCommonWord.CDocProtect(); protection.asc_setEditType(props); @@ -131,14 +129,12 @@ define([ Common.NotificationCenter.trigger('edit:complete'); } }).on('close', function() { - if (btn!=='ok') - me.view.btnProtectDoc.toggle(false, true); + me._docProtectDlg = undefined; }); - win.show(); + me._docProtectDlg.show(); } else { var me = this, - btn, props = me.api.asc_getDocumentProtection(); if (props && props.asc_getIsPassword()) { var win = new Common.Views.OpenDialog({ @@ -149,7 +145,6 @@ define([ validatePwd: false, maxPasswordLength: 15, handler: function (result, value) { - btn = result; if (result == 'ok') { if (me.api) { props.asc_setEditType(Asc.c_oAscEDocProtect.None); @@ -160,8 +155,6 @@ define([ } } }).on('close', function() { - if (btn!=='ok') - me.view.btnProtectDoc.toggle(true, true); }); win.show(); @@ -208,6 +201,8 @@ define([ } props && this.applyRestrictions(props.type); + if (this._docProtectDlg && this._docProtectDlg.isVisible()) + this._docProtectDlg.SetDisabled(!!this._state.lockDocProtect || isProtected); Common.NotificationCenter.trigger('protect:doclock', props); }, @@ -246,7 +241,11 @@ define([ }, onLockDocumentProtection: function(state) { + this._state.lockDocProtect = state; 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 || {})); diff --git a/apps/documenteditor/main/app/view/ProtectDialog.js b/apps/documenteditor/main/app/view/ProtectDialog.js index 43c741b60..50481ae81 100644 --- a/apps/documenteditor/main/app/view/ProtectDialog.js +++ b/apps/documenteditor/main/app/view/ProtectDialog.js @@ -146,6 +146,10 @@ define([ value: Asc.c_oAscEDocProtect.Comments }); + this.btnOk = new Common.UI.Button({ + el: this.$window.find('.primary') + }); + this.afterRender(); }, @@ -171,8 +175,11 @@ define([ }, _handleInput: function(state) { + if (state === 'ok' && this.btnOk.isDisabled()) + return; + if (this.handler) { - if (state == 'ok') { + if (state === 'ok') { if (this.inputPwd.checkValidate() !== true) { this.inputPwd.focus(); return; @@ -208,6 +215,10 @@ define([ return Asc.c_oAscEDocProtect.Comments; }, + SetDisabled: function(disabled) { + this.btnOk.setDisabled(disabled); + }, + txtPassword : "Password", txtRepeat: 'Repeat password', txtOptional: 'optional',