From 781030ed3d0f56ed9e7935fd90fc6dd27d4fef2a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 16 Nov 2017 12:43:21 +0300 Subject: [PATCH] [DE] Change layout for protect file menu. --- apps/common/main/lib/controller/Protection.js | 5 +- apps/common/main/lib/view/Protection.js | 86 +++++++++++++++++-- .../main/app/view/FileMenuPanels.js | 41 ++++++++- apps/documenteditor/main/locale/en.json | 21 +++-- 4 files changed, 130 insertions(+), 23 deletions(-) diff --git a/apps/common/main/lib/controller/Protection.js b/apps/common/main/lib/controller/Protection.js index 351ba98a2..af4c2f733 100644 --- a/apps/common/main/lib/controller/Protection.js +++ b/apps/common/main/lib/controller/Protection.js @@ -110,9 +110,7 @@ define([ }, onDocumentPassword: function(hasPassword) { - if (!this.view) return; - this.view.btnAddPwd.setVisible(!hasPassword); - this.view.btnPwd.setVisible(hasPassword); + this.view && this.view.onDocumentPassword(hasPassword); }, SetDisabled: function(state) { @@ -147,6 +145,7 @@ define([ onAppReady: function (config) { var me = this; // this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); + // this.onDocumentPassword(true); }, addPassword: function() { diff --git a/apps/common/main/lib/view/Protection.js b/apps/common/main/lib/view/Protection.js index a3cd222da..44ed9ab15 100644 --- a/apps/common/main/lib/view/Protection.js +++ b/apps/common/main/lib/view/Protection.js @@ -66,8 +66,16 @@ define([ var me = this; if ( me.appConfig.isDesktopApp && me.appConfig.isOffline ) { - this.btnAddPwd.on('click', function (e) { - me.fireEvent('protect:password', [me.btnAddPwd, 'add']); + this.btnsAddPwd.concat(this.btnsChangePwd).forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('protect:password', [b, 'add']); + }); + }); + + this.btnsDelPwd.forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('protect:password', [b, 'delete']); + }); }); this.btnPwd.menu.on('item:click', function (menu, item, e) { @@ -97,18 +105,27 @@ define([ this.appConfig = options.mode; + this.btnsInvisibleSignature = []; + this.btnsAddPwd = []; + this.btnsDelPwd = []; + this.btnsChangePwd = []; + + this._state = {disabled: false, hasPassword: false}; + if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) { this.btnAddPwd = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'review-prev', caption: this.txtEncrypt }); + this.btnsAddPwd.push(this.btnAddPwd); this.btnPwd = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'btn-ic-reviewview', caption: this.txtEncrypt, - menu: true + menu: true, + visible: false }); if (this.appConfig.canProtect) @@ -120,8 +137,6 @@ define([ }); } - this.btnsInvisibleSignature = []; - var filter = Common.localStorage.getKeysFilter(); this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; @@ -189,7 +204,6 @@ define([ if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) { this.btnAddPwd.render(this.$el.find('#slot-btn-add-password')); this.btnPwd.render(this.$el.find('#slot-btn-change-password')); - this.btnPwd.setVisible(false); this.btnSignature && this.btnSignature.render(this.$el.find('#slot-btn-signature')); } return this.$el; @@ -205,21 +219,76 @@ define([ var button = new Common.UI.Button({ cls: 'btn-text-default', style: 'width: 100%;', - caption: this.txtInvisibleSignature + caption: this.txtInvisibleSignature, + disabled: this._state.disabled }); this.btnsInvisibleSignature.push(button); + return button; + } else if ( type == 'add-password' ) { + var button = new Common.UI.Button({ + cls: 'btn-text-default', + style: 'width: 100%;', + caption: this.txtAddPwd, + disabled: this._state.disabled, + visible: !this._state.hasPassword + }); + this.btnsAddPwd.push(button); + + return button; + } else if ( type == 'del-password' ) { + var button = new Common.UI.Button({ + cls: 'btn-text-default', + style: 'width: 100%;', + caption: this.txtDeletePwd, + disabled: this._state.disabled, + visible: this._state.hasPassword + }); + this.btnsDelPwd.push(button); + + return button; + } else if ( type == 'change-password' ) { + var button = new Common.UI.Button({ + cls: 'btn-text-default', + style: 'width: 100%;', + caption: this.txtChangePwd, + disabled: this._state.disabled, + visible: this._state.hasPassword + }); + this.btnsChangePwd.push(button); + return button; } }, - SetDisabled: function (state, langs) { + SetDisabled: function (state) { + this._state.disabled = state; this.btnsInvisibleSignature && this.btnsInvisibleSignature.forEach(function(button) { if ( button ) { button.setDisabled(state); } }, this); this.btnSignature && this.btnSignature.setDisabled(state); + this.btnsAddPwd.concat(this.btnsDelPwd, this.btnsChangePwd).forEach(function(button) { + if ( button ) { + button.setDisabled(state); + } + }, this); + }, + + onDocumentPassword: function (hasPassword) { + this._state.hasPassword = hasPassword; + this.btnsAddPwd && this.btnsAddPwd.forEach(function(button) { + if ( button ) { + button.setVisible(!hasPassword); + } + }, this); + this.btnsDelPwd.concat(this.btnsChangePwd).forEach(function(button) { + if ( button ) { + button.setVisible(hasPassword); + } + }, this); + this.btnPwd.setVisible(hasPassword); }, txtEncrypt: 'Encrypt', @@ -229,6 +298,7 @@ define([ hintSignature: 'Add digital signature or signature line', txtChangePwd: 'Change password', txtDeletePwd: 'Delete password', + txtAddPwd: 'Add password', txtInvisibleSignature: 'Add digital signature', txtSignatureLine: 'Signature line' } diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index bc230f4ee..233dc2c18 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1101,9 +1101,22 @@ define([ template: _.template([ '', + '
', + '', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '
<%= scope.txtEncrypted %>
', + '
', '
', '', - '
', + '
', '
', '
' ].join('')), @@ -1131,6 +1144,21 @@ define([ $(this.el).html(this.template({scope: this})); var protection = DE.getController('Common.Controllers.Protection').getView(); + + this.btnAddPwd = protection.getButton('add-password'); + this.btnAddPwd.render(this.$el.find('#fms-btn-add-pwd')); + this.btnAddPwd.on('click', _.bind(this.closeMenu, this)); + + this.btnChangePwd = protection.getButton('change-password'); + this.btnChangePwd.render(this.$el.find('#fms-btn-change-pwd')); + this.btnChangePwd.on('click', _.bind(this.closeMenu, this)); + + this.btnDeletePwd = protection.getButton('del-password'); + this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd')); + this.btnDeletePwd.on('click', _.bind(this.closeMenu, this)); + + this.cntPassword = $('#id-fms-view-pwd'); + this.btnAddInvisibleSign = protection.getButton('signature'); this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign')); this.btnAddInvisibleSign.on('click', _.bind(this.closeMenu, this)); @@ -1153,6 +1181,7 @@ define([ show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); this.updateSignatures(); + this.updateEncrypt(); }, setMode: function(mode) { @@ -1180,7 +1209,7 @@ define([ primary: 'ok', callback: function(btn) { if (btn == 'ok') { - // me.api.editSignedDoc(); + me.api.asc_RemoveAllSignatures(); } } }); @@ -1217,6 +1246,10 @@ define([ this.cntSignatureView.html(this.templateSignature({tipText: tipText, hasSigned: (hasValid || hasInvalid), hasRequested: hasRequested})); }, + updateEncrypt: function() { + this.cntPassword.toggleClass('hidden', this.btnAddPwd.isVisible()); + }, + strProtect: 'Protect Document', strSignature: 'Signature', txtView: 'View signatures', @@ -1225,7 +1258,9 @@ define([ txtSignedInvalid: 'Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.', txtRequestedSignatures: 'This document needs to be signed.', notcriticalErrorTitle: 'Warning', - txtEditWarning: 'Editing will remove the signatures from the document.
Are you sure you want to continue?' + txtEditWarning: 'Editing will remove the signatures from the document.
Are you sure you want to continue?', + strEncrypt: 'Password', + txtEncrypted: 'This document has been protected by password' }, DE.Views.FileMenuPanels.ProtectDoc || {})); diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index a6ac6dcac..740e053c1 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -196,6 +196,7 @@ "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", "Common.Views.Plugins.textStop": "Stop", + "Common.Views.Protection.txtAddPwd": "Add password", "Common.Views.Protection.txtEncrypt": "Encrypt", "Common.Views.Protection.txtSignature": "Signature", "Common.Views.Protection.hintAddPwd": "Encrypt with password", @@ -1051,6 +1052,17 @@ "DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words", "DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", + "DE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Document", + "DE.Views.FileMenuPanels.ProtectDoc.strSignature": "Signature", + "DE.Views.FileMenuPanels.ProtectDoc.txtView": "View signatures", + "DE.Views.FileMenuPanels.ProtectDoc.txtEdit": "Edit document", + "DE.Views.FileMenuPanels.ProtectDoc.txtSigned": "Valid signatures has been added to the document. The document is protected from editing.", + "DE.Views.FileMenuPanels.ProtectDoc.txtSignedInvalid": "Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.", + "DE.Views.FileMenuPanels.ProtectDoc.txtRequestedSignatures": "This document needs to be signed.", + "DE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning", + "DE.Views.FileMenuPanels.ProtectDoc.txtEditWarning": "Editing will remove the signatures from the document.
Are you sure you want to continue?", + "DE.Views.FileMenuPanels.ProtectDoc.strEncrypt": "Password", + "DE.Views.FileMenuPanels.ProtectDoc.txtEncrypted": "This document has been protected by password", "DE.Views.FileMenuPanels.Settings.okButtonText": "Apply", "DE.Views.FileMenuPanels.Settings.strAlignGuides": "Turn on alignment guides", "DE.Views.FileMenuPanels.Settings.strAutoRecover": "Turn on autorecover", @@ -1097,15 +1109,6 @@ "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomRight": "Bottom right", - "DE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Document", - "DE.Views.FileMenuPanels.ProtectDoc.strSignature": "Signature", - "DE.Views.FileMenuPanels.ProtectDoc.txtView": "View signatures", - "DE.Views.FileMenuPanels.ProtectDoc.txtEdit": "Edit document", - "DE.Views.FileMenuPanels.ProtectDoc.txtSigned": "Valid signatures has been added to the document. The document is protected from editing.", - "DE.Views.FileMenuPanels.ProtectDoc.txtSignedInvalid": "Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.", - "DE.Views.FileMenuPanels.ProtectDoc.txtRequestedSignatures": "This document needs to be signed.", - "DE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning", - "DE.Views.FileMenuPanels.ProtectDoc.txtEditWarning": "Editing will remove the signatures from the document.
Are you sure you want to continue?", "DE.Views.HeaderFooterSettings.textDiffFirst": "Different first page", "DE.Views.HeaderFooterSettings.textDiffOdd": "Different odd and even pages", "DE.Views.HeaderFooterSettings.textHeaderFromBottom": "Footer from Bottom",