Merge pull request #1390 from ONLYOFFICE/fix/forms

Fix/forms
This commit is contained in:
Julia Radzhabova 2021-12-06 17:53:21 +03:00 committed by GitHub
commit 1940f6dc12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 19 deletions

View file

@ -401,7 +401,8 @@ define([
this.appOptions.canRequestSharingSettings = this.editorConfig.canRequestSharingSettings; this.appOptions.canRequestSharingSettings = this.editorConfig.canRequestSharingSettings;
this.appOptions.compatibleFeatures = (typeof (this.appOptions.customization) == 'object') && !!this.appOptions.customization.compatibleFeatures; this.appOptions.compatibleFeatures = (typeof (this.appOptions.customization) == 'object') && !!this.appOptions.customization.compatibleFeatures;
this.appOptions.canFeatureComparison = !!this.api.asc_isSupportFeature("comparison"); this.appOptions.canFeatureComparison = !!this.api.asc_isSupportFeature("comparison");
this.appOptions.canFeatureContentControl = !!this.api.asc_isSupportFeature("content-controls"); this.appOptions.canFeatureContentControl = true;
this.appOptions.canFeatureForms = !!this.api.asc_isSupportFeature("forms");
this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false));
@ -480,8 +481,7 @@ define([
} }
var type = data.doc ? /^(?:(docxf))$/.exec(data.doc.fileType) : false; var type = data.doc ? /^(?:(docxf))$/.exec(data.doc.fileType) : false;
this.appOptions.isFormCreator = !!(type && typeof type[1] === 'string'); this.appOptions.isFormCreator = !!(type && typeof type[1] === 'string') && this.appOptions.canFeatureForms; // show forms only for docxf
this.appOptions.canFeatureForms = this.appOptions.isFormCreator; // show forms only for docxf
type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false; type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false;
if (type && typeof type[1] === 'string') { if (type && typeof type[1] === 'string') {

View file

@ -3168,8 +3168,8 @@ define([
onAppShowed: function (config) { onAppShowed: function (config) {
var me = this; var me = this;
var compactview = !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.canFeatureForms); var compactview = !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator);
if ( config.isEdit || config.isRestrictedEdit && config.canFillForms && config.canFeatureForms) { if ( config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator) {
if ( Common.localStorage.itemExists("de-compact-toolbar") ) { if ( Common.localStorage.itemExists("de-compact-toolbar") ) {
compactview = Common.localStorage.getBool("de-compact-toolbar"); compactview = Common.localStorage.getBool("de-compact-toolbar");
} else } else
@ -3217,8 +3217,8 @@ define([
links.setApi(me.api).setConfig({toolbar: me}); links.setApi(me.api).setConfig({toolbar: me});
Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons()); Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons());
} }
if ( config.isEdit && config.canFeatureContentControl || config.isRestrictedEdit && config.canFillForms ) { if ( config.isEdit && config.canFeatureContentControl && config.canFeatureForms || config.isRestrictedEdit && config.canFillForms ) {
if (config.canFeatureForms) { if (config.isFormCreator) {
tab = {caption: me.textTabForms, action: 'forms', dataHintTitle: 'M'}; tab = {caption: me.textTabForms, action: 'forms', dataHintTitle: 'M'};
var forms = me.getApplication().getController('FormsTab'); var forms = me.getApplication().getController('FormsTab');
forms.setApi(me.api).setConfig({toolbar: me, config: config}); forms.setApi(me.api).setConfig({toolbar: me, config: config});
@ -3226,7 +3226,7 @@ define([
if ($panel) { if ($panel) {
me.toolbar.addTab(tab, $panel, 4); me.toolbar.addTab(tab, $panel, 4);
me.toolbar.setVisible('forms', true); me.toolbar.setVisible('forms', true);
config.isEdit && config.canFeatureContentControl && Array.prototype.push.apply(me.toolbar.toolbarControls, forms.getView('FormsTab').getButtons()); config.isEdit && config.canFeatureContentControl && config.canFeatureForms && Array.prototype.push.apply(me.toolbar.toolbarControls, forms.getView('FormsTab').getButtons());
!compactview && (config.isFormCreator || config.isRestrictedEdit && config.canFillForms) && me.toolbar.setTab('forms'); !compactview && (config.isFormCreator || config.isRestrictedEdit && config.canFillForms) && me.toolbar.setTab('forms');
} }
} }

View file

@ -167,7 +167,7 @@ define([
me.viewport.$el.attr('applang', me.appConfig.lang.split(/[\-_]/)[0]); me.viewport.$el.attr('applang', me.appConfig.lang.split(/[\-_]/)[0]);
if ( !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.canFeatureForms) || if ( !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator) ||
( !Common.localStorage.itemExists("de-compact-toolbar") && ( !Common.localStorage.itemExists("de-compact-toolbar") &&
config.customization && config.customization.compactToolbar )) { config.customization && config.customization.compactToolbar )) {
@ -207,8 +207,8 @@ define([
onAppReady: function (config) { onAppReady: function (config) {
var me = this; var me = this;
if ( me.header.btnOptions ) { if ( me.header.btnOptions ) {
var compactview = !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.canFeatureForms); var compactview = !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator);
if ( config.isEdit || config.isRestrictedEdit && config.canFillForms && config.canFeatureForms) { if ( config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator) {
if ( Common.localStorage.itemExists("de-compact-toolbar") ) { if ( Common.localStorage.itemExists("de-compact-toolbar") ) {
compactview = Common.localStorage.getBool("de-compact-toolbar"); compactview = Common.localStorage.getBool("de-compact-toolbar");
} else } else

View file

@ -405,12 +405,12 @@ define([
} }
if (this.mode.canDownload) { if (this.mode.canDownload) {
!this.panels['saveas'] && (this.panels['saveas'] = ((new DE.Views.FileMenuPanels.ViewSaveAs({menu: this, fileType: this.document.fileType})).render())); !this.panels['saveas'] && (this.panels['saveas'] = ((new DE.Views.FileMenuPanels.ViewSaveAs({menu: this, fileType: this.document.fileType, mode: this.mode})).render()));
} else if (this.mode.canDownloadOrigin) } else if (this.mode.canDownloadOrigin)
$('a',this.miDownload.$el).text(this.textDownload); $('a',this.miDownload.$el).text(this.textDownload);
if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) { if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) {
!this.panels['save-copy'] && (this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this, fileType: this.document.fileType})).render())); !this.panels['save-copy'] && (this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this, fileType: this.document.fileType, mode: this.mode})).render()));
} }
if (this.mode.canHelp && !this.panels['help']) { if (this.mode.canHelp && !this.panels['help']) {

View file

@ -94,9 +94,16 @@ define([
this.menu = options.menu; this.menu = options.menu;
this.fileType = options.fileType; this.fileType = options.fileType;
this.mode = options.mode;
}, },
render: function() { render: function() {
if (this.mode && !this.mode.canFeatureForms) {
this.formats[2].splice(1, 2);
this.formats[2] = this.formats[2].concat(this.formats[3]);
this.formats[3] = undefined;
}
this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()})); this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()}));
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this)); $('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));
@ -170,9 +177,16 @@ define([
this.menu = options.menu; this.menu = options.menu;
this.fileType = options.fileType; this.fileType = options.fileType;
this.mode = options.mode;
}, },
render: function() { render: function() {
if (this.mode && !this.mode.canFeatureForms) {
this.formats[2].splice(1, 2);
this.formats[2] = this.formats[2].concat(this.formats[3]);
this.formats[3] = undefined;
}
this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()})); this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()}));
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this)); $('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));

View file

@ -269,7 +269,7 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon previous-field', iconCls: 'toolbar__icon previous-field',
caption: this.capBtnPrev, caption: this.capBtnPrev,
disabled: true, disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'
@ -280,7 +280,7 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon next-field', iconCls: 'toolbar__icon next-field',
caption: this.capBtnNext, caption: this.capBtnNext,
disabled: true, disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode,
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'
@ -292,7 +292,7 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon submit-form', iconCls: 'toolbar__icon submit-form',
caption: this.capBtnSubmit, caption: this.capBtnSubmit,
disabled: true, disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode,
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'
@ -304,7 +304,7 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon save-form', iconCls: 'toolbar__icon save-form',
caption: this.capBtnSaveForm, caption: this.capBtnSaveForm,
disabled: true, disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode,
dataHint: '1', dataHint: '1',
dataHintDirection: 'bottom', dataHintDirection: 'bottom',
dataHintOffset: 'small' dataHintOffset: 'small'
@ -327,7 +327,7 @@ define([
(new Promise(function (accept, reject) { (new Promise(function (accept, reject) {
accept(); accept();
})).then(function(){ })).then(function(){
if (config.isEdit && config.canFeatureContentControl) { if (config.isEdit && config.canFeatureContentControl && config.canFeatureForms) {
if (config.canEditContentControl) { if (config.canEditContentControl) {
me.btnHighlight.setMenu(); me.btnHighlight.setMenu();
me.mnuFormsColorPicker = me.btnHighlight.getPicker(); me.mnuFormsColorPicker = me.btnHighlight.getPicker();

View file

@ -211,7 +211,7 @@ define([
this.signatureSettings = new DE.Views.SignatureSettings(); this.signatureSettings = new DE.Views.SignatureSettings();
} }
if (mode && mode.canFeatureContentControl && mode.canEditContentControl && mode.canFeatureForms) { if (mode && mode.canFeatureContentControl && mode.canEditContentControl && mode.isFormCreator) {
this.btnForm = new Common.UI.Button({ this.btnForm = new Common.UI.Button({
hint: this.txtFormSettings, hint: this.txtFormSettings,
asctype: Common.Utils.documentSettingsType.Form, asctype: Common.Utils.documentSettingsType.Form,