[DE Form] Show protection tab in toolbar

This commit is contained in:
Alexey Koshelev
2026-02-14 13:39:46 +03:00
committed by Maxim Kadushkin
parent 350a02a9c9
commit e6530ff812
3 changed files with 33 additions and 24 deletions

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',