Merge pull request #2145 from ONLYOFFICE/fix/sign-protect

Fix/sign protect
This commit is contained in:
Julia Radzhabova 2022-12-16 23:18:41 +03:00 committed by GitHub
commit 1b942cf47f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 64 additions and 25 deletions

View file

@ -56,7 +56,8 @@ define([
maxlength : undefined,
placeHolder : '',
spellcheck : false,
disabled: false
disabled: false,
resize: false
},
template: _.template([
@ -133,6 +134,7 @@ define([
this._input.on('blur', _.bind(this.onInputChanged, this));
this._input.on('keydown', _.bind(this.onKeyDown, this));
if (this.maxLength) this._input.attr('maxlength', this.maxLength);
if (!this.resize) this._input.css('resize', 'none');
if (this.disabled)
this.setDisabled(this.disabled);
@ -140,6 +142,9 @@ define([
me.rendered = true;
if (me.value)
me.setValue(me.value);
return this;
},

View file

@ -147,6 +147,23 @@ define([
},
onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
accept();
})).then(function(){
me.onChangeProtectDocument();
Common.NotificationCenter.on('protect:doclock', _.bind(me.onChangeProtectDocument, me));
});
},
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (props && this.view) {
this.view._state.docProtection = props;
}
},
addPassword: function() {

View file

@ -87,10 +87,17 @@ define([
}
if (me.appConfig.isSignatureSupport) {
if (this.btnSignature.menu)
if (this.btnSignature.menu) {
this.btnSignature.menu.on('item:click', function (menu, item, e) {
me.fireEvent('protect:signature', [item.value, false]);
});
this.btnSignature.menu.on('show:after', function (menu, e) {
if (me._state) {
var isProtected = me._state.docProtection ? me._state.docProtection.isReadOnly || me._state.docProtection.isFormsOnly || me._state.docProtection.isCommentsOnly : false;
menu.items && menu.items[1].setDisabled(isProtected || me._state.disabled);
}
});
}
this.btnsInvisibleSignature.forEach(function(button) {
button.on('click', function (b, e) {
@ -314,13 +321,14 @@ define([
SetDisabled: function (state, canProtect) {
this._state.disabled = state;
this._state.invisibleSignDisabled = state && !canProtect;
var isProtected = this._state.docProtection ? this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly : false;
this.btnsInvisibleSignature && this.btnsInvisibleSignature.forEach(function(button) {
if ( button ) {
button.setDisabled(state && !canProtect);
}
}, this);
if (this.btnSignature && this.btnSignature.menu) {
this.btnSignature.menu.items && this.btnSignature.menu.items[1].setDisabled(state); // disable adding signature line
this.btnSignature.menu.items && this.btnSignature.menu.items[1].setDisabled(state || isProtected); // disable adding signature line
this.btnSignature.setDisabled(state && !canProtect); // disable adding any signature
}
this.btnsAddPwd.concat(this.btnsDelPwd, this.btnsChangePwd).forEach(function(button) {

View file

@ -79,7 +79,7 @@ define([
'<div class="input-row">',
'<label>' + this.textInstructions + '</label>',
'</div>',
'<textarea id="id-dlg-sign-settings-instructions" class="form-control" style="width: 100%;height: 35px;margin-bottom: 10px;resize: none;"></textarea>',
'<div id="id-dlg-sign-settings-instructions">',
'<div id="id-dlg-sign-settings-date"></div>',
'</div>',
'<div class="footer center">',
@ -121,15 +121,12 @@ define([
disabled : this.type=='view'
});
me.textareaInstructions = this.$window.find('textarea');
me.textareaInstructions.val(this.textDefInstruction);
me.textareaInstructions.keydown(function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
event.stopPropagation();
}
me.textareaInstructions = new Common.UI.TextareaField({
el : $window.find('#id-dlg-sign-settings-instructions'),
style : 'width: 100%; height: 35px;margin-bottom: 10px;',
value : this.textDefInstruction,
disabled : this.type=='view'
});
(this.type=='view') ? this.textareaInstructions.attr('disabled', 'disabled') : this.textareaInstructions.removeAttr('disabled');
this.textareaInstructions.toggleClass('disabled', this.type=='view');
this.chDate = new Common.UI.CheckBox({
el: $('#id-dlg-sign-settings-date'),
@ -160,7 +157,7 @@ define([
value = props.asc_getEmail();
me.inputEmail.setValue(value ? value : '');
value = props.asc_getInstructions();
me.textareaInstructions.val(value ? value : '');
me.textareaInstructions.setValue(value ? value : '');
me.chDate.setValue(props.asc_getShowDate());
me._currentGuid = props.asc_getGuid();
@ -174,7 +171,7 @@ define([
props.asc_setSigner1(me.inputName.getValue());
props.asc_setSigner2(me.inputTitle.getValue());
props.asc_setEmail(me.inputEmail.getValue());
props.asc_setInstructions(me.textareaInstructions.val());
props.asc_setInstructions(me.textareaInstructions.getValue());
props.asc_setShowDate(me.chDate.getValue()=='checked');
(me._currentGuid!==undefined) && props.asc_setGuid(me._currentGuid);

View file

@ -214,7 +214,7 @@ define([
if (!this._settings[Common.Utils.documentSettingsType.MailMerge].locked) // lock MailMerge-InsertField, если хотя бы один объект locked
this._settings[Common.Utils.documentSettingsType.MailMerge].locked = value.get_Locked() || isProtected;
if (!this._settings[Common.Utils.documentSettingsType.Signature].locked) // lock Signature, если хотя бы один объект locked
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.get_Locked() || isProtected;
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.get_Locked();
}
if (control_props && control_props.get_FormPr() && this.rightmenu.formSettings) {
@ -265,6 +265,9 @@ define([
if (!this._settings[Common.Utils.documentSettingsType.MailMerge].hidden)
this._settings[Common.Utils.documentSettingsType.MailMerge].panel.setLocked(this._settings[Common.Utils.documentSettingsType.MailMerge].locked);
if (!this._settings[Common.Utils.documentSettingsType.Signature].hidden)
this._settings[Common.Utils.documentSettingsType.Signature].panel.setProtected(isProtected);
if (!this.rightmenu.minimizedMode || open) {
var active;
@ -428,6 +431,7 @@ define([
this._settings[type].hidden = disabled ? 1 : 0;
this._settings[type].btn.setDisabled(disabled);
this._settings[type].panel.setLocked(this._settings[type].locked);
this._settings[type].panel.setProtected(this._state.docProtection ? this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly : false);
},
SetDisabled: function(disabled, allowMerge, allowSignature) {

View file

@ -2931,7 +2931,7 @@ define([
SetDisabled: function(state, canProtect, fillFormMode) {
this._isDisabled = state;
this._canProtect = canProtect;
this._canProtect = state ? canProtect : true;
this._fillFormMode = state ? fillFormMode : false;
},

View file

@ -71,6 +71,7 @@ define([
tip: undefined
};
this._locked = false;
this._protected = false;
this.render();
},
@ -156,6 +157,10 @@ define([
this._locked = locked;
},
setProtected: function (value) {
this._protected = value;
},
setMode: function(mode) {
this.mode = mode;
},
@ -288,7 +293,7 @@ define([
menu.items[3].setVisible(!requested);
menu.items[0].setDisabled(this._locked);
menu.items[3].setDisabled(this._locked);
menu.items[3].setDisabled(this._locked || this._protected);
menu.items[1].cmpEl.attr('data-value', record.get('certificateId')); // view certificate
menu.items[2].cmpEl.attr('data-value', signed ? 1 : 0); // view or edit signature settings
@ -307,7 +312,7 @@ define([
this.api.asc_ViewCertificate(item.cmpEl.attr('data-value'));
break;
case 2:
Common.NotificationCenter.trigger('protect:signature', 'visible', !!parseInt(item.cmpEl.attr('data-value')), guid);// can edit settings for requested signature
Common.NotificationCenter.trigger('protect:signature', 'visible', !!parseInt(item.cmpEl.attr('data-value')) || this._protected, guid);// can edit settings for requested signature
break;
case 3:
var me = this;

View file

@ -94,13 +94,14 @@
right: 14px;
width: 8px;
height: 8px;
border: solid 1px @icon-normal-pressed-ie;
border: solid 1px @icon-normal-pressed;
border: solid 1px @icon-normal-ie;
border: solid 1px @icon-normal;
opacity: 0.6;
border-bottom: none;
border-right: none;
background-image: none;
transform: rotate(-135deg);
filter: none;
&.nomargin {
margin: 2px;

View file

@ -87,13 +87,14 @@
right: 14px;
width: 8px;
height: 8px;
border: solid 1px @icon-normal-pressed-ie;
border: solid 1px @icon-normal-pressed;
border: solid 1px @icon-normal-ie;
border: solid 1px @icon-normal;
opacity: 0.6;
border-bottom: none;
border-right: none;
background-image: none;
transform: rotate(-135deg);
filter: none;
&.nomargin {
margin: 2px;

View file

@ -4433,7 +4433,7 @@ define([
SetDisabled: function(state, canProtect) {
this._isDisabled = state;
this._canProtect = canProtect;
this._canProtect = state ? canProtect : true;
this.disableEquationBar();
},

View file

@ -159,13 +159,14 @@
right: 14px;
width: 8px;
height: 8px;
border: solid 1px @icon-normal-pressed-ie;
border: solid 1px @icon-normal-pressed;
border: solid 1px @icon-normal-ie;
border: solid 1px @icon-normal;
opacity: 0.6;
border-bottom: none;
border-right: none;
background-image: none;
transform: rotate(-135deg);
filter: none;
&.nomargin {
margin: 2px;