[SSE] Protect workbook

This commit is contained in:
Julia Radzhabova 2021-06-21 23:53:28 +03:00
parent 11c999227d
commit 7617a9681e
4 changed files with 45 additions and 13 deletions

View file

@ -153,7 +153,6 @@ define([
var me = this,
win = new Common.Views.PasswordDialog({
api: me.api,
signType: 'invisible',
handler: function(result, props) {
if (result == 'ok') {
me.api.asc_setCurrentPassword(props);

View file

@ -55,22 +55,27 @@ define([
_.extend(_options, {
width : 395,
height : 270,
height : options.height || 261,
header : true,
cls : 'modal-dlg',
contentTemplate : '',
title : t.txtTitle,
buttons: ['ok', 'cancel']
title : options.txtTitle || t.txtTitle,
passwordOptional: !!options.passwordOptional,
buttons: options.buttons || ['ok', 'cancel']
}, options);
this.handler = options.handler;
this.passwordOptional = options.passwordOptional || false;
this.txtDescription = options.txtDescription || t.txtDescription;
this.template = options.template || [
'<div class="box">',
'<div class="input-row" style="margin-bottom: 10px;">',
'<div class="" style="margin-bottom: 10px;">',
'<label>' + t.txtDescription + '</label>',
'</div>',
'<div class="input-row">',
'<label>' + t.txtPassword + '</label>',
'<label>' + t.txtPassword + (t.passwordOptional ? ' (' + t.txtOptional + ')': '') + '</label>',
'</div>',
'<div id="id-password-txt" class="input-row" style="margin-bottom: 5px;"></div>',
'<div class="input-row">',
@ -81,9 +86,6 @@ define([
'</div>'
].join('');
this.handler = options.handler;
this.settings = options.settings;
_options.tpl = _.template(this.template)(_options);
Common.UI.Window.prototype.initialize.call(this, _options);
@ -97,7 +99,7 @@ define([
this.inputPwd = new Common.UI.InputField({
el: $('#id-password-txt'),
type: 'password',
allowBlank : false,
allowBlank : this.passwordOptional,
style : 'width: 100%;',
maxLength: 255,
validateOnBlur: false
@ -105,7 +107,7 @@ define([
this.repeatPwd = new Common.UI.InputField({
el: $('#id-repeat-txt'),
type: 'password',
allowBlank : false,
allowBlank : this.passwordOptional,
style : 'width: 100%;',
maxLength: 255,
validateOnBlur: false,
@ -157,7 +159,8 @@ define([
txtDescription : "A Password is required to open this document",
txtRepeat: 'Repeat password',
txtIncorrectPwd: 'Confirmation password is not identical',
txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.'
txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.',
txtOptional: 'Optional'
}, Common.Views.PasswordDialog || {}));
});

View file

@ -105,6 +105,27 @@ define([
},
onWorkbookClick: function(state) {
var me = this,
win = new Common.Views.PasswordDialog({
api: me.api,
txtTitle: me.view.txtWBTitle,
txtDescription: me.view.txtWBDescription,
passwordOptional: true,
height: 291,
buttons: [{
value: 'ok',
caption: me.view.txtProtect
}, 'cancel'],
primary: 'ok',
handler: function(result, props) {
if (result == 'ok') {
me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook());
}
Common.NotificationCenter.trigger('edit:complete');
}
});
win.show();
},
onSheetClick: function(state) {
@ -129,6 +150,12 @@ define([
},
onAppReady: function (config) {
var me = this;
(new Promise(function (resolve) {
resolve();
})).then(function () {
me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true);
});
},
onCoAuthoringDisconnect: function() {

View file

@ -209,7 +209,10 @@ define([
txtLockedCell: 'Locked Cell',
txtLockedShape: 'Shape Locked',
txtLockedText: 'Lock Text',
txtHiddenFormula: 'Hidden Formulas'
txtHiddenFormula: 'Hidden Formulas',
txtProtect: 'Protect',
txtWBDescription: 'To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets and renaming worksheets, you can protect the structure of your workbook with a password.',
txtWBTitle: 'Protect Workbook structure'
}
}()), SSE.Views.WBProtection || {}));
});