[SSE] Protect workbook
This commit is contained in:
parent
11c999227d
commit
7617a9681e
|
@ -153,7 +153,6 @@ define([
|
||||||
var me = this,
|
var me = this,
|
||||||
win = new Common.Views.PasswordDialog({
|
win = new Common.Views.PasswordDialog({
|
||||||
api: me.api,
|
api: me.api,
|
||||||
signType: 'invisible',
|
|
||||||
handler: function(result, props) {
|
handler: function(result, props) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
me.api.asc_setCurrentPassword(props);
|
me.api.asc_setCurrentPassword(props);
|
||||||
|
|
|
@ -55,22 +55,27 @@ define([
|
||||||
|
|
||||||
_.extend(_options, {
|
_.extend(_options, {
|
||||||
width : 395,
|
width : 395,
|
||||||
height : 270,
|
height : options.height || 261,
|
||||||
header : true,
|
header : true,
|
||||||
cls : 'modal-dlg',
|
cls : 'modal-dlg',
|
||||||
contentTemplate : '',
|
contentTemplate : '',
|
||||||
title : t.txtTitle,
|
title : options.txtTitle || t.txtTitle,
|
||||||
buttons: ['ok', 'cancel']
|
passwordOptional: !!options.passwordOptional,
|
||||||
|
buttons: options.buttons || ['ok', 'cancel']
|
||||||
|
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
|
this.handler = options.handler;
|
||||||
|
this.passwordOptional = options.passwordOptional || false;
|
||||||
|
this.txtDescription = options.txtDescription || t.txtDescription;
|
||||||
|
|
||||||
this.template = options.template || [
|
this.template = options.template || [
|
||||||
'<div class="box">',
|
'<div class="box">',
|
||||||
'<div class="input-row" style="margin-bottom: 10px;">',
|
'<div class="" style="margin-bottom: 10px;">',
|
||||||
'<label>' + t.txtDescription + '</label>',
|
'<label>' + t.txtDescription + '</label>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<div class="input-row">',
|
'<div class="input-row">',
|
||||||
'<label>' + t.txtPassword + '</label>',
|
'<label>' + t.txtPassword + (t.passwordOptional ? ' (' + t.txtOptional + ')': '') + '</label>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<div id="id-password-txt" class="input-row" style="margin-bottom: 5px;"></div>',
|
'<div id="id-password-txt" class="input-row" style="margin-bottom: 5px;"></div>',
|
||||||
'<div class="input-row">',
|
'<div class="input-row">',
|
||||||
|
@ -81,9 +86,6 @@ define([
|
||||||
'</div>'
|
'</div>'
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
this.handler = options.handler;
|
|
||||||
this.settings = options.settings;
|
|
||||||
|
|
||||||
_options.tpl = _.template(this.template)(_options);
|
_options.tpl = _.template(this.template)(_options);
|
||||||
|
|
||||||
Common.UI.Window.prototype.initialize.call(this, _options);
|
Common.UI.Window.prototype.initialize.call(this, _options);
|
||||||
|
@ -97,7 +99,7 @@ define([
|
||||||
this.inputPwd = new Common.UI.InputField({
|
this.inputPwd = new Common.UI.InputField({
|
||||||
el: $('#id-password-txt'),
|
el: $('#id-password-txt'),
|
||||||
type: 'password',
|
type: 'password',
|
||||||
allowBlank : false,
|
allowBlank : this.passwordOptional,
|
||||||
style : 'width: 100%;',
|
style : 'width: 100%;',
|
||||||
maxLength: 255,
|
maxLength: 255,
|
||||||
validateOnBlur: false
|
validateOnBlur: false
|
||||||
|
@ -105,7 +107,7 @@ define([
|
||||||
this.repeatPwd = new Common.UI.InputField({
|
this.repeatPwd = new Common.UI.InputField({
|
||||||
el: $('#id-repeat-txt'),
|
el: $('#id-repeat-txt'),
|
||||||
type: 'password',
|
type: 'password',
|
||||||
allowBlank : false,
|
allowBlank : this.passwordOptional,
|
||||||
style : 'width: 100%;',
|
style : 'width: 100%;',
|
||||||
maxLength: 255,
|
maxLength: 255,
|
||||||
validateOnBlur: false,
|
validateOnBlur: false,
|
||||||
|
@ -157,7 +159,8 @@ define([
|
||||||
txtDescription : "A Password is required to open this document",
|
txtDescription : "A Password is required to open this document",
|
||||||
txtRepeat: 'Repeat password',
|
txtRepeat: 'Repeat password',
|
||||||
txtIncorrectPwd: 'Confirmation password is not identical',
|
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 || {}));
|
}, Common.Views.PasswordDialog || {}));
|
||||||
});
|
});
|
|
@ -105,6 +105,27 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onWorkbookClick: function(state) {
|
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) {
|
onSheetClick: function(state) {
|
||||||
|
@ -129,6 +150,12 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onAppReady: function (config) {
|
onAppReady: function (config) {
|
||||||
|
var me = this;
|
||||||
|
(new Promise(function (resolve) {
|
||||||
|
resolve();
|
||||||
|
})).then(function () {
|
||||||
|
me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onCoAuthoringDisconnect: function() {
|
onCoAuthoringDisconnect: function() {
|
||||||
|
|
|
@ -209,7 +209,10 @@ define([
|
||||||
txtLockedCell: 'Locked Cell',
|
txtLockedCell: 'Locked Cell',
|
||||||
txtLockedShape: 'Shape Locked',
|
txtLockedShape: 'Shape Locked',
|
||||||
txtLockedText: 'Lock Text',
|
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 || {}));
|
}()), SSE.Views.WBProtection || {}));
|
||||||
});
|
});
|
Loading…
Reference in a new issue