From 9dbb46510694ae0b2ff88283def70e79197fc28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 4 Dec 2025 13:56:51 +0100 Subject: [PATCH] feat: debounced forms --- .../controllers/form_debounce_controller.js | 25 +++++++++++++++++++ .../Partials/Form/Form/Navigation.html | 12 +++++++-- .../Private/Templates/Form/Form.html | 22 ++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/form_debounce_controller.js create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/Form.html diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/form_debounce_controller.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/form_debounce_controller.js new file mode 100644 index 00000000..21474f25 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/form_debounce_controller.js @@ -0,0 +1,25 @@ +import { Controller } from '@hotwired/stimulus' + +export default class extends Controller { + + static targets = ['button'] + static classes = [ 'disabled' ] + static values = { + isSubmitting: Boolean, + submittingLabel: { type: String, default: 'wird versendet' } + } + + debounce(e) { + if (true === this.isSubmittingValue) { + e.preventDefault() + e.stopPropagation() + return false + } + this.isSubmittingValue = true + this.buttonTarget.innerText = this.submittingLabelValue + if (this.hasDisabledClass) { + this.buttonTarget.classList.add(this.disabledClass) + } + } +} + diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Form/Form/Navigation.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Form/Form/Navigation.html index 6436f012..4b8ec61a 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Form/Form/Navigation.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Form/Form/Navigation.html @@ -7,10 +7,18 @@ - {formvh:translateElementProperty(element: form.currentPage, renderingOptionProperty: 'nextButtonLabel')} + + {formvh:translateElementProperty(element: form.currentPage, renderingOptionProperty: 'nextButtonLabel')} + - + {formvh:translateElementProperty(element: form, renderingOptionProperty: 'submitButtonLabel')} diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/Form.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/Form.html new file mode 100644 index 00000000..ef9d15c4 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/Form.html @@ -0,0 +1,22 @@ + + + + +
+ +
+
+
+