Merge pull request 'fix/protected-tab-pdf' (#979) from fix/protected-tab-pdf into release/v9.3.0

This commit is contained in:
Maxim Kadushkin
2026-02-16 13:16:23 +00:00
9 changed files with 73 additions and 25 deletions

View File

@ -61,7 +61,8 @@ define([
this.addListeners({
'Common.Views.Protection': {
'protect:password': _.bind(this.onPasswordClick, this),
'protect:signature': _.bind(this.onSignatureClick, this)
'protect:signature': _.bind(this.onSignatureClick, this),
'protect:protectForm': _.bind(this.onProtectForm, this),
}
});
},
@ -91,6 +92,8 @@ define([
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this));
}
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('doc:mode-changed', _.bind(this.onChangeDocMode, this));
}
},
@ -132,6 +135,10 @@ define([
}
},
onProtectForm: function(state) {
this.api && this.api.asc_markAsFinal(state);
},
createToolbarPanel: function() {
return this.view.getPanel();
},
@ -256,6 +263,12 @@ define([
onCoAuthoringDisconnect: function() {
this.SetDisabled(true);
},
onChangeDocMode: function () {
if(this.view && this.view.btnProtectForm) {
this.view.btnProtectForm.toggle(this.api.asc_isFinal(), true);
}
}
}, Common.Controllers.Protection || {}));

View File

