Merge pull request #927 from ONLYOFFICE/fix/required-forms

Fix/required forms
This commit is contained in:
Julia Radzhabova 2021-06-18 11:29:00 +03:00 committed by GitHub
commit a889a6ac14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View file

@ -255,12 +255,15 @@ DE.ApplicationController = new(function(){
common.utils.dialogPrint(url, api);
}
function onFillRequiredFields() {
if (btnSubmit) {
function onFillRequiredFields(isFilled) {
if (isFilled) {
btnSubmit.removeAttr('disabled');
btnSubmit.css("pointer-events", "auto");
// $requiredTooltip && $requiredTooltip.hide();
} else {
btnSubmit.attr({disabled: true});
btnSubmit.css("pointer-events", "none");
}
$requiredTooltip && $requiredTooltip.hide();
}
function hidePreloader() {
@ -338,7 +341,7 @@ DE.ApplicationController = new(function(){
api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl);
api.asc_registerCallback('asc_onPrint', onPrint);
api.asc_registerCallback('asc_onPrintUrl', onPrintUrl);
api.asc_registerCallback('asc_onFillRequiredFields', onFillRequiredFields);
api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields);
Common.Gateway.on('processmouse', onProcessMouse);
Common.Gateway.on('downloadas', onDownloadAs);
@ -420,8 +423,8 @@ DE.ApplicationController = new(function(){
});
// TODO: add asc_hasRequiredFields to sdk
/*
if (appOptions.canSubmitForms && api.asc_hasRequiredFields()) {
if (appOptions.canSubmitForms && !api.asc_IsAllRequiredFormsFilled()) {
var sgroup = $('#id-submit-group');
btnSubmit.attr({disabled: true});
btnSubmit.css("pointer-events", "none");
@ -432,6 +435,7 @@ DE.ApplicationController = new(function(){
$requiredTooltip.css({top : offset.top + btnSubmit.height() + 'px', left: offset.left + btnSubmit.outerWidth()/2 - $requiredTooltip.outerWidth() + 'px'});
$requiredTooltip.find('.close-div').on('click', function() {
$requiredTooltip.hide();
api.asc_MoveToFillingForm(true, true, true);
common.localStorage.setItem("de-embed-hide-submittip", 1);
sgroup.attr('data-toggle', 'tooltip');
sgroup.tooltip({
@ -448,7 +452,6 @@ DE.ApplicationController = new(function(){
});
}
}
*/
var documentMoveTimer;
var ismoved = false;

View file

@ -233,6 +233,18 @@ define([
},
onSubmitClick: function() {
if (!this.api.asc_IsAllRequiredFormsFilled()) {
var me = this;
Common.UI.warning({
msg: this.view.textRequired,
callback: function() {
me.api.asc_MoveToFillingForm(true, true, true);
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
});
return;
}
this.api.asc_SendForm();
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},

View file

@ -388,7 +388,8 @@ define([
tipPrevForm: 'Go to the previous field',
tipNextForm: 'Go to the next field',
tipSubmit: 'Submit form',
textSubmited: 'Form submitted successfully'
textSubmited: 'Form submitted successfully',
textRequired: 'Fill all required fields to send form.'
}
}()), DE.Views.FormsTab || {}));
});

View file

@ -1794,6 +1794,7 @@
"DE.Views.FormsTab.tipSubmit": "Submit form",
"DE.Views.FormsTab.tipTextField": "Insert text field",
"DE.Views.FormsTab.tipViewForm": "View form",
"DE.Views.FormsTab.textRequired": "Fill all required fields to send form.",
"DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center",
"DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left",
"DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of Page",