testing the fucking js if it is displayed on the admin

This commit is contained in:
Nils 2025-04-14 14:39:32 +02:00
parent 1727215818
commit 23201641c9
Signed by: slinicraftet204
GPG Key ID: 78E12696BAFC2A4B
3 changed files with 22 additions and 99 deletions

View File

@ -1,7 +1,7 @@
{
"name": "melvinachterhuis/turnstile-shopware6-plugin",
"description": "CloudFlare Turnstile Captcha",
"version": "0.1.04-alpha",
"version": "0.1.05-alpha",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [

View File

@ -1 +1,5 @@
import './module/sw-settings-basic-information/component/sw-settings-captcha-select-v2';
// src/Resources/app/administration/src/main.js
import './module/sw-settings-basic-information/component/sw-settings-captcha-select-v2';
// Füge zur Sicherheit hier einen Log hinzu, um zu sehen, ob DIESE Datei geladen wird
console.log('DEBUG Turnstile Plugin: main.js EXECUTED.');

View File

@ -1,108 +1,27 @@
// src/Resources/app/administration/src/module/sw-settings-basic-information/component/sw-settings-captcha-select-v2/index.js
import template from './sw-settings-captcha-select-v2.html.twig';
import enGB from './snippet/en-GB.json';
import deDE from './snippet/de-DE.json';
const { Component } = Shopware;
const { Component, Locale } = Shopware;
Locale.extend('en-GB', enGB);
Locale.extend('de-DE', deDE);
console.info('DEBUG Turnstile Plugin: Overriding sw-settings-captcha-select-v2 component...');
// Einfachstes mögliches Override, um zu sehen, ob es überhaupt greift
console.error('!!!!!! DEBUG Turnstile Plugin: index.js override EXECUTED !!!!!!'); // Auffällige Meldung
Component.override('sw-settings-captcha-select-v2', {
template,
template: `
<div style="border: 5px solid red; padding: 20px; margin: 20px;">
<h1>TEMPLATE OVERRIDE ACTIVE (Turnstile Debug)</h1>
<p>Wenn Sie das sehen, funktioniert das Template-Override.</p>
<p>Original-Template-Inhalt wird ignoriert.</p>
<!-- Ursprüngliches Template wird bewusst NICHT geladen -->
</div>
`,
// Hinzufügen eines 'created' Hooks für frühes Debugging
created() {
console.log('DEBUG Turnstile Plugin: Component created. Initial currentValue:', this.currentValue);
console.log('DEBUG Turnstile Plugin: Initial allCaptchaTypes:', this.allCaptchaTypes);
// Rufen Sie die ursprüngliche created-Methode auf, falls vorhanden (gute Praxis)
if (typeof this.$super('created') === 'function') {
this.$super('created');
}
console.error('!!!!!! DEBUG Turnstile Plugin: Component CREATED Hook EXECUTED !!!!!!');
// $super hier weglassen für den Minimaltest
},
computed: {
captchaOptions() {
console.log('--- DEBUG Turnstile Plugin: Computing captchaOptions ---');
// WICHTIG: Logge den Zustand von allCaptchaTypes HIER, da computed properties reaktiv sind
console.log('DEBUG Turnstile Plugin: this.allCaptchaTypes inside computed:', this.allCaptchaTypes);
// Verwende die Helper-Methode, um Basisoptionen zu bauen
const options = this.buildBaseCaptchaOptions();
console.log('DEBUG Turnstile Plugin: Base options built:', JSON.parse(JSON.stringify(options))); // Deep copy for logging
// Prüfen, ob unser Typ in den geladenen Daten existiert
if (this.allCaptchaTypes && this.allCaptchaTypes.cloudFlareTurnstile) {
console.log('DEBUG Turnstile Plugin: "cloudFlareTurnstile" FOUND in this.allCaptchaTypes. Adding to options.');
options.push({
value: 'cloudFlareTurnstile',
label: this.$tc('sw-settings-basic-information.captcha.label.cloudFlareTurnstile'),
});
} else {
// SEHR WICHTIG: Wenn diese Meldung erscheint, fehlt dein Captcha in den Daten!
console.warn('DEBUG Turnstile Plugin: "cloudFlareTurnstile" ***NOT FOUND*** in this.allCaptchaTypes!');
// Logge, was stattdessen vorhanden ist
if (this.allCaptchaTypes) {
console.warn('DEBUG Turnstile Plugin: Available keys in allCaptchaTypes:', Object.keys(this.allCaptchaTypes));
} else {
console.warn('DEBUG Turnstile Plugin: this.allCaptchaTypes is null or undefined.');
}
}
// Sortieren (optional)
options.sort((a, b) => a.label.localeCompare(b.label));
console.log('DEBUG Turnstile Plugin: Final options returned:', JSON.parse(JSON.stringify(options))); // Deep copy for logging
console.log('--- DEBUG Turnstile Plugin: Finished computing captchaOptions ---');
return options;
},
// Helper - unverändert lassen oder ggf. an SW 6.6 anpassen
buildBaseCaptchaOptions() {
// ... (Code aus der vorherigen Antwort - hier zur Kürze weggelassen) ...
// Stelle sicher, dass dieser Teil die Standard-Captchas korrekt generiert
// Basierend auf this.allCaptchaTypes
const options = [];
if (!this.allCaptchaTypes) {
console.warn('DEBUG Turnstile Plugin (buildBaseCaptchaOptions): this.allCaptchaTypes is missing!');
return [];
}
if (this.allCaptchaTypes.honeypot) options.push({ value: 'honeypot', label: this.$tc('sw-settings-basic-information.captcha.label.honeypot') });
if (this.allCaptchaTypes.basicCaptcha) options.push({ value: 'basicCaptcha', label: this.$tc('sw-settings-basic-information.captcha.label.basicCaptcha') });
if (this.allCaptchaTypes.googleReCaptchaV2) options.push({ value: 'googleReCaptchaV2', label: this.$tc('sw-settings-basic-information.captcha.label.googleReCaptchaV2') });
if (this.allCaptchaTypes.googleReCaptchaV3) options.push({ value: 'googleReCaptchaV3', label: this.$tc('sw-settings-basic-information.captcha.label.googleReCaptchaV3') });
return options;
}
},
// Optional: Hinzufügen von Methoden zum Stringifizieren für das Template-Debugging
methods: {
stringifyForDebug(value) {
// Einfache Stringifizierung für das Template, um Zirkelbezüge zu vermeiden
try {
// Nur Top-Level-Keys anzeigen, um Überladung zu vermeiden
if (value && typeof value === 'object') {
return JSON.stringify(Object.keys(value));
}
return JSON.stringify(value);
} catch (e) {
return '[Error stringifying]';
}
},
getCloudflareTurnstileDataForDebug() {
if (this.allCaptchaTypes && this.allCaptchaTypes.cloudFlareTurnstile) {
try {
return JSON.stringify(this.allCaptchaTypes.cloudFlareTurnstile, null, 2);
} catch (e) {
return '[Error stringifying cloudFlareTurnstile data]';
}
}
return 'Not found in allCaptchaTypes';
}
// Alle computed properties für den Test entfernen oder leer lassen
// captchaOptions() { return []; }
}
});
console.info('DEBUG Turnstile Plugin: Override applied.');
});