From aa9d331414335ce085faaf74765a09ee9e800c82 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 14 Jun 2018 15:11:50 +0300 Subject: [PATCH] [Desktop] Disable/enable password editing --- apps/common/main/lib/controller/Protection.js | 4 ++-- apps/common/main/lib/view/Protection.js | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/controller/Protection.js b/apps/common/main/lib/controller/Protection.js index 8cf112051..3939ef431 100644 --- a/apps/common/main/lib/controller/Protection.js +++ b/apps/common/main/lib/controller/Protection.js @@ -110,8 +110,8 @@ define([ return this; }, - onDocumentPassword: function(hasPassword) { - this.view && this.view.onDocumentPassword(hasPassword); + onDocumentPassword: function(hasPassword, disabled) { + this.view && this.view.onDocumentPassword(hasPassword, disabled); }, SetDisabled: function(state, canProtect) { diff --git a/apps/common/main/lib/view/Protection.js b/apps/common/main/lib/view/Protection.js index 43623b50e..0f4683c37 100644 --- a/apps/common/main/lib/view/Protection.js +++ b/apps/common/main/lib/view/Protection.js @@ -111,7 +111,7 @@ define([ this.btnsDelPwd = []; this.btnsChangePwd = []; - this._state = {disabled: false, hasPassword: false}; + this._state = {disabled: false, hasPassword: false, disabledPassword: false}; var filter = Common.localStorage.getKeysFilter(); this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; @@ -235,7 +235,7 @@ define([ cls: 'btn-text-default', style: 'width: 100%;', caption: this.txtAddPwd, - disabled: this._state.disabled, + disabled: this._state.disabled || this._state.disabledPassword, visible: !this._state.hasPassword }); this.btnsAddPwd.push(button); @@ -246,7 +246,7 @@ define([ cls: 'btn-text-default', style: 'width: 100%;', caption: this.txtDeletePwd, - disabled: this._state.disabled, + disabled: this._state.disabled || this._state.disabledPassword, visible: this._state.hasPassword }); this.btnsDelPwd.push(button); @@ -257,7 +257,7 @@ define([ cls: 'btn-text-default', style: 'width: 100%;', caption: this.txtChangePwd, - disabled: this._state.disabled, + disabled: this._state.disabled || this._state.disabledPassword, visible: this._state.hasPassword }); this.btnsChangePwd.push(button); @@ -279,21 +279,25 @@ define([ } this.btnsAddPwd.concat(this.btnsDelPwd, this.btnsChangePwd).forEach(function(button) { if ( button ) { - button.setDisabled(state); + button.setDisabled(state || this._state.disabledPassword); } }, this); }, - onDocumentPassword: function (hasPassword) { + onDocumentPassword: function (hasPassword, disabledPassword) { this._state.hasPassword = hasPassword; + this._state.disabledPassword = !!disabledPassword; + var disabled = this._state.disabledPassword || this._state.disabled; this.btnsAddPwd && this.btnsAddPwd.forEach(function(button) { if ( button ) { button.setVisible(!hasPassword); + button.setDisabled(disabled); } }, this); this.btnsDelPwd.concat(this.btnsChangePwd).forEach(function(button) { if ( button ) { button.setVisible(hasPassword); + button.setDisabled(disabled); } }, this); this.btnPwd.setVisible(hasPassword);