diff --git a/apps/common/main/lib/controller/Protection.js b/apps/common/main/lib/controller/Protection.js
index 8e155a19b4..92c6b08896 100644
--- a/apps/common/main/lib/controller/Protection.js
+++ b/apps/common/main/lib/controller/Protection.js
@@ -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 || {}));
diff --git a/apps/common/main/lib/view/Protection.js b/apps/common/main/lib/view/Protection.js
index 7a520c9b96..101ac7ed76 100644
--- a/apps/common/main/lib/view/Protection.js
+++ b/apps/common/main/lib/view/Protection.js
@@ -58,6 +58,10 @@ define([
'' +
'' +
'' +
+ '
' +
+ '' +
+ '' +
+ '
' +
'';
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',
diff --git a/apps/documenteditor/main/app/controller/DocProtection.js b/apps/documenteditor/main/app/controller/DocProtection.js
index e200661461..3cf0bed3a9 100644
--- a/apps/documenteditor/main/app/controller/DocProtection.js
+++ b/apps/documenteditor/main/app/controller/DocProtection.js
@@ -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));
diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js
index 9b8f0f7b50..22a65aba71 100644
--- a/apps/documenteditor/main/app/controller/Toolbar.js
+++ b/apps/documenteditor/main/app/controller/Toolbar.js
@@ -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($(''));
- 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($(''));
+ }
+ $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);
}
}
diff --git a/apps/documenteditor/main/app/view/DocProtection.js b/apps/documenteditor/main/app/view/DocProtection.js
index 2a54ca8d98..75ea37086c 100644
--- a/apps/documenteditor/main/app/view/DocProtection.js
+++ b/apps/documenteditor/main/app/view/DocProtection.js
@@ -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',
diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json
index eb51fdcbae..5781bba471 100644
--- a/apps/documenteditor/main/locale/en.json
+++ b/apps/documenteditor/main/locale/en.json
@@ -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",
diff --git a/apps/pdfeditor/main/locale/en.json b/apps/pdfeditor/main/locale/en.json
index 67f9340e04..7e9e5c947e 100644
--- a/apps/pdfeditor/main/locale/en.json
+++ b/apps/pdfeditor/main/locale/en.json
@@ -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",
diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json
index 08c2a53bfe..942567a619 100644
--- a/apps/presentationeditor/main/locale/en.json
+++ b/apps/presentationeditor/main/locale/en.json
@@ -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",
diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json
index dd9214cadb..298c034c0e 100644
--- a/apps/spreadsheeteditor/main/locale/en.json
+++ b/apps/spreadsheeteditor/main/locale/en.json
@@ -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",