diff --git a/src/Resources/public/administration/js/melv-turnstile.js b/src/Resources/public/administration/js/melv-turnstile.js index 03db3ce..4e62869 100644 --- a/src/Resources/public/administration/js/melv-turnstile.js +++ b/src/Resources/public/administration/js/melv-turnstile.js @@ -15,8 +15,7 @@ Shopware.Component.override('sw-settings-captcha-select-v2', { {% block sw_settings_captcha_select_v2_cloudflare_turnstile_site_key %} @@ -24,8 +23,7 @@ Shopware.Component.override('sw-settings-captcha-select-v2', { {% block sw_settings_captcha_select_v2_cloudflare_turnstile_secret_key %} @@ -35,51 +33,35 @@ Shopware.Component.override('sw-settings-captcha-select-v2', { {% endblock %} `, - data() { - return { - defaultConfig: { - isActive: false, - config: { - siteKey: '', - secretKey: '' - } - } - }; - }, - created() { - this.initializeTurnstileConfig(); + this.initConfig(); }, methods: { - initializeTurnstileConfig() { + initConfig() { if (!this.currentValue.cloudFlareTurnstile) { - this.$set(this.currentValue, 'cloudFlareTurnstile', { ...this.defaultConfig }); + this.$set(this.currentValue, 'cloudFlareTurnstile', { + isActive: false, + config: { + siteKey: '', + secretKey: '' + } + }); } else if (!this.currentValue.cloudFlareTurnstile.config) { - this.$set(this.currentValue.cloudFlareTurnstile, 'config', { ...this.defaultConfig.config }); + this.$set(this.currentValue.cloudFlareTurnstile, 'config', { + siteKey: '', + secretKey: '' + }); } - }, - - updateSiteKey(value) { - this.$set(this.currentValue.cloudFlareTurnstile.config, 'siteKey', value); - this.updateCaptchaConfig(); - }, - - updateSecretKey(value) { - this.$set(this.currentValue.cloudFlareTurnstile.config, 'secretKey', value); - this.updateCaptchaConfig(); - }, - - updateCaptchaConfig() { - this.$emit('config-update', this.currentValue); } }, watch: { 'currentValue.cloudFlareTurnstile.config': { deep: true, - handler(newVal) { - console.debug('Turnstile config updated:', newVal); + handler(newValue) { + // Stellen Sie sicher, dass die Änderungen persistent sind + this.$emit('input', this.currentValue); } } }