Skip to content

Commit

Permalink
Merge pull request #2990 from ONLYOFFICE/fix/pdf-forms
Browse files Browse the repository at this point in the history
Fix/pdf forms
  • Loading branch information
JuliaRadzhabova authored May 17, 2024
2 parents a3aa30d + 07248b4 commit 1955a20
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
2 changes: 2 additions & 0 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
header: {
users: false/true // users list button
save: false/true // save button
editMode: false/true // change mode button
},
leftMenu: {
navigation: false/true,
Expand All @@ -202,6 +203,7 @@
mode: false/true // init value in de/pe
change: false/true // hide/show feature in de/pe/sse
} / false / true // if false/true - use as init value in de/pe. use instead of customization.spellcheck parameter
roles: false/true // hide/show Roles manager, roles settings in right panel and roles in View form button in de
},
font: {
name: "Arial",
Expand Down
9 changes: 8 additions & 1 deletion apps/common/main/lib/controller/LayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,16 @@ Common.UI.FeaturesManager = new(function() {
}
};

var _isFeatureEnabled = function(name, force) {
if (!(_licensed || force) || !_config) return true;

return _config[name]!==false;
};

return {
init: _init,
canChange: _canChange,
getInitValue: _getInitValue
getInitValue: _getInitValue,
isFeatureEnabled: _isFeatureEnabled
}
})();
2 changes: 1 addition & 1 deletion apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ define([
'<div class="btn-slot" id="slot-hbtn-print-quick"></div>' +
'<div class="btn-slot" id="slot-hbtn-download"></div>' +
'</div>' +
'<div class="hedset">' +
'<div class="hedset" data-layout-name="header-editMode">' +
'<div class="btn-slot" id="slot-btn-edit-mode"></div>' +
'</div>' +
'<div class="hedset" data-layout-name="header-users">' +
Expand Down
7 changes: 7 additions & 0 deletions apps/documenteditor/main/app/controller/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ define([
},

onRefreshRolesList: function(roles) {
if (!Common.UI.FeaturesManager.isFeatureEnabled('roles')) return;

if (!roles) {
var oform = this.api.asc_GetOForm();
oform && (roles = oform.asc_getAllRoles());
Expand All @@ -582,6 +584,11 @@ define([
},

showRolesList: function(callback) {
if (!Common.UI.FeaturesManager.isFeatureEnabled('roles')) {
callback.call(this);
return;
}

var me = this,
oform = this.api.asc_GetOForm();
oform && (new DE.Views.SaveFormDlg({
Expand Down
2 changes: 2 additions & 0 deletions apps/documenteditor/main/app/view/FormSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ define([
this.DateOnlySettings = el.find('.form-datetime');
this.DefValueText = el.find('#form-txt-def-value').closest('tr');
this.DefValueDropDown = el.find('#form-combo-def-value').closest('tr');

!Common.UI.FeaturesManager.isFeatureEnabled('roles') && el.find('#form-combo-roles').closest('tr').hide();
},

createDelayedElements: function() {
Expand Down
46 changes: 26 additions & 20 deletions apps/documenteditor/main/app/view/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,28 @@ define([
});
if (this.btnViewFormRoles) {
this.btnViewFormRoles.on('click', function (b, e) {
var item = b.menu.getChecked();
if (item) {
item = item.caption;
} else if (me._state.roles && me._state.roles.length>0) {
item = me._state.roles[0].asc_getSettings().asc_getName();
var item;
if (b.menu) {
item = b.menu.getChecked();
if (item) {
item = item.caption;
} else if (me._state.roles && me._state.roles.length>0) {
item = me._state.roles[0].asc_getSettings().asc_getName();
}
}
me.fireEvent('forms:mode', [b.pressed, item]);
});
this.btnViewFormRoles.menu.on('item:click', _.bind(function (menu, item) {
if (!!item.checked) {
me.btnViewFormRoles.toggle(true, true);
me.fireEvent('forms:mode', [true, item.caption]);
}
}, me));
this.btnViewFormRoles.menu.on('show:after', function (menu) {
me.fillRolesMenu();
});
if (this.btnViewFormRoles.menu) {
this.btnViewFormRoles.menu.on('item:click', _.bind(function (menu, item) {
if (!!item.checked) {
me.btnViewFormRoles.toggle(true, true);
me.fireEvent('forms:mode', [true, item.caption]);
}
}, me));
this.btnViewFormRoles.menu.on('show:after', function (menu) {
me.fillRolesMenu();
});
}
}
this.btnManager && this.btnManager.on('click', function (b, e) {
me.fireEvent('forms:manager');
Expand Down Expand Up @@ -406,6 +411,7 @@ define([
iconCls: 'toolbar__icon btn-ic-sharing',
lock: [ _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode],
caption: this.capBtnManager,
visible: Common.UI.FeaturesManager.isFeatureEnabled('roles'),
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
Expand Down Expand Up @@ -483,13 +489,13 @@ define([
iconCls: 'toolbar__icon btn-big-sheet-view',
lock: [ _set.previewReviewMode, _set.formsNoRoles, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode],
caption: this.capBtnView,
split: true,
menu: new Common.UI.Menu({
split: Common.UI.FeaturesManager.isFeatureEnabled('roles'),
menu: Common.UI.FeaturesManager.isFeatureEnabled('roles') ? new Common.UI.Menu({
cls: 'menu-roles',
maxHeight: 270,
style: 'max-width: 400px;',
items: []
}),
}) : false,
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom',
Expand Down Expand Up @@ -580,9 +586,8 @@ define([
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnSubmit);
}

this.paragraphControls.push(this.btnSubmit);
} else if (this.appConfig.canDownloadForms) {
this.btnSaveForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
Expand All @@ -606,7 +611,7 @@ define([

return this;
},

onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
Expand Down Expand Up @@ -717,6 +722,7 @@ define([
this.btnSubmit && this.btnSubmit.render($host.find('#slot-btn-form-submit'));

$host.find('.forms-buttons').show();
!Common.UI.FeaturesManager.isFeatureEnabled('roles') && this.btnManager.cmpEl.parents('.group').hide().prev('.separator').hide();
}
this.btnClear.render($host.find('#slot-btn-form-clear'));
this.btnPrevForm.render($host.find('#slot-btn-form-prev'));
Expand Down

0 comments on commit 1955a20

Please sign in to comment.