From ed5865f2f5d29000c1d55b17c5670c90bf4a92a8 Mon Sep 17 00:00:00 2001 From: MWD-Art Date: Wed, 23 Oct 2024 09:45:11 +0200 Subject: [PATCH] new melv-turnstile.js --- .../administration/js/melv-turnstile.js | 171 ++++++++---------- 1 file changed, 79 insertions(+), 92 deletions(-) diff --git a/src/Resources/public/administration/js/melv-turnstile.js b/src/Resources/public/administration/js/melv-turnstile.js index 3c1b9b0..03db3ce 100644 --- a/src/Resources/public/administration/js/melv-turnstile.js +++ b/src/Resources/public/administration/js/melv-turnstile.js @@ -1,99 +1,86 @@ -! function(e) { - var t = {}; +Shopware.Component.override('sw-settings-captcha-select-v2', { + template: ` + {% block sw_settings_captcha_select_v2_google_recaptcha_v2 %} + {% parent() %} + {% block sw_settings_captcha_select_v2_cloudflare_turnstile %} + + {% block sw_settings_captcha_select_v2_cloudflare_turnstile_description %} +

+ {{ $tc('sw-settings-basic-information.captcha.label.cloudFlareTurnstileDescription') }} +

+ {% endblock %} - function n(l) { - if(t[l]) return t[l].exports; - var r = t[l] = { - i: l, - l: !1, - exports: {} - }; - return e[l].call(r.exports, r, r.exports, n), r.l = !0, r.exports - } - n.m = e, n.c = t, n.d = function(e, t, l) { - n.o(e, t) || Object.defineProperty(e, t, { - enumerable: !0, - get: l - }) - }, n.r = function(e) { - "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { - value: "Module" - }), Object.defineProperty(e, "__esModule", { - value: !0 - }) - }, n.t = function(e, t) { - if(1 & t && (e = n(e)), 8 & t) return e; - if(4 & t && "object" == typeof e && e && e.__esModule) return e; - var l = Object.create(null); - if(n.r(l), Object.defineProperty(l, "default", { - enumerable: !0, - value: e - }), 2 & t && "string" != typeof e) - for(var r in e) n.d(l, r, function(t) { - return e[t] - }.bind(null, r)); - return l - }, n.n = function(e) { - var t = e && e.__esModule ? function() { - return e.default - } : function() { - return e - }; - return n.d(t, "a", t), t - }, n.o = function(e, t) { - return Object.prototype.hasOwnProperty.call(e, t) - }, n.p = "/bundles/melvturnstile/", n(n.s = "wNoc") -}({ - "+t2p": function(e) { - e.exports = JSON.parse('{"sw-settings-basic-information":{"captcha":{"label":{"cloudFlareTurnstile":"CloudFlare Turnstile","cloudFlareTurnstileSiteKey":"CloudFlare Turnstile site key","cloudFlareTurnstileSecretKey":"CloudFlare Turnstile secret key","cloudFlareTurnstileDescription":"Turnstile is CloudFlare\'s CAPTCHA alternative. It automatically chooses from a rotating suite of non-intrusive browser challenges based on telemetry and client behavior exhibited during a session."}}}}') - }, - "R+yN": function(e) { - e.exports = JSON.parse('{"sw-settings-basic-information":{"captcha":{"label":{"cloudFlareTurnstile":"CloudFlare Turnstile","cloudFlareTurnstileSiteKey":"CloudFlare Turnstile site key","cloudFlareTurnstileSecretKey":"CloudFlare Turnstile secret key","cloudFlareTurnstileDescription":"Turnstile is CloudFlare\'s CAPTCHA alternative. It automatically chooses from a rotating suite of non-intrusive browser challenges based on telemetry and client behavior exhibited during a session."}}}}') - }, - wNoc: function(e, t, n) { - "use strict"; - n.r(t); - var l = n("+t2p"), - r = n("R+yN"), - s = Shopware, - i = s.Component, - c = s.Locale; - c.extend("en-GB", l), c.extend("de-DE", r), i.override("sw-settings-captcha-select-v2", { - template: `\n{% block sw_settings_captcha_select_v2_google_recaptcha_v2 %}\n {% parent() %}\n {% block sw_settings_captcha_select_v2_cloudflare_turnstile %}\n \n\n \n {% block sw_settings_captcha_select_v2_cloudflare_turnstile_description %}\n

\n {{ $tc(\'sw-settings-basic-information.captcha.label.cloudFlareTurnstileDescription\') }}\n

\n {% endblock %}\n\n \n {% block sw_settings_captcha_select_v2_cloudflare_turnstile_site_key %}\n \n {% endblock %}\n\n \n {% block sw_settings_captcha_select_v2_cloudflare_turnstile_secret_key %}\n \n {% endblock %}\n
\n {% endblock %}\n{% endblock %}`, + {% block sw_settings_captcha_select_v2_cloudflare_turnstile_site_key %} + + {% endblock %} - mounted() { - // Warte, bis die Daten verfügbar sind - this.$nextTick(() => { - if (!this.currentValue.cloudFlareTurnstile) { - this.currentValue.cloudFlareTurnstile = { - isActive: false, - config: { - siteKey: '', - secretKey: '' - } - }; - } else if (!this.currentValue.cloudFlareTurnstile.config) { - this.currentValue.cloudFlareTurnstile.config = { - siteKey: '', - secretKey: '' - }; - } + {% block sw_settings_captcha_select_v2_cloudflare_turnstile_secret_key %} + + {% endblock %} + + {% endblock %} + {% endblock %} + `, - console.log('Mounted - Initial cloudFlareTurnstile:', JSON.stringify(this.currentValue.cloudFlareTurnstile.config)); - }); - }, - - methods: { - updateCaptchaConfig() { - console.log('Before updating - SiteKey:', this.currentValue.cloudFlareTurnstile.config.siteKey); - console.log('Before updating - SecretKey:', this.currentValue.cloudFlareTurnstile.config.secretKey); - - this.$set(this.currentValue.cloudFlareTurnstile.config, 'siteKey', this.currentValue.cloudFlareTurnstile.config.siteKey); - this.$set(this.currentValue.cloudFlareTurnstile.config, 'secretKey', this.currentValue.cloudFlareTurnstile.config.secretKey); - - console.log('Updated Captcha Config:', JSON.stringify(this.currentValue.cloudFlareTurnstile.config)); + data() { + return { + defaultConfig: { + isActive: false, + config: { + siteKey: '', + secretKey: '' } } - }); + }; + }, + + created() { + this.initializeTurnstileConfig(); + }, + + methods: { + initializeTurnstileConfig() { + if (!this.currentValue.cloudFlareTurnstile) { + this.$set(this.currentValue, 'cloudFlareTurnstile', { ...this.defaultConfig }); + } else if (!this.currentValue.cloudFlareTurnstile.config) { + this.$set(this.currentValue.cloudFlareTurnstile, 'config', { ...this.defaultConfig.config }); + } + }, + + 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); + } + } } }); \ No newline at end of file