From 34fafd5c1a090ff6e03ea34682a21ed10393924c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 20 May 2021 17:44:21 +0300 Subject: [PATCH] [DE embedded] Fix submit action --- apps/common/embed/resources/less/common.less | 19 ++++++++ .../embed/js/ApplicationController.js | 45 ++++++++++++++++--- apps/documenteditor/embed/locale/en.json | 3 ++ 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/apps/common/embed/resources/less/common.less b/apps/common/embed/resources/less/common.less index 20482b452..38e3834c7 100644 --- a/apps/common/embed/resources/less/common.less +++ b/apps/common/embed/resources/less/common.less @@ -67,6 +67,7 @@ @btnColored: #446995; @btnActiveColored: #293F59; @btnHoverColored: #375478; +@notificationColor: #fcfed7; @iconSpriteCommonPath: "../../../../common/embed/resources/img/glyphicons.png"; @icon-socnet-size: 40px; @@ -300,6 +301,10 @@ border: 1px solid @btnActiveColor; background-color: @btnActiveColor; } + + &[disabled] { + opacity: 0.4; + } } // Overlay control @@ -694,3 +699,17 @@ box-shadow: none; } } + +.submit-tooltip { + position: absolute; + z-index: 1000; + top: 58px; + right: 15px; + + padding: 7px 15px; + border-radius: 5px; + background-color: @notificationColor; + -webkit-box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + font-size: 11px; +} \ No newline at end of file diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index eabeb7404..992531f0d 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -41,7 +41,9 @@ DE.ApplicationController = new(function(){ created = false, ttOffset = [0, -10], labelDocName, - appOptions = {}; + appOptions = {}, + btnSubmit, + _submitFail, $submitedTooltip; // Initialize analytics // ------------------------- @@ -144,6 +146,11 @@ DE.ApplicationController = new(function(){ case Asc.c_oAscAsyncAction['Print']: text = me.downloadTextText; break; + case Asc.c_oAscAsyncAction['Submit']: + _submitFail = false; + $submitedTooltip && $submitedTooltip.hide(); + btnSubmit.attr({disabled: true}); + break; default: text = me.waitText; break; @@ -155,7 +162,16 @@ DE.ApplicationController = new(function(){ } } - function onLongActionEnd(){ + function onLongActionEnd(type, id){ + if (id==Asc.c_oAscAsyncAction['Submit']) { + btnSubmit.removeAttr('disabled'); + if (!$submitedTooltip) { + $submitedTooltip = $(''); + $(document.body).append($submitedTooltip); + $submitedTooltip.on('click', function() {$submitedTooltip.hide();}); + } + !_submitFail && $submitedTooltip.show(); + } hideMask(); } @@ -419,11 +435,13 @@ DE.ApplicationController = new(function(){ api.asc_setViewMode(!appOptions.canFillForms); + btnSubmit = $('#id-btn-submit'); + if (!appOptions.canFillForms) { $('#id-btn-prev-field').hide(); $('#id-btn-next-field').hide(); $('#id-btn-clear-fields').hide(); - $('#id-btn-submit').hide(); + btnSubmit.hide(); } else { $('#id-pages').hide(); $('#id-btn-next-field .caption').text(me.textNext); @@ -440,12 +458,12 @@ DE.ApplicationController = new(function(){ }); if (appOptions.canSubmitForms) { - $('#id-btn-submit .caption').text(me.textSubmit); - $('#id-btn-submit').on('click', function(){ + btnSubmit.find('.caption').text(me.textSubmit); + btnSubmit.on('click', function(){ api.asc_SendForm(); }); } else - $('#id-btn-submit').hide(); + btnSubmit.hide(); api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); api.asc_SetFastCollaborative(true); @@ -534,6 +552,16 @@ DE.ApplicationController = new(function(){ message = me.errorAccessDeny; break; + case Asc.c_oAscError.ID.Submit: + message = me.errorSubmit; + _submitFail = true; + $submitedTooltip && $submitedTooltip.hide(); + break; + + case Asc.c_oAscError.ID.EditingError: + message = me.errorEditingDownloadas; + break; + default: message = me.errorDefaultMessage.replace('%1', id); break; @@ -704,6 +732,9 @@ DE.ApplicationController = new(function(){ errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', textNext: 'Next Field', textClear: 'Clear All Fields', - textSubmit: 'Submit' + textSubmit: 'Submit', + textSubmited: 'Form submitted successfully
Click to close the tip.', + errorSubmit: 'Submit failed.', + errorEditingDownloadas: 'An error occurred during the work with the document.
Use the \'Download as...\' option to save the file backup copy to your computer hard drive.' } })(); \ No newline at end of file diff --git a/apps/documenteditor/embed/locale/en.json b/apps/documenteditor/embed/locale/en.json index 118dd202c..0fd6298c0 100644 --- a/apps/documenteditor/embed/locale/en.json +++ b/apps/documenteditor/embed/locale/en.json @@ -26,6 +26,9 @@ "DE.ApplicationController.textNext": "Next Field", "DE.ApplicationController.textClear": "Clear All Fields", "DE.ApplicationController.textSubmit": "Submit", + "DE.ApplicationController.textSubmited": "Form submitted successfully
Click to close the tip", + "DE.ApplicationController.errorSubmit": "Submit failed.", + "DE.ApplicationController.errorEditingDownloadas": "An error occurred during the work with the document.
Use the 'Download as...' option to save the file backup copy to your computer hard drive.", "DE.ApplicationView.txtDownload": "Download", "DE.ApplicationView.txtEmbed": "Embed", "DE.ApplicationView.txtFullScreen": "Full Screen",