[DE] Change layout for protect file menu.

This commit is contained in:
Julia Radzhabova 2017-11-16 12:43:21 +03:00
parent 1b26f5a94d
commit 781030ed3d
4 changed files with 130 additions and 23 deletions

View file

@ -110,9 +110,7 @@ define([
}, },
onDocumentPassword: function(hasPassword) { onDocumentPassword: function(hasPassword) {
if (!this.view) return; this.view && this.view.onDocumentPassword(hasPassword);
this.view.btnAddPwd.setVisible(!hasPassword);
this.view.btnPwd.setVisible(hasPassword);
}, },
SetDisabled: function(state) { SetDisabled: function(state) {
@ -147,6 +145,7 @@ define([
onAppReady: function (config) { onAppReady: function (config) {
var me = this; var me = this;
// this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); // 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() { addPassword: function() {

View file

@ -66,8 +66,16 @@ define([
var me = this; var me = this;
if ( me.appConfig.isDesktopApp && me.appConfig.isOffline ) { if ( me.appConfig.isDesktopApp && me.appConfig.isOffline ) {
this.btnAddPwd.on('click', function (e) { this.btnsAddPwd.concat(this.btnsChangePwd).forEach(function(button) {
me.fireEvent('protect:password', [me.btnAddPwd, 'add']); 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) { this.btnPwd.menu.on('item:click', function (menu, item, e) {
@ -97,18 +105,27 @@ define([
this.appConfig = options.mode; 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 ) { if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) {
this.btnAddPwd = new Common.UI.Button({ this.btnAddPwd = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'review-prev', iconCls: 'review-prev',
caption: this.txtEncrypt caption: this.txtEncrypt
}); });
this.btnsAddPwd.push(this.btnAddPwd);
this.btnPwd = new Common.UI.Button({ this.btnPwd = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-ic-reviewview', iconCls: 'btn-ic-reviewview',
caption: this.txtEncrypt, caption: this.txtEncrypt,
menu: true menu: true,
visible: false
}); });
if (this.appConfig.canProtect) if (this.appConfig.canProtect)
@ -120,8 +137,6 @@ define([
}); });
} }
this.btnsInvisibleSignature = [];
var filter = Common.localStorage.getKeysFilter(); var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
@ -189,7 +204,6 @@ define([
if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) { if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) {
this.btnAddPwd.render(this.$el.find('#slot-btn-add-password')); this.btnAddPwd.render(this.$el.find('#slot-btn-add-password'));
this.btnPwd.render(this.$el.find('#slot-btn-change-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')); this.btnSignature && this.btnSignature.render(this.$el.find('#slot-btn-signature'));
} }
return this.$el; return this.$el;
@ -205,21 +219,76 @@ define([
var button = new Common.UI.Button({ var button = new Common.UI.Button({
cls: 'btn-text-default', cls: 'btn-text-default',
style: 'width: 100%;', style: 'width: 100%;',
caption: this.txtInvisibleSignature caption: this.txtInvisibleSignature,
disabled: this._state.disabled
}); });
this.btnsInvisibleSignature.push(button); 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; return button;
} }
}, },
SetDisabled: function (state, langs) { SetDisabled: function (state) {
this._state.disabled = state;
this.btnsInvisibleSignature && this.btnsInvisibleSignature.forEach(function(button) { this.btnsInvisibleSignature && this.btnsInvisibleSignature.forEach(function(button) {
if ( button ) { if ( button ) {
button.setDisabled(state); button.setDisabled(state);
} }
}, this); }, this);
this.btnSignature && this.btnSignature.setDisabled(state); 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', txtEncrypt: 'Encrypt',
@ -229,6 +298,7 @@ define([
hintSignature: 'Add digital signature or signature line', hintSignature: 'Add digital signature or signature line',
txtChangePwd: 'Change password', txtChangePwd: 'Change password',
txtDeletePwd: 'Delete password', txtDeletePwd: 'Delete password',
txtAddPwd: 'Add password',
txtInvisibleSignature: 'Add digital signature', txtInvisibleSignature: 'Add digital signature',
txtSignatureLine: 'Signature line' txtSignatureLine: 'Signature line'
} }

View file

@ -1101,9 +1101,22 @@ define([
template: _.template([ template: _.template([
'<label id="id-fms-lbl-protect-header" style="font-size: 18px;"><%= scope.strProtect %></label>', '<label id="id-fms-lbl-protect-header" style="font-size: 18px;"><%= scope.strProtect %></label>',
'<div id="id-fms-password">',
'<label class="header"><%= scope.strEncrypt %></label>',
'<div id="fms-btn-add-pwd" style="width:190px;"></div>',
'<table id="id-fms-view-pwd" cols="2" width="300">',
'<tr>',
'<td colspan="2"><span><%= scope.txtEncrypted %></span></td>',
'</tr>',
'<tr>',
'<td><div id="fms-btn-change-pwd" style="width:190px;"></div></td>',
'<td align="right"><div id="fms-btn-delete-pwd" style="width:190px; margin-left:20px;"></div></td>',
'</tr>',
'</table>',
'</div>',
'<div id="id-fms-signature">', '<div id="id-fms-signature">',
'<label class="header"><%= scope.strSignature %></label>', '<label class="header"><%= scope.strSignature %></label>',
'<div id="fms-btn-invisible-sign" style="width:190px; margin-top: 10px;margin-bottom: 20px;"></div>', '<div id="fms-btn-invisible-sign" style="width:190px; margin-bottom: 20px;"></div>',
'<div id="id-fms-signature-view"></div>', '<div id="id-fms-signature-view"></div>',
'</div>' '</div>'
].join('')), ].join('')),
@ -1131,6 +1144,21 @@ define([
$(this.el).html(this.template({scope: this})); $(this.el).html(this.template({scope: this}));
var protection = DE.getController('Common.Controllers.Protection').getView(); 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 = protection.getButton('signature');
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign')); this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
this.btnAddInvisibleSign.on('click', _.bind(this.closeMenu, this)); this.btnAddInvisibleSign.on('click', _.bind(this.closeMenu, this));
@ -1153,6 +1181,7 @@ define([
show: function() { show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments); Common.UI.BaseView.prototype.show.call(this,arguments);
this.updateSignatures(); this.updateSignatures();
this.updateEncrypt();
}, },
setMode: function(mode) { setMode: function(mode) {
@ -1180,7 +1209,7 @@ define([
primary: 'ok', primary: 'ok',
callback: function(btn) { callback: function(btn) {
if (btn == 'ok') { 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})); this.cntSignatureView.html(this.templateSignature({tipText: tipText, hasSigned: (hasValid || hasInvalid), hasRequested: hasRequested}));
}, },
updateEncrypt: function() {
this.cntPassword.toggleClass('hidden', this.btnAddPwd.isVisible());
},
strProtect: 'Protect Document', strProtect: 'Protect Document',
strSignature: 'Signature', strSignature: 'Signature',
txtView: 'View signatures', 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.', 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.', txtRequestedSignatures: 'This document needs to be signed.',
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',
txtEditWarning: 'Editing will remove the signatures from the document.<br>Are you sure you want to continue?' txtEditWarning: 'Editing will remove the signatures from the document.<br>Are you sure you want to continue?',
strEncrypt: 'Password',
txtEncrypted: 'This document has been protected by password'
}, DE.Views.FileMenuPanels.ProtectDoc || {})); }, DE.Views.FileMenuPanels.ProtectDoc || {}));

View file

@ -196,6 +196,7 @@
"Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start", "Common.Views.Plugins.textStart": "Start",
"Common.Views.Plugins.textStop": "Stop", "Common.Views.Plugins.textStop": "Stop",
"Common.Views.Protection.txtAddPwd": "Add password",
"Common.Views.Protection.txtEncrypt": "Encrypt", "Common.Views.Protection.txtEncrypt": "Encrypt",
"Common.Views.Protection.txtSignature": "Signature", "Common.Views.Protection.txtSignature": "Signature",
"Common.Views.Protection.hintAddPwd": "Encrypt with password", "Common.Views.Protection.hintAddPwd": "Encrypt with password",
@ -1051,6 +1052,17 @@
"DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words", "DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words",
"DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights",
"DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have 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.<br>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.okButtonText": "Apply",
"DE.Views.FileMenuPanels.Settings.strAlignGuides": "Turn on alignment guides", "DE.Views.FileMenuPanels.Settings.strAlignGuides": "Turn on alignment guides",
"DE.Views.FileMenuPanels.Settings.strAutoRecover": "Turn on autorecover", "DE.Views.FileMenuPanels.Settings.strAutoRecover": "Turn on autorecover",
@ -1097,15 +1109,6 @@
"DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center",
"DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left",
"DE.Views.HeaderFooterSettings.textBottomRight": "Bottom right", "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.<br>Are you sure you want to continue?",
"DE.Views.HeaderFooterSettings.textDiffFirst": "Different first page", "DE.Views.HeaderFooterSettings.textDiffFirst": "Different first page",
"DE.Views.HeaderFooterSettings.textDiffOdd": "Different odd and even pages", "DE.Views.HeaderFooterSettings.textDiffOdd": "Different odd and even pages",
"DE.Views.HeaderFooterSettings.textHeaderFromBottom": "Footer from Bottom", "DE.Views.HeaderFooterSettings.textHeaderFromBottom": "Footer from Bottom",