From 88f573cd2819d1d5b27840c81824a50c6a2f19e2 Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 22 Aug 2024 14:42:26 +0800 Subject: [PATCH] * [misc] skip to submit form on check saveForm step. --- module/tutorial/js/index.ui.js | 24 +++++------------------- module/tutorial/lang/de.php | 1 - module/tutorial/lang/en.php | 1 - module/tutorial/lang/fr.php | 1 - module/tutorial/lang/zh-cn.php | 1 - module/tutorial/ui/index.html.php | 1 - 6 files changed, 5 insertions(+), 24 deletions(-) diff --git a/module/tutorial/js/index.ui.js b/module/tutorial/js/index.ui.js index c44d7b2259..42ec3593a6 100644 --- a/module/tutorial/js/index.ui.js +++ b/module/tutorial/js/index.ui.js @@ -128,6 +128,9 @@ const stepPresenters = $form.attr('zui-tutorial-step', step.id); step.$form = $form; + const ajaxForm = $form.zui('ajaxForm'); + ajaxForm.setOptions({beforeSubmit: () => false}); + const $saveBtn = $form.find('[type="submit"]'); return $saveBtn.length ? $saveBtn : $target; }, step); @@ -188,18 +191,6 @@ function isStepFormFilled(step, event) return true; } -function isStepFormSubmitted(step, event, info) -{ - if(!step.$form || !step.$form.length || !Array.isArray(info) || info.length < 2) return; - const response = info[1] || {}; - if(response.result === 'fail') - { - highlightStepTarget(step.$form, step, {content: typeof response.message === 'string' ? response.message : lang.formSubmitFailed}); - return false; - } - return true; -} - function highlightStepTarget($target, step, popoverOptions) { if(config.debug) showLog('Highlight', step, null, {$target, popover, popoverOptions}); @@ -278,7 +269,7 @@ function highlightStepTarget($target, step, popoverOptions) const $doc = scope.$(scope.document); if($doc.data('tutorialCheckBinding')) return; - $doc.data('tutorialCheckBinding', true).on('click change complete', '[zui-tutorial-step]', function(event, info) + $doc.data('tutorialCheckBinding', true).on('click change', '[zui-tutorial-step]', function(event, info) { if(!currentStep || currentStep.checkType !== event.type) return; @@ -286,15 +277,10 @@ function highlightStepTarget($target, step, popoverOptions) if(stepID !== currentStep.id) return; if(currentStep.type === 'form' && !isStepFormFilled(currentStep, event)) return; - if(currentStep.type === 'saveForm' && !isStepFormSubmitted(currentStep, event, info)) return; if(config.debug) showLog(`Step target ${event.type}`, currentStep, null, {stepID, event}); activeNextStep(); }); - - scope.zui.AjaxForm.optionsModifiers.push(() => { - return {headers: {'X-ZIN-Tutorial': currentStep.id}}; - }); }); } @@ -487,7 +473,7 @@ function activeTaskStep(guideName, taskName, stepIndex) step.task = task; step.index = stepIndex; step.isLast = stepIndex === task.steps.length - 1; - step.checkType = step.type === 'form' ? 'change' : (step.type === 'saveForm' ? 'complete' : 'click'); + step.checkType = step.type === 'form' ? 'change' : 'click'; if(step.type === 'openApp' && !task.app) task.app = step.app; if(!step.app && stepIndex) step.app = task.steps[stepIndex - 1].app; diff --git a/module/tutorial/lang/de.php b/module/tutorial/lang/de.php index f0c87b3ef3..58dc08b223 100644 --- a/module/tutorial/lang/de.php +++ b/module/tutorial/lang/de.php @@ -34,7 +34,6 @@ $lang->tutorial->novice = "Für einen Schnellstart, beginnen Sie mit e $lang->tutorial->dataNotSave = "In der Anleitung erstellte Daten werden nicht gespeichert!"; $lang->tutorial->clickTipFormat = "klicken %s"; $lang->tutorial->clickAndOpenIt = "Click %s to open %s."; -$lang->tutorial->formSubmitFailed = "Failed to submit the form. Please check and try again."; $lang->tutorial->tasks = new stdclass(); $lang->tutorial->tasks->createAccount = new stdclass(); diff --git a/module/tutorial/lang/en.php b/module/tutorial/lang/en.php index a2b2b36215..a562fc21ba 100644 --- a/module/tutorial/lang/en.php +++ b/module/tutorial/lang/en.php @@ -36,7 +36,6 @@ $lang->tutorial->novice = "For a quick start, let's go through a two-m $lang->tutorial->dataNotSave = "Data generated in this Tutorial will not be saved!"; $lang->tutorial->clickTipFormat = "Click %s"; $lang->tutorial->clickAndOpenIt = "Click %s to open %s."; -$lang->tutorial->formSubmitFailed = "Failed to submit the form. Please check and try again."; $lang->tutorial->guideTypes = array(); $lang->tutorial->guideTypes['starter'] = 'Getting Started'; diff --git a/module/tutorial/lang/fr.php b/module/tutorial/lang/fr.php index b43290e730..75d024ed6e 100644 --- a/module/tutorial/lang/fr.php +++ b/module/tutorial/lang/fr.php @@ -34,7 +34,6 @@ $lang->tutorial->novice = "For a quick start, let's go through a two-m $lang->tutorial->dataNotSave = "Data generated in this Tutorial will not be saved!"; $lang->tutorial->clickTipFormat = "cliquez %s"; $lang->tutorial->clickAndOpenIt = "Click %s to open %s."; -$lang->tutorial->formSubmitFailed = "Failed to submit the form. Please check and try again."; $lang->tutorial->tasks = new stdclass(); $lang->tutorial->tasks->createAccount = new stdclass(); diff --git a/module/tutorial/lang/zh-cn.php b/module/tutorial/lang/zh-cn.php index 376533fa4f..c7d2e387fc 100644 --- a/module/tutorial/lang/zh-cn.php +++ b/module/tutorial/lang/zh-cn.php @@ -36,7 +36,6 @@ $lang->tutorial->novice = "你可能初次使用禅道,是否进入 $lang->tutorial->dataNotSave = "教程任务中,数据不会保存。"; $lang->tutorial->clickTipFormat = "点击%s"; $lang->tutorial->clickAndOpenIt = "点击%s打开%s。"; -$lang->tutorial->formSubmitFailed = "表单提交失败,请检查输入的内容。"; $lang->tutorial->guideTypes = array(); $lang->tutorial->guideTypes['starter'] = '快速上手'; diff --git a/module/tutorial/ui/index.html.php b/module/tutorial/ui/index.html.php index 6f60974c31..aef7c5703e 100644 --- a/module/tutorial/ui/index.html.php +++ b/module/tutorial/ui/index.html.php @@ -165,7 +165,6 @@ jsVar('lang', array 'nextStep' => $lang->tutorial->nextStep, 'clickTipFormat' => $lang->tutorial->clickTipFormat, 'clickAndOpenIt' => $lang->tutorial->clickAndOpenIt, - 'formSubmitFailed' => $lang->tutorial->formSubmitFailed, 'congratulateTask' => $lang->tutorial->congratulateTask ));