@ -58,6 +58,10 @@ define([
'<span id="slot-btn-change-password" class="btn-slot text x-huge"></span>' +
'<span id="slot-btn-signature" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="separator long protect-form"></div>' +
'<div class="group">' +
'<span id="slot-btn-protect-form" class="btn-slot text x-huge"></span>' +
'</div>' +
'</section>';
function setEvents() {
@ -122,6 +126,7 @@ define([
this._state = {disabled: false, hasPassword: false, disabledPassword: false, invisibleSignDisabled: false};
const me = this;
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
@ -163,6 +168,20 @@ define([
this.btnsInvisibleSignature.push(this.btnSignature);
}
if(this.appConfig.isPDFForm) {
this.btnProtectForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-restrict-editing',
caption: this.txtProtectForm,
enableToggle: true,
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.btnProtectForm.on('toggle', function (btn, state) {
me.fireEvent('protect:protectForm', [state]);
});
}
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -219,6 +238,7 @@ define([
}
Common.NotificationCenter.trigger('tab:visible', 'protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect'));
}
!me.btnProtectForm && (me.$el || $(me.el)).find('.separator.protect-form').hide();
setEvents.call(me);
});
@ -231,6 +251,7 @@ define([
this.btnAddPwd && this.btnAddPwd.render(this.$el.find('#slot-btn-add-password'));
this.btnPwd && this.btnPwd.render(this.$el.find('#slot-btn-change-password'));
this.btnSignature && this.btnSignature.render(this.$el.find('#slot-btn-signature'));
this.btnProtectForm && this.btnProtectForm.render(this.$el.find('#slot-btn-protect-form'));
}
return this.$el;
},
@ -353,6 +374,7 @@ define([
},
txtEncrypt: 'Encrypt',
txtProtectForm: 'Protect Form',
txtSignature: 'Signature',
hintAddPwd: 'Encrypt with password',
hintPwd: 'Change or delete password',

View File

@ -119,7 +119,7 @@ define([
},
onProtectDocClick: function(state) {
this.view.btnProtectDoc.toggle(!state, true);
this.view && this.view.btnProtectDoc && this.view.btnProtectDoc.toggle(!state, true);
if (state) {
var me = this;
me._docProtectDlg = new DE.Views.ProtectDialog({
@ -183,7 +183,7 @@ define([
type = props ? props.asc_getEditType() : Asc.c_oAscEDocProtect.None,
isProtected = (type === Asc.c_oAscEDocProtect.ReadOnly || type === Asc.c_oAscEDocProtect.Comments ||
type === Asc.c_oAscEDocProtect.TrackedChanges || type === Asc.c_oAscEDocProtect.Forms);
me.view && me.view.btnProtectDoc.toggle(!!isProtected, true);
me.view && me.view.btnProtectDoc && me.view.btnProtectDoc.toggle(!!isProtected, true);
if (isProtected) {
var str;
@ -226,7 +226,7 @@ define([
var props = this.getDocProps(true),
isProtected = props && (props.isReadOnly || props.isCommentsOnly || props.isFormsOnly || props.isReviewOnly);
this.view && this.view.btnProtectDoc.toggle(isProtected, true);
this.view && this.view.btnProtectDoc && this.view.btnProtectDoc.toggle(isProtected, true);
// off preview forms
var forms = this.getApplication().getController('FormsTab');
@ -305,7 +305,9 @@ define([
onLockDocumentProtection: function(state) {
this._state.lockDocProtect = state;
this.view && Common.Utils.lockControls(Common.enumLock.protectLock, state, {array: [this.view.btnProtectDoc]});
if(this.view && this.view.btnProtectDoc) {
Common.Utils.lockControls(Common.enumLock.protectLock, state, {array: [this.view.btnProtectDoc]});
}
if (this._docProtectDlg && this._docProtectDlg.isVisible())
this._docProtectDlg.SetDisabled(state || this._state.docProtection && (this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly ||
this._state.docProtection.isCommentsOnly || this._state.docProtection.isReviewOnly));

View File

@ -3929,16 +3929,20 @@ define([
}
Array.prototype.push.apply(me.toolbar.lockControls, headerfootertab.getView('HeaderFooterTab').getButtons());
if ( config.canProtect && !config.isPDFForm) {
if ( config.canProtect) {
tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'};
$panel = application.getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel) {
(config.isSignatureSupport || config.isPasswordSupport) && $panel.append($('<div class="separator long"></div>'));
var doctab = application.getController('DocProtection');
$panel.append(doctab.createToolbarPanel());
const doctabController = application.getController('DocProtection');
const doctabView = doctabController.getView('DocProtection');
const doctabButtons = doctabView.getButtons();
if(doctabButtons.length > 0 && (config.isSignatureSupport || config.isPasswordSupport)) {
$panel.append($('<div class="separator long"></div>'));
}
$panel.append(doctabController.createToolbarPanel());
me.toolbar.addTab(tab, $panel, 7);
me.toolbar.setVisible('protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect'));
Array.prototype.push.apply(me.toolbar.lockControls, doctab.getView('DocProtection').getButtons());
Array.prototype.push.apply(me.toolbar.lockControls, doctabButtons);
}
}

View File

@ -54,7 +54,7 @@ define([
function setEvents() {
var me = this;
this.btnProtectDoc.on('click', function (btn, e) {
this.btnProtectDoc && this.btnProtectDoc.on('click', function (btn, e) {
me.fireEvent('protect:document', [btn.pressed]);
});
me._isSetEvents = true;
@ -73,17 +73,20 @@ define([
this.lockedControls = [];
this._state = {disabled: false, currentProtectHint: this.hintProtectDoc };
this.btnProtectDoc = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-restrict-editing',
enableToggle: true,
caption: this.txtProtectDoc,
lock : [_set.lostConnect, _set.coAuth, _set.previewReviewMode, _set.viewFormMode, _set.protectLock, _set.viewMode],
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.lockedControls.push(this.btnProtectDoc);
if(!this.appConfig.isPDFForm) {
this.btnProtectDoc = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-restrict-editing',
enableToggle: true,
caption: this.txtProtectDoc,
lock : [_set.lostConnect, _set.coAuth, _set.previewReviewMode, _set.viewFormMode, _set.protectLock, _set.viewMode],
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.lockedControls.push(this.btnProtectDoc);
}
Common.UI.LayoutManager.addControls(this.lockedControls);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -97,7 +100,7 @@ define([
(new Promise(function (accept, reject) {
accept();
})).then(function(){
me.btnProtectDoc.updateHint(me._state.currentProtectHint, true);
me.btnProtectDoc && me.btnProtectDoc.updateHint(me._state.currentProtectHint, true);
setEvents.call(me);
});
},
@ -105,7 +108,7 @@ define([
getPanel: function () {
this.$el = $(_.template(template)( {} ));
this.btnProtectDoc.render(this.$el.find('#slot-btn-protect-doc'));
this.btnProtectDoc && this.btnProtectDoc.render(this.$el.find('#slot-btn-protect-doc'));
return this.$el;
},
@ -131,7 +134,7 @@ define([
} else if (type === Asc.c_oAscEDocProtect.TrackedChanges){ // none or tracked changes
str = this.txtDocProtectedTrack;
}
this.btnProtectDoc.updateHint(str, true);
this.btnProtectDoc && this.btnProtectDoc.updateHint(str, true);
this._state.currentProtectHint = str;
},
txtProtectDoc: 'Protect Document',

View File

@ -1051,6 +1051,7 @@
"Common.Views.Protection.txtChangePwd": "Change password",
"Common.Views.Protection.txtDeletePwd": "Delete password",
"Common.Views.Protection.txtEncrypt": "Encrypt",
"Common.Views.Protection.txtProtectForm": "Protect Form",
"Common.Views.Protection.txtInvisibleSignature": "Add digital signature",
"Common.Views.Protection.txtSignature": "Signature",
"Common.Views.Protection.txtSignatureLine": "Add signature line",

View File

@ -823,6 +823,7 @@
"Common.Views.Protection.txtChangePwd": "Change password",
"Common.Views.Protection.txtDeletePwd": "Delete password",
"Common.Views.Protection.txtEncrypt": "Encrypt",
"Common.Views.Protection.txtProtectForm": "Protect Form",
"Common.Views.Protection.txtInvisibleSignature": "Add digital signature",
"Common.Views.Protection.txtSignature": "Signature",
"Common.Views.Protection.txtSignatureLine": "Add signature line",

View File

@ -1134,6 +1134,7 @@
"Common.Views.Protection.txtChangePwd": "Change password",
"Common.Views.Protection.txtDeletePwd": "Delete password",
"Common.Views.Protection.txtEncrypt": "Encrypt",
"Common.Views.Protection.txtProtectForm": "Protect Form",
"Common.Views.Protection.txtInvisibleSignature": "Add digital signature",
"Common.Views.Protection.txtSignature": "Signature",
"Common.Views.Protection.txtSignatureLine": "Add signature line",

View File

@ -1072,6 +1072,7 @@
"Common.Views.Protection.txtChangePwd": "Change password",
"Common.Views.Protection.txtDeletePwd": "Delete password",
"Common.Views.Protection.txtEncrypt": "Encrypt",
"Common.Views.Protection.txtProtectForm": "Protect Form",
"Common.Views.Protection.txtInvisibleSignature": "Add digital signature",
"Common.Views.Protection.txtSignature": "Signature",
"Common.Views.Protection.txtSignatureLine": "Add signature line